diff --git a/asm/code_8045A00.s b/asm/code_8045A00.s index 5f79ba4d4..74dd85a19 100644 --- a/asm/code_8045A00.s +++ b/asm/code_8045A00.s @@ -442,7 +442,7 @@ _08046110: ldrsh r0, [r5, r1] movs r2, 0x2 ldrsh r1, [r5, r2] - bl GetTileSafe + bl GetTileMut str r4, [r0, 0x14] ldrh r1, [r0] movs r0, 0x20 @@ -528,7 +528,7 @@ sub_80461C8: ldrsh r0, [r2, r1] movs r3, 0x2 ldrsh r1, [r2, r3] - bl GetTileSafe + bl GetTileMut adds r6, r0, 0 ldr r5, [r6, 0x14] cmp r5, 0 diff --git a/asm/code_804AFAC.s b/asm/code_804AFAC.s index c2f4a3fea..48d8e5dd8 100644 --- a/asm/code_804AFAC.s +++ b/asm/code_804AFAC.s @@ -679,7 +679,7 @@ _0804B55A: adds r0, r5, 0 adds r1, r4, 0 str r3, [sp, 0xC] - bl GetTileSafe + bl GetTileMut adds r2, r0, 0 ldrh r0, [r2] ldr r6, _0804B630 @@ -1196,7 +1196,7 @@ _0804B962: ldr r2, _0804B9F0 add r2, sp str r3, [r2] - bl GetTileSafe + bl GetTileMut ldrh r1, [r0] mov r2, r9 ands r1, r2 @@ -1205,7 +1205,7 @@ _0804B962: strh r1, [r0] adds r0, r4, 0 adds r1, r5, 0 - bl GetTileSafe + bl GetTileMut ldr r1, _0804B9D0 add r1, sp ldrb r1, [r1] @@ -1294,7 +1294,7 @@ _0804B9F4: strh r0, [r7, 0x6] adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut ldrh r1, [r0] ldr r3, _0804BBF8 adds r2, r3, 0 @@ -1304,7 +1304,7 @@ _0804B9F4: strh r1, [r0] adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut movs r1, 0xFF strb r1, [r0, 0x9] _0804BA72: @@ -1805,7 +1805,7 @@ _0804BE84: ldr r2, _0804BEFC add r2, sp str r3, [r2] - bl GetTileSafe + bl GetTileMut ldrh r1, [r0] mov r2, r8 ands r1, r2 @@ -1814,7 +1814,7 @@ _0804BE84: strh r1, [r0] adds r0, r4, 0 adds r1, r5, 0 - bl GetTileSafe + bl GetTileMut ldr r1, _0804BEE0 add r1, sp ldrb r1, [r1] @@ -1902,7 +1902,7 @@ _0804BF00: strh r0, [r7, 0x6] adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut ldrh r1, [r0] ldr r6, _0804C090 adds r2, r6, 0 @@ -1912,7 +1912,7 @@ _0804BF00: strh r1, [r0] adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut movs r1, 0xFF strb r1, [r0, 0x9] _0804BF88: @@ -2563,7 +2563,7 @@ _0804C4C2: _0804C4CE: adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut ldrh r1, [r0] ands r1, r7 movs r2, 0x1 @@ -3164,7 +3164,7 @@ _0804C95C: _0804C972: adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut ldrh r1, [r0] mov r2, r8 ands r1, r2 @@ -3173,7 +3173,7 @@ _0804C972: strh r1, [r0] adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut mov r1, r9 strb r1, [r0, 0x9] adds r4, 0x1 @@ -3373,7 +3373,7 @@ _0804CB0C: lsls r2, 5 add r2, sp str r3, [r2] - bl GetTileSafe + bl GetTileMut ldrh r1, [r0] mov r2, r8 ands r1, r2 @@ -3382,7 +3382,7 @@ _0804CB0C: strh r1, [r0] adds r0, r4, 0 adds r1, r5, 0 - bl GetTileSafe + bl GetTileMut movs r1, 0xE5 lsls r1, 5 add r1, sp @@ -3871,7 +3871,7 @@ _0804CEFA: beq _0804CF16 adds r0, r7, 0 adds r1, r6, 0 - bl GetTileSafe + bl GetTileMut ldrh r1, [r0] ldr r3, _0804D018 adds r2, r3, 0 @@ -4544,7 +4544,7 @@ _0804D3E0: adds r0, r4, 0 adds r1, r5, 0 str r3, [sp, 0x34] - bl GetTileSafe + bl GetTileMut ldrh r1, [r0] mov r2, r9 ands r1, r2 @@ -4553,7 +4553,7 @@ _0804D3E0: strh r1, [r0] adds r0, r4, 0 adds r1, r5, 0 - bl GetTileSafe + bl GetTileMut mov r1, sp ldrb r1, [r1, 0x10] strb r1, [r0, 0x9] @@ -4680,7 +4680,7 @@ _0804D4BA: strh r0, [r7, 0x6] adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut ldrh r1, [r0] ldr r3, _0804D530 adds r2, r3, 0 @@ -4690,7 +4690,7 @@ _0804D4BA: strh r1, [r0] adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut movs r1, 0xFE strb r1, [r0, 0x9] _0804D508: @@ -5815,7 +5815,7 @@ _0804DCF0: adds r0, r5, 0 adds r1, r4, 0 str r3, [sp, 0x54] - bl GetTileSafe + bl GetTileMut ldrh r1, [r0] ldr r3, [sp, 0x54] ands r1, r3 @@ -5945,7 +5945,7 @@ _0804DDE0: adds r0, r5, 0 adds r1, r4, 0 str r3, [sp, 0x54] - bl GetTileSafe + bl GetTileMut ldrh r1, [r0] ldr r3, [sp, 0x54] ands r1, r3 @@ -6076,7 +6076,7 @@ _0804DED0: adds r0, r5, 0 adds r1, r4, 0 str r3, [sp, 0x54] - bl GetTileSafe + bl GetTileMut ldrh r1, [r0] ldr r3, [sp, 0x54] ands r1, r3 @@ -6195,7 +6195,7 @@ _0804DFB6: adds r0, r5, 0 adds r1, r4, 0 str r3, [sp, 0x54] - bl GetTileSafe + bl GetTileMut ldrh r1, [r0] mov r2, r9 ands r1, r2 @@ -6617,7 +6617,7 @@ _0804E2AA: bne _0804E2F0 adds r0, r7, 0 mov r1, r8 - bl GetTileSafe + bl GetTileMut ldrh r2, [r0] ldr r4, _0804E2CC adds r1, r4, 0 @@ -6723,7 +6723,7 @@ _0804E360: beq _0804E390 adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut ldrh r2, [r0] ldr r3, _0804E38C adds r1, r3, 0 @@ -6773,7 +6773,7 @@ _0804E3BC: beq _0804E3EC adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut ldrh r2, [r0] ldr r3, _0804E3E8 adds r1, r3, 0 @@ -6829,7 +6829,7 @@ _0804E420: beq _0804E450 adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut ldrh r2, [r0] ldr r3, _0804E44C adds r1, r3, 0 @@ -6883,7 +6883,7 @@ _0804E482: beq _0804E4B0 adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut ldrh r2, [r0] ldr r3, _0804E4AC adds r1, r3, 0 @@ -6930,7 +6930,7 @@ _0804E4D0: beq _0804E508 adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut ldrh r2, [r0] ldr r3, _0804E504 adds r1, r3, 0 @@ -6979,7 +6979,7 @@ _0804E52C: beq _0804E564 adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut ldrh r2, [r0] ldr r3, _0804E560 adds r1, r3, 0 @@ -7379,7 +7379,7 @@ _0804E848: ldrsh r0, [r6, r1] movs r2, 0x2 ldrsh r1, [r6, r2] - bl GetTileSafe + bl GetTileMut ldrh r1, [r0] ldr r3, _0804E99C adds r2, r3, 0 @@ -7494,7 +7494,7 @@ _0804E908: _0804E926: adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut ldrh r2, [r0] ldr r3, _0804E99C adds r1, r3, 0 @@ -7628,7 +7628,7 @@ _0804EA0E: ble _0804EA4E subs r0, r5, 0x1 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut adds r2, r0, 0 ldrb r0, [r2, 0x9] cmp r0, 0xFF @@ -7653,7 +7653,7 @@ _0804EA4E: ble _0804EA82 subs r1, r4, 0x1 adds r0, r5, 0 - bl GetTileSafe + bl GetTileMut adds r2, r0, 0 ldrb r0, [r2, 0x9] cmp r0, 0xFF @@ -7680,7 +7680,7 @@ _0804EA82: bgt _0804EABA adds r0, r5, 0 adds r1, r6, 0 - bl GetTileSafe + bl GetTileMut adds r2, r0, 0 ldrb r0, [r2, 0x9] cmp r0, 0xFF @@ -7707,7 +7707,7 @@ _0804EABA: bgt _0804EB0E mov r0, r10 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut adds r2, r0, 0 ldrb r0, [r2, 0x9] cmp r0, 0xFF @@ -7740,7 +7740,7 @@ _0804EAF4: bne _0804EB0E adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut movs r1, 0xFF strb r1, [r0, 0x9] _0804EB0E: @@ -8099,7 +8099,7 @@ _0804ED98: adds r0, r5, 0 adds r1, r4, 0 str r3, [sp, 0x50] - bl GetTileSafe + bl GetTileMut ldrh r2, [r0] movs r1, 0x20 orrs r1, r2 @@ -8185,7 +8185,7 @@ _0804EE18: _0804EE38: adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut ldrh r2, [r0, 0x4] movs r1, 0x10 orrs r1, r2 @@ -8466,7 +8466,7 @@ _0804F046: _0804F05A: adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut ldrh r2, [r0] movs r1, 0x40 orrs r1, r2 @@ -8971,7 +8971,7 @@ _0804F40A: beq _0804F438 subs r0, r6, 0x1 adds r1, r5, 0 - bl GetTileSafe + bl GetTileMut ldrh r1, [r0] ands r1, r7 movs r2, 0x2 @@ -8982,7 +8982,7 @@ _0804F434: .4byte 0x0000fffc _0804F438: subs r0, r6, 0x1 adds r1, r5, 0 - bl GetTileSafe + bl GetTileMut ldrh r1, [r0] ands r1, r7 _0804F444: @@ -9057,7 +9057,7 @@ _0804F4BA: movs r7, 0 adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut mov r1, r9 mov r3, r8 lsrs r2, r3, 24 @@ -9140,7 +9140,7 @@ _0804F550: _0804F55A: adds r0, r5, 0x1 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut mov r1, r9 mov r3, r8 lsrs r2, r3, 24 @@ -9150,7 +9150,7 @@ _0804F55A: _0804F570: subs r1, r4, 0x1 adds r0, r5, 0 - bl GetTileSafe + bl GetTileMut mov r1, r9 mov r3, r8 lsrs r2, r3, 24 @@ -9160,7 +9160,7 @@ _0804F570: _0804F586: subs r0, r5, 0x1 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut mov r1, r9 mov r3, r8 lsrs r2, r3, 24 @@ -9170,7 +9170,7 @@ _0804F586: _0804F59C: adds r1, r4, 0x1 adds r0, r5, 0 - bl GetTileSafe + bl GetTileMut mov r1, r9 mov r3, r8 lsrs r2, r3, 24 @@ -9220,7 +9220,7 @@ _0804F5E2: _0804F5F0: adds r0, r6, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut ldrh r2, [r0, 0x4] movs r1, 0x20 orrs r1, r2 @@ -9400,7 +9400,7 @@ _0804F730: _0804F73C: mov r0, r8 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut movs r1, 0 bl sub_804F5C4 adds r4, 0x1 @@ -9425,7 +9425,7 @@ _0804F75E: _0804F76C: adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut ldrh r2, [r0] movs r1, 0x80 orrs r1, r2 @@ -9482,7 +9482,7 @@ _0804F7C8: _0804F7D4: adds r0, r4, 0 mov r1, r8 - bl GetTileSafe + bl GetTileMut movs r1, 0 bl sub_804F5C4 adds r4, 0x1 @@ -9507,7 +9507,7 @@ _0804F7F6: _0804F804: adds r0, r4, 0 adds r1, r5, 0 - bl GetTileSafe + bl GetTileMut ldrh r2, [r0] movs r1, 0x80 orrs r1, r2 @@ -9568,7 +9568,7 @@ _0804F864: mov r10, r0 adds r0, r5, 0 mov r1, r10 - bl GetTileSafe + bl GetTileMut movs r1, 0x4 bl sub_804F5C4 ldr r1, [sp] @@ -9576,12 +9576,12 @@ _0804F864: mov r9, r1 mov r0, r9 mov r1, r10 - bl GetTileSafe + bl GetTileMut movs r1, 0x4 bl sub_804F5C4 ldr r0, [sp] mov r1, r10 - bl GetTileSafe + bl GetTileMut movs r1, 0x4 bl sub_804F5C4 ldr r2, [sp] @@ -9589,118 +9589,118 @@ _0804F864: mov r8, r2 mov r0, r8 mov r1, r10 - bl GetTileSafe + bl GetTileMut movs r1, 0x4 bl sub_804F5C4 ldr r6, [sp, 0x4] subs r6, 0x1 adds r0, r5, 0 adds r1, r6, 0 - bl GetTileSafe + bl GetTileMut movs r1, 0x4 bl sub_804F5C4 adds r0, r5, 0 ldr r1, [sp, 0x4] - bl GetTileSafe + bl GetTileMut movs r1, 0x4 bl sub_804F5C4 ldr r4, [sp, 0x4] adds r4, 0x1 adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut movs r1, 0x4 bl sub_804F5C4 adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut movs r1, 0x4 bl sub_804F5C4 mov r0, r9 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut movs r1, 0x4 bl sub_804F5C4 ldr r0, [sp] adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut movs r1, 0x4 bl sub_804F5C4 mov r0, r8 mov r1, r10 - bl GetTileSafe + bl GetTileMut movs r1, 0x4 bl sub_804F5C4 mov r0, r8 adds r1, r6, 0 - bl GetTileSafe + bl GetTileMut movs r1, 0x4 bl sub_804F5C4 mov r0, r8 ldr r1, [sp, 0x4] - bl GetTileSafe + bl GetTileMut movs r1, 0x4 bl sub_804F5C4 mov r0, r8 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut movs r1, 0x4 bl sub_804F5C4 mov r0, r9 adds r1, r6, 0 - bl GetTileSafe + bl GetTileMut ldrh r2, [r0, 0x4] movs r1, 0x4 orrs r1, r2 strh r1, [r0, 0x4] mov r0, r9 adds r1, r6, 0 - bl GetTileSafe + bl GetTileMut ldrh r1, [r0, 0x4] movs r2, 0x40 orrs r1, r2 strh r1, [r0, 0x4] ldr r0, [sp] adds r1, r6, 0 - bl GetTileSafe + bl GetTileMut ldrh r1, [r0, 0x4] movs r4, 0x2 orrs r1, r4 strh r1, [r0, 0x4] mov r0, r9 ldr r1, [sp, 0x4] - bl GetTileSafe + bl GetTileMut ldrh r1, [r0, 0x4] orrs r1, r4 strh r1, [r0, 0x4] ldr r0, [sp] ldr r1, [sp, 0x4] - bl GetTileSafe + bl GetTileMut ldrh r1, [r0, 0x4] orrs r1, r4 strh r1, [r0, 0x4] mov r0, r9 adds r1, r6, 0 - bl GetTileSafe + bl GetTileMut ldrh r1, [r0, 0x4] movs r4, 0x10 orrs r1, r4 strh r1, [r0, 0x4] ldr r0, [sp] adds r1, r6, 0 - bl GetTileSafe + bl GetTileMut ldrh r1, [r0, 0x4] orrs r1, r4 strh r1, [r0, 0x4] mov r0, r9 ldr r1, [sp, 0x4] - bl GetTileSafe + bl GetTileMut ldrh r1, [r0, 0x4] orrs r1, r4 strh r1, [r0, 0x4] ldr r0, [sp] ldr r1, [sp, 0x4] - bl GetTileSafe + bl GetTileMut ldrh r1, [r0, 0x4] orrs r4, r1 strh r4, [r0, 0x4] @@ -9789,7 +9789,7 @@ _0804FA6C: _0804FA76: adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut movs r1, 0 bl sub_804F5C4 adds r4, 0x1 @@ -9861,7 +9861,7 @@ _0804FAD4: movs r4, 0x2 ldrsh r1, [r7, r4] adds r1, r2 - bl GetTileSafe + bl GetTileMut movs r1, 0 bl sub_804F5C4 _0804FB14: @@ -9917,28 +9917,28 @@ _0804FB54: ble _0804FBAE adds r0, r5, 0x1 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut movs r1, 0 bl sub_804F5C4 adds r1, r4, 0x1 adds r0, r5, 0 - bl GetTileSafe + bl GetTileMut movs r1, 0 bl sub_804F5C4 subs r0, r5, 0x1 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut movs r1, 0 bl sub_804F5C4 subs r1, r4, 0x1 adds r0, r5, 0 - bl GetTileSafe + bl GetTileMut movs r1, 0 bl sub_804F5C4 _0804FBAE: adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut movs r1, 0 bl sub_804F5C4 b _0804FBD2 diff --git a/asm/code_804FD30.s b/asm/code_804FD30.s index 19dec61b2..0ef076dfb 100644 --- a/asm/code_804FD30.s +++ b/asm/code_804FD30.s @@ -106,7 +106,7 @@ _0804FFAA: adds r4, r1, r0 ldrb r0, [r4] ldrb r1, [r4, 0x1] - bl GetTileSafe + bl GetTileMut adds r5, r0, 0 ldrh r1, [r5, 0x4] movs r0, 0x1 @@ -137,7 +137,7 @@ _08050002: _08050004: adds r0, r6, 0 adds r1, r5, 0 - bl GetTileSafe + bl GetTileMut adds r1, r0, 0 ldrh r2, [r1] movs r0, 0x3 @@ -245,7 +245,7 @@ _080500BC: _080500D8: ldrb r0, [r4] ldrb r1, [r4, 0x1] - bl GetTileSafe + bl GetTileMut ldrh r2, [r0, 0x4] movs r1, 0x2 orrs r1, r2 @@ -320,7 +320,7 @@ _08050128: _0805016C: ldrb r0, [r4] ldrb r1, [r4, 0x1] - bl GetTileSafe + bl GetTileMut ldrh r2, [r0, 0x4] movs r1, 0x2 orrs r1, r2 @@ -432,7 +432,7 @@ _0805024C: .4byte 0x00003a0c _08050250: .4byte gUnknown_80F4DA0 _08050254: ldrb r1, [r7, 0x1] - bl GetTileSafe + bl GetTileMut adds r4, r0, 0 movs r0, 0x2 bl DungeonRandInt @@ -549,7 +549,7 @@ _08050318: _08050334: ldrb r0, [r4] ldrb r1, [r4, 0x1] - bl GetTileSafe + bl GetTileMut ldrh r2, [r0, 0x4] movs r1, 0x4 orrs r1, r2 @@ -814,7 +814,7 @@ _0805051C: _0805053C: ldrb r0, [r4] ldrb r1, [r4, 0x1] - bl GetTileSafe + bl GetTileMut ldrh r2, [r0, 0x4] movs r1, 0x8 orrs r1, r2 @@ -969,7 +969,7 @@ _0805064E: _0805066A: ldrb r0, [r4] ldrb r1, [r4, 0x1] - bl GetTileSafe + bl GetTileMut ldrh r2, [r0, 0x4] movs r1, 0x8 orrs r1, r2 @@ -1137,7 +1137,7 @@ _080507A8: bne _080507B8 mov r0, r9 mov r1, r10 - bl GetTileSafe + bl GetTileMut bl sub_80506BC _080507B8: ldr r2, [sp, 0x68] @@ -1278,7 +1278,7 @@ _080508CC: cmp r1, 0 bne _080508DA adds r1, r5, 0 - bl GetTileSafe + bl GetTileMut bl sub_80506BC _080508DA: ldr r1, [sp, 0x7C] @@ -1446,7 +1446,7 @@ _08050A0A: bne _08050A1A ldr r0, [sp, 0x90] ldr r1, [sp, 0x94] - bl GetTileSafe + bl GetTileMut bl sub_80506BC _08050A1A: adds r5, 0x1 @@ -1650,7 +1650,7 @@ _08050B7C: subs r0, r7, 0x5 adds r1, r6, 0 str r2, [sp, 0x9C] - bl GetTileSafe + bl GetTileMut bl sub_80506BC ldr r2, [sp, 0x9C] _08050B92: @@ -1683,7 +1683,7 @@ _08050BB8: _08050BC0: mov r0, r9 mov r1, r10 - bl GetTileSafe + bl GetTileMut adds r2, r0, 0 ldrh r3, [r2] movs r0, 0x3 @@ -1777,7 +1777,7 @@ _08050C5C: _08050C68: adds r0, r7, 0 adds r1, r6, 0 - bl GetTileSafe + bl GetTileMut adds r2, r0, 0 ldrh r0, [r2] movs r3, 0x3 @@ -2135,7 +2135,7 @@ _08050F00: _08050F08: adds r0, r7, 0 adds r1, r6, 0 - bl GetTileSafe + bl GetTileMut adds r2, r0, 0 ldrb r1, [r4] movs r0, 0x87 @@ -2374,7 +2374,7 @@ _080510D6: adds r0, r5, 0 adds r1, r4, 0 str r3, [sp, 0x38] - bl GetTileSafe + bl GetTileMut ldrh r1, [r0] mov r2, r9 ands r1, r2 @@ -2383,7 +2383,7 @@ _080510D6: strh r1, [r0] adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut mov r1, sp ldrb r1, [r1, 0x10] strb r1, [r0, 0x9] @@ -2469,7 +2469,7 @@ _08051162: strh r0, [r6, 0x6] adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut ldrh r1, [r0] ldr r3, _080511EC adds r2, r3, 0 @@ -2479,7 +2479,7 @@ _08051162: strh r1, [r0] adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut movs r1, 0xFF strb r1, [r0, 0x9] ldr r4, [sp, 0x14] @@ -2663,7 +2663,7 @@ _080512EE: lsrs r4, 24 adds r0, r5, 0 adds r1, r6, 0 - bl GetTileSafe + bl GetTileMut movs r1, 0x1 str r1, [sp] adds r1, r4, 0 @@ -2711,7 +2711,7 @@ _08051338: _08051350: adds r0, r5, 0 adds r1, r6, 0 - bl GetTileSafe + bl GetTileMut adds r2, r0, 0 ldrh r1, [r2] movs r0, 0x10 @@ -2760,7 +2760,7 @@ _080513B8: _080513BC: adds r0, r5, 0 adds r1, r6, 0 - bl GetTileSafe + bl GetTileMut ldrh r2, [r0] movs r1, 0x10 orrs r1, r2 @@ -2788,7 +2788,7 @@ _080513EC: _080513F0: adds r0, r5, 0 adds r1, r6, 0 - bl GetTileSafe + bl GetTileMut adds r2, r0, 0 ldrh r1, [r2] movs r0, 0x3 @@ -2923,7 +2923,7 @@ _080514EE: lsrs r5, 24 adds r0, r7, 0 mov r1, r8 - bl GetTileSafe + bl GetTileMut adds r6, r0, 0 ldr r1, [sp, 0x4] ldr r2, _080515D0 @@ -3047,7 +3047,7 @@ _080515F6: lsrs r4, 24 adds r0, r7, 0 mov r1, r8 - bl GetTileSafe + bl GetTileMut adds r5, r0, 0 ldrb r6, [r5, 0x9] movs r0, 0x1 @@ -3154,7 +3154,7 @@ _080516CA: ldr r0, [r5] adds r1, r4, 0 str r2, [sp, 0xC] - bl GetTileSafe + bl GetTileMut ldrh r1, [r0] ldr r2, [sp, 0xC] ands r1, r2 @@ -3187,7 +3187,7 @@ _0805170A: ldr r0, [r5, 0x8] adds r1, r4, 0 str r2, [sp, 0xC] - bl GetTileSafe + bl GetTileMut ldrh r1, [r0] ldr r2, [sp, 0xC] ands r1, r2 @@ -3233,7 +3233,7 @@ _08051762: ldr r1, [r5, 0x4] adds r0, r4, 0 str r2, [sp, 0xC] - bl GetTileSafe + bl GetTileMut ldrh r1, [r0] ldr r2, [sp, 0xC] ands r1, r2 @@ -3266,7 +3266,7 @@ _080517A2: ldr r1, [r5, 0xC] adds r0, r4, 0 str r2, [sp, 0xC] - bl GetTileSafe + bl GetTileMut ldrh r1, [r0] ldr r2, [sp, 0xC] ands r1, r2 @@ -3306,7 +3306,7 @@ _080517EC: adds r0, r7, 0 adds r1, r5, 0 str r3, [sp, 0x10] - bl GetTileSafe + bl GetTileMut adds r2, r0, 0 ldrh r1, [r2] movs r0, 0x20 @@ -3370,7 +3370,7 @@ _08051864: adds r0, r7, 0 adds r1, r5, 0 str r3, [sp, 0x10] - bl GetTileSafe + bl GetTileMut adds r6, r0, 0 ldrh r1, [r6] movs r0, 0x20 @@ -3446,7 +3446,7 @@ sub_80518F0: _080518F8: adds r0, r5, 0 movs r1, 0x1 - bl GetTileSafe + bl GetTileMut adds r4, r0, 0 bl sub_804FD10 cmp r5, 0 @@ -3460,7 +3460,7 @@ _0805190E: _08051914: adds r0, r5, 0 movs r1, 0x1E - bl GetTileSafe + bl GetTileMut adds r4, r0, 0 bl sub_804FD10 cmp r5, 0 @@ -3614,7 +3614,7 @@ sub_8051A24: mov r8, r3 adds r0, r4, 0 adds r1, r5, 0 - bl GetTileSafe + bl GetTileMut adds r7, r0, 0 lsls r4, 16 lsls r5, 16 @@ -4067,7 +4067,7 @@ _08051E42: _08051E46: adds r0, r4, 0 adds r1, r5, 0 - bl GetTileSafe + bl GetTileMut adds r2, r0, 0 ldrb r0, [r2, 0xE] cmp r0, 0xF @@ -4107,7 +4107,7 @@ sub_8051E7C: movs r3, 0x6 ldrsh r1, [r2, r3] subs r1, 0x1 - bl GetTileSafe + bl GetTileMut str r0, [sp, 0x8] ldrh r1, [r0] movs r0, 0x80 @@ -4207,7 +4207,7 @@ _08051F10: bge _08051FCA adds r0, r5, 0 adds r1, r6, 0 - bl GetTileSafe + bl GetTileMut adds r4, r0, 0 ldrh r0, [r4] movs r3, 0x80 diff --git a/asm/code_805D8C8_1.s b/asm/code_805D8C8_1.s index f06cb8e2d..f2259e3f7 100644 --- a/asm/code_805D8C8_1.s +++ b/asm/code_805D8C8_1.s @@ -1489,7 +1489,7 @@ sub_80694C0: mov r9, r3 adds r0, r7, 0 mov r1, r8 - bl GetTileSafe + bl GetTileMut mov r10, r0 ldr r5, [r4, 0x70] adds r6, r5, 0 @@ -1536,7 +1536,7 @@ _08069522: blt _08069552 adds r1, r0, 0 adds r0, r2, 0 - bl GetTileSafe + bl GetTileMut adds r1, r0, 0 ldr r0, [r1, 0x10] cmp r0, r4 diff --git a/asm/code_8069E0C.s b/asm/code_8069E0C.s index 97672b2e2..7e590a7a2 100644 --- a/asm/code_8069E0C.s +++ b/asm/code_8069E0C.s @@ -102,7 +102,7 @@ _0806A488: movs r2, 0x6 ldrsh r1, [r6, r2] adds r1, r7 - bl GetTileSafe + bl GetTileMut adds r4, r0, 0 ldr r0, [r4, 0x10] cmp r0, 0 diff --git a/asm/code_8077274_1.s b/asm/code_8077274_1.s index 01c3324eb..65cdb1b1b 100644 --- a/asm/code_8077274_1.s +++ b/asm/code_8077274_1.s @@ -86,7 +86,7 @@ _0807ABC6: adds r0, r4, 0 adds r1, r6, 0 str r2, [sp, 0x1A4] - bl GetTileSafe + bl GetTileMut adds r1, r0, 0 ldr r0, [r1, 0x10] ldr r2, [sp, 0x1A4] @@ -176,7 +176,7 @@ _0807AC72: adds r0, r4, 0 adds r1, r6, 0 str r2, [sp, 0x1A4] - bl GetTileSafe + bl GetTileMut adds r1, r0, 0 ldr r0, [r1, 0x10] ldr r2, [sp, 0x1A4] diff --git a/asm/code_807CD9C.s b/asm/code_807CD9C.s index 358e4db4c..604aa7cea 100644 --- a/asm/code_807CD9C.s +++ b/asm/code_807CD9C.s @@ -831,7 +831,7 @@ _0807DBB6: _0807DBB8: adds r0, r4, 0 adds r1, r5, 0 - bl GetTileSafe + bl GetTileMut adds r2, r0, 0 ldrh r1, [r2] movs r0, 0x3 @@ -971,7 +971,7 @@ _0807DCD8: movs r6, 0 adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut adds r2, r0, 0 ldrh r1, [r2] ldr r3, _0807DD6C @@ -1094,7 +1094,7 @@ _0807DDC8: _0807DDCA: adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut adds r2, r0, 0 ldrh r1, [r2] movs r3, 0x80 @@ -1141,7 +1141,7 @@ _0807DE1A: beq _0807DE30 adds r0, r5, 0 adds r1, r4, 0 - bl GetTileSafe + bl GetTileMut ldrh r2, [r0] movs r1, 0x40 orrs r1, r2 @@ -1402,7 +1402,7 @@ _0807E014: bgt _0807E112 cmp r1, 0x1F bgt _0807E112 - bl GetTileSafe + bl GetTileMut mov r8, r0 ldr r0, [sp, 0x18] movs r2, 0 diff --git a/asm/code_807E5AC.s b/asm/code_807E5AC.s index 9ecbe863e..eaf80cb03 100644 --- a/asm/code_807E5AC.s +++ b/asm/code_807E5AC.s @@ -2468,7 +2468,7 @@ _0807FA1E: _0807FA22: adds r0, r5, 0 adds r1, r6, 0 - bl GetTileSafe + bl GetTileMut adds r4, r0, 0 ldrh r1, [r4, 0x4] movs r0, 0x4 diff --git a/include/dungeon_map_access.h b/include/dungeon_map_access.h index adee8dc5b..5defb8029 100644 --- a/include/dungeon_map_access.h +++ b/include/dungeon_map_access.h @@ -8,8 +8,8 @@ typedef struct unkStruct_202F190 Tile *unk0[6]; } unkStruct_202F190; -Tile *GetTile(s32 x, s32 y); -Tile *GetTileSafe(s32 x, s32 y); +const Tile *GetTile(s32 x, s32 y); +Tile *GetTileMut(s32 x, s32 y); void sub_8049ED4(void); void sub_804AC20(DungeonPos *pos); diff --git a/include/dungeon_movement.h b/include/dungeon_movement.h index 1549f1aa6..3d3973d23 100644 --- a/include/dungeon_movement.h +++ b/include/dungeon_movement.h @@ -7,7 +7,7 @@ extern u8 gWalkableTileToCrossableTerrain[8]; u8 GetCrossableTerrain(s16 species); -u8 sub_807034C(s16 id, struct Tile *tile); +u8 sub_807034C(s16 id, const Tile *tile); u8 sub_80703A0(Entity *pokemon, DungeonPos *pos); bool8 CanCrossWalls(Entity *pokemon); bool8 sub_807049C(Entity *pokemon, DungeonPos *pos); diff --git a/include/dungeon_util.h b/include/dungeon_util.h index 5ecd4b111..845a2ec51 100644 --- a/include/dungeon_util.h +++ b/include/dungeon_util.h @@ -5,13 +5,14 @@ #include "structs/dungeon_entity.h" #include "structs/str_position.h" #include "structs/str_traps.h" +#include "structs/map.h" extern const DungeonPos gAdjacentTileOffsets[NUM_DIRECTIONS]; bool8 EntityExists(Entity *pokemon); u32 GetEntityType(Entity *entity); u8 GetEntityRoom(Entity *entity); -struct Tile *GetTileAtEntitySafe(Entity *entity); +Tile *GetTileAtEntitySafe(Entity *entity); void sub_804535C(Entity *entity, PixelPos *pos); void SetEntityPixelPos(Entity *entity, s32 x, s32 y); void IncreaseEntityPixelPos(Entity *entity, s32 x, s32 y); diff --git a/src/code_803E724.c b/src/code_803E724.c index 475f05814..42be68d70 100644 --- a/src/code_803E724.c +++ b/src/code_803E724.c @@ -1081,7 +1081,7 @@ void sub_803F580(u8 a0) void sub_803F7BC(void) { UnkDungeonGlobal_unk181E8_sub *strPtr = &gDungeon->unk181e8; - Tile *tile = GetTile(strPtr->cameraPos.x, strPtr->cameraPos.y); + const Tile *tile = GetTile(strPtr->cameraPos.x, strPtr->cameraPos.y); u32 roomId = tile->room; if (strPtr->unk1820B != 0 || strPtr->unk1820C != 0 || strPtr->unk18217 != 0) { diff --git a/src/code_8040094.c b/src/code_8040094.c index 91c14d244..4386cd74c 100644 --- a/src/code_8040094.c +++ b/src/code_8040094.c @@ -26,7 +26,7 @@ extern const char *gUnknown_80FD040; // It became brighter on the floor // Luminous Orb??? void HandleLuminousOrbAction(Entity *pokemon) { - struct Tile *mapTile; + Tile *mapTile; int XCoord; int YCoord; @@ -36,7 +36,7 @@ void HandleLuminousOrbAction(Entity *pokemon) { for(XCoord = 0; XCoord < DUNGEON_MAX_SIZE_X; XCoord++) { - mapTile = GetTileSafe(XCoord, YCoord); + mapTile = GetTileMut(XCoord, YCoord); mapTile->unk4 = mapTile->unk4 | 1; } } diff --git a/src/code_8042B34.c b/src/code_8042B34.c index 234c0267a..89bbcd7c5 100644 --- a/src/code_8042B34.c +++ b/src/code_8042B34.c @@ -1055,7 +1055,7 @@ void sub_8043D60(void) for (y = 0; y < 32; y++) { for (x = 0; x < 56; x++) { - Entity *object = GetTileSafe(x, y)->object; + Entity *object = GetTileMut(x, y)->object; if (EntityExists(object) && GetEntityType(object) == ENTITY_TRAP) { Trap *trapData = GetTrapData(object); if (trapData->id == 27) { diff --git a/src/code_8044CC8.c b/src/code_8044CC8.c index 8d9ead4b3..826c67265 100644 --- a/src/code_8044CC8.c +++ b/src/code_8044CC8.c @@ -41,7 +41,7 @@ bool8 sub_80461C8(DungeonPos *, u32); Item * sub_8044CC8(Entity *param_1, unkStruct_8044CC8 *param_2) { - Tile *tile; + const Tile *tile; Item *item; EntityInfo *info; @@ -282,4 +282,4 @@ void sub_8045064(void) } } } -} \ No newline at end of file +} diff --git a/src/code_80450F8.c b/src/code_80450F8.c index 526a34b5a..38f2308b9 100644 --- a/src/code_80450F8.c +++ b/src/code_80450F8.c @@ -554,7 +554,7 @@ Entity *sub_8045708(DungeonPos *pos) Entity *ent; if (gDungeonWaterType[gDungeon->tileset] == DUNGEON_WATER_TYPE_LAVA - && (GetTileSafe(pos->x, pos->y)->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY)) == TERRAIN_TYPE_SECONDARY) { + && (GetTileMut(pos->x, pos->y)->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY)) == TERRAIN_TYPE_SECONDARY) { return NULL; } diff --git a/src/code_8045A00.c b/src/code_8045A00.c index fd8662e4b..28f217f54 100644 --- a/src/code_8045A00.c +++ b/src/code_8045A00.c @@ -131,7 +131,7 @@ void sub_8045CB0(void) u32 x; int y; int yCounter; - struct Tile *tile; + const Tile *tile; u32 uVar5; int xCounter; Item item; diff --git a/src/code_804AFAC.c b/src/code_804AFAC.c index 5f2549bc0..f46979a1e 100644 --- a/src/code_804AFAC.c +++ b/src/code_804AFAC.c @@ -13,7 +13,7 @@ void sub_804FBE8(void) { for(y = 0; y < DUNGEON_MAX_SIZE_Y; y++) { - tile = GetTileSafe(x,y); + tile = GetTileMut(x,y); if ((tile->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY)) != TERRAIN_TYPE_NORMAL) { if ((tile->terrainType & (TERRAIN_TYPE_UNK_8 | TERRAIN_TYPE_IMPASSABLE_WALL)) != 0) { tile->unk4 &= 0xfffd; @@ -42,7 +42,7 @@ void sub_804FC74(void) for(y = 0; y < DUNGEON_MAX_SIZE_Y; y++) { if ((GetTile(x, y)->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY)) == TERRAIN_TYPE_SECONDARY) { - tile = GetTileSafe(x,y); + tile = GetTileMut(x,y); tile->terrainType &= ~(TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY); tile->terrainType |= (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY); } @@ -61,7 +61,7 @@ void sub_804FCCC(void) for(y = 0; y < DUNGEON_MAX_SIZE_Y; y++) { if ((GetTile(x, y)->terrainType & TERRAIN_TYPE_IMPASSABLE_WALL) != 0) { - tile = GetTileSafe(x,y); + tile = GetTileMut(x,y); tile->terrainType &= ~(TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY); } } @@ -100,7 +100,7 @@ void sub_804FD30(void) { for(y = 0; y < DUNGEON_MAX_SIZE_Y; y++) { - sub_804FD10(GetTileSafe(x,y)); + sub_804FD10(GetTileMut(x,y)); if ((boundsCheck(x, y - 1)) || (boundsCheck(x + 1, y - 1)) || @@ -111,7 +111,7 @@ void sub_804FD30(void) (boundsCheck(x - 1, y)) || (boundsCheck(x - 1, y - 1))) { - GetTileSafe(x,y)->terrainType |= TERRAIN_TYPE_IMPASSABLE_WALL; + GetTileMut(x,y)->terrainType |= TERRAIN_TYPE_IMPASSABLE_WALL; } } } diff --git a/src/code_805D8C8_1.c b/src/code_805D8C8_1.c index 6e13f4d04..e8cfceb52 100644 --- a/src/code_805D8C8_1.c +++ b/src/code_805D8C8_1.c @@ -1347,7 +1347,7 @@ NAKED static void TryCreateModeArrows(Entity *leader) void sub_805E738(Entity *a0) { - Tile *tile; + const Tile *tile; s32 i, j; EntityInfo *entityInfo = GetEntInfo(a0); if (entityInfo->blinkerClassStatus.status != 1 && entityInfo->blinkerClassStatus.status != 2) { @@ -1401,7 +1401,7 @@ bool8 sub_805E874(void) s32 direction = GetEntInfo(leader)->action.direction; s32 x = leader->pos.x; s32 y = leader->pos.y; - Tile *leaderTile = GetTile(x, y); + const Tile *leaderTile = GetTile(x, y); s32 xAdjacent = x + gAdjacentTileOffsets[direction].x; s32 yAdjacent = y + gAdjacentTileOffsets[direction].y; s32 room; @@ -1426,7 +1426,7 @@ bool8 sub_805E874(void) } for (j = -1; j < 2; j++) { - Tile *tile = GetTile(x + gAdjacentTileOffsets[(direction + j) & 7].x, y + gAdjacentTileOffsets[(direction + j) & 7].y); + const Tile *tile = GetTile(x + gAdjacentTileOffsets[(direction + j) & 7].x, y + gAdjacentTileOffsets[(direction + j) & 7].y); if (tile->monster != NULL) return FALSE; if (tile->terrainType & TERRAIN_TYPE_STAIRS) @@ -1443,7 +1443,7 @@ bool8 sub_805E874(void) for (i = -1; i < 2; i++) { for (j = -1; j < 2; j++) { - Tile *tile = GetTile(x + i, y + j); + const Tile *tile = GetTile(x + i, y + j); if (tile->object != NULL) { for (k = 0; k < 3; k++) { if (x + i == xArray[k] && y + j == yArray[k]) @@ -1528,7 +1528,7 @@ bool8 sub_805EC2C(Entity *a0, s32 x, s32 y) bool8 sub_805EC4C(Entity *a0, u8 a1) { DungeonPos pos; - Tile *tile; + const Tile *tile; EntityInfo *tileMonsterInfo; Entity *tileMonster; EntityInfo *entityInfo = GetEntInfo(a0); @@ -2054,7 +2054,7 @@ void ShowFieldMenu(u8 a0_, bool8 a1) } else if (var_28 == 4) { Entity *leader = GetLeader(); - Tile *tile = GetTile(leader->pos.x, leader->pos.y); + const Tile *tile = GetTile(leader->pos.x, leader->pos.y); Entity *tileObject = tile->object; if (tileObject != NULL) { if (GetEntityType(tileObject) == ENTITY_ITEM) { @@ -2757,7 +2757,7 @@ static void CreateFieldItemMenu(s32 a0, Entity *a1, bool8 a2, bool8 a3, UnkTextS } break; case 2: { - Tile *tile = GetTile(a1->pos.x, a1->pos.y); + const Tile *tile = GetTile(a1->pos.x, a1->pos.y); Item *item = GetItemData(tile->object); PrintFormattedStringOnWindow(x, 0, gFieldItemMenuGroundTextPtr, 0, 0); if (item->flags & ITEM_FLAG_EXISTS) { diff --git a/src/code_8066D04.c b/src/code_8066D04.c index 5beb3e648..80adc5407 100644 --- a/src/code_8066D04.c +++ b/src/code_8066D04.c @@ -282,7 +282,7 @@ void HandleUseItemAction(Entity *param_1) void HandlePlaceItemAction(Entity *param_1) { Item *item; - Tile *tile; + const Tile *tile; EntityInfo *info; #ifndef NONMATCHING register Entity *entity asm("r4"); diff --git a/src/code_806CD90.c b/src/code_806CD90.c index e16c9d267..4bfc23693 100644 --- a/src/code_806CD90.c +++ b/src/code_806CD90.c @@ -237,7 +237,7 @@ void sub_806CF60(void) u32 sub_806CF98(Entity *entity) { - struct Tile *mapTile; + const Tile *mapTile; u32 shadowSize; u16 terrainType; EntityInfo *entityInfo; diff --git a/src/code_80718D8.c b/src/code_80718D8.c index aed02349e..0b5b4c9f8 100644 --- a/src/code_80718D8.c +++ b/src/code_80718D8.c @@ -70,7 +70,7 @@ void GetPokemonLevelData(LevelData* a1, s32 _id, s32 level); // TODO: change to void sub_8071B48(void) { - struct Tile *tile; + const Tile *tile; struct Entity *entity2; struct Entity *entity; int index; diff --git a/src/code_8072B78.c b/src/code_8072B78.c index 7a96283c3..cee32ad69 100644 --- a/src/code_8072B78.c +++ b/src/code_8072B78.c @@ -100,7 +100,7 @@ static inline void fu(EntityInfo *entityInfo, s16 id) void sub_8072B78(Entity *pokemon, Entity *target, s16 id) { OpenedFile *file; - Tile *tile; + const Tile *tile; int index; s32 id_s32; EntityInfo *entityInfo; diff --git a/src/code_8075708.c b/src/code_8075708.c index c89b02c49..5eeefe47b 100644 --- a/src/code_8075708.c +++ b/src/code_8075708.c @@ -56,7 +56,7 @@ void sub_8075708(Entity *entity) { bool8 bVar1; bool8 bVar2; - Tile *tile; + const Tile *tile; Trap *trapData; Entity *trap; EntityInfo *info; @@ -121,7 +121,7 @@ void sub_8075708(Entity *entity) u32 sub_8075818(Entity *entity) { - struct Tile *tile; + const Tile *tile; EntityInfo *entityInfo; Entity *subEntity; Item *item; diff --git a/src/code_807CD9C.c b/src/code_807CD9C.c index 68b97d534..81986f847 100644 --- a/src/code_807CD9C.c +++ b/src/code_807CD9C.c @@ -53,7 +53,7 @@ u8 sub_8083660(DungeonPos *); void sub_807CD9C(Entity *pokemon, Entity *target, u32 direction) { - Tile *tile; + const Tile *tile; int iVar8; bool8 flag; DungeonPos sp_0x18; @@ -370,7 +370,7 @@ void sub_807D3CC(Entity *param_1) bool8 ExposeTrap(s32 x,s32 y) { - Tile *tile; + const Tile *tile; Entity *trap; tile = GetTile(x,y); diff --git a/src/dungeon_ai_attack.c b/src/dungeon_ai_attack.c index 1d22cc2ba..2ed23d4f9 100644 --- a/src/dungeon_ai_attack.c +++ b/src/dungeon_ai_attack.c @@ -399,7 +399,7 @@ s32 AIConsiderMove(struct AIPossibleMove *aiPossibleMove, Entity *pokemon, Move { // Double assignment to fix a regswap. s16 rangeTargetingFlags = rangeTargetingFlags2 = targetingFlags & 0xF0; - struct Tile *adjacentTile = GetTile(pokemon->pos.x + gAdjacentTileOffsets[i].x, + const Tile *adjacentTile = GetTile(pokemon->pos.x + gAdjacentTileOffsets[i].x, pokemon->pos.y + gAdjacentTileOffsets[i].y); Entity *adjacentPokemon = adjacentTile->monster; if (adjacentPokemon != NULL && GetEntityType(adjacentPokemon) == ENTITY_MONSTER) @@ -433,7 +433,7 @@ s32 AIConsiderMove(struct AIPossibleMove *aiPossibleMove, Entity *pokemon, Move { for (i = 0; i < NUM_DIRECTIONS; i++) { - struct Tile *targetTile = GetTile(pokemon->pos.x + gAdjacentTileOffsets[i].x, + const Tile *targetTile = GetTile(pokemon->pos.x + gAdjacentTileOffsets[i].x, pokemon->pos.y + gAdjacentTileOffsets[i].y); if (CanAttackInDirection(pokemon, i)) { @@ -917,7 +917,7 @@ bool8 IsTargetInRange(Entity *pokemon, Entity *targetPokemon, s32 direction, s32 s32 i; for (i = 0; i <= effectiveMaxRange; i++) { - struct Tile *mapTile; + const Tile *mapTile; currentPosX += adjacentTileOffsetX; currentPosY += adjacentTileOffsetY; if (currentPosX <= 0 || currentPosY <= 0 || diff --git a/src/dungeon_ai_item_weight.c b/src/dungeon_ai_item_weight.c index 5ee42ce9f..c6b036c7b 100644 --- a/src/dungeon_ai_item_weight.c +++ b/src/dungeon_ai_item_weight.c @@ -448,7 +448,7 @@ bool8 IsAdjacentToEnemy(Entity *pokemon) s32 direction; for (direction = 0; direction < NUM_DIRECTIONS; direction++) { - struct Tile *mapTile = GetTile(pokemon->pos.x + gAdjacentTileOffsets[direction].x, pokemon->pos.y + gAdjacentTileOffsets[direction].y); + const Tile *mapTile = GetTile(pokemon->pos.x + gAdjacentTileOffsets[direction].x, pokemon->pos.y + gAdjacentTileOffsets[direction].y); Entity *adjacentPokemon = mapTile->monster; if (adjacentPokemon != NULL && GetEntityType(adjacentPokemon) != ENTITY_NOTHING && GetTreatmentBetweenMonsters(pokemon, adjacentPokemon, FALSE, TRUE) == TREATMENT_TREAT_AS_ENEMY) diff --git a/src/dungeon_ai_items.c b/src/dungeon_ai_items.c index 09a5934f7..6f1685096 100644 --- a/src/dungeon_ai_items.c +++ b/src/dungeon_ai_items.c @@ -156,7 +156,7 @@ void AIDecideUseItem(Entity *pokemon) else if (toolboxIndex == 0) { // This seems unused. toolboxIndex can never be 0. - struct Tile *mapTile = GetTile(pokemon->pos.x, pokemon->pos.y); + const Tile *mapTile = GetTile(pokemon->pos.x, pokemon->pos.y); Entity *object = mapTile->object; if (object != null) { diff --git a/src/dungeon_ai_movement.c b/src/dungeon_ai_movement.c index e6e435246..64f095c17 100644 --- a/src/dungeon_ai_movement.c +++ b/src/dungeon_ai_movement.c @@ -104,7 +104,7 @@ void AIMovement(Entity *pokemon, bool8 showRunAwayEffect) bool8 CanTakeItem(Entity *pokemon) { EntityInfo *pokemonInfo = GetEntInfo(pokemon); - struct Tile *mapTile; + const Tile *mapTile; Entity *object; if (!EntityExists(pokemon) || CheckVariousConditions(pokemon)) { @@ -310,7 +310,7 @@ bool8 ChooseTargetPosition(Entity *pokemon) { for (x = minX; x <= maxX; x++) { - Entity *object = GetTileSafe(x, y)->object; + Entity *object = GetTileMut(x, y)->object; if (object && GetEntityType(object) == ENTITY_ITEM) { pokemonInfo->aiTarget.aiObjective = AI_TAKE_ITEM; @@ -553,7 +553,7 @@ bool8 AvoidEnemies(Entity *pokemon) { if (room == closestTargetRoom && room != CORRIDOR_ROOM) { - struct Tile *tile = GetTile(pokemon->pos.x, pokemon->pos.y); + const Tile *tile = GetTile(pokemon->pos.x, pokemon->pos.y); if (tile->terrainType & TERRAIN_TYPE_NATURAL_JUNCTION) { DungeonPos aiTargetPos; @@ -563,7 +563,7 @@ bool8 AvoidEnemies(Entity *pokemon) // Scan for a direction leading outside the room. for (targetDir = 0; targetDir < NUM_DIRECTIONS; targetDir++) { - struct Tile *adjacentTile; + const Tile *adjacentTile; aiTargetPos.x = pokemon->pos.x + gAdjacentTileOffsets[targetDir].x; aiTargetPos.y = pokemon->pos.y + gAdjacentTileOffsets[targetDir].y; adjacentTile = GetTile(aiTargetPos.x, aiTargetPos.y); diff --git a/src/dungeon_ai_targeting.c b/src/dungeon_ai_targeting.c index 1088795b3..760dda6e9 100644 --- a/src/dungeon_ai_targeting.c +++ b/src/dungeon_ai_targeting.c @@ -65,7 +65,7 @@ const u8 gTreatmentData[3][2][2][2] = { bool8 sub_8070F3C(Entity * pokemon, DungeonPos *pos, s32 direction) { u8 terrain; - struct Tile *tile; + const Tile *tile; terrain = GetCrossableTerrain(GetEntInfo(pokemon)->id); @@ -109,7 +109,7 @@ bool8 sub_8070F3C(Entity * pokemon, DungeonPos *pos, s32 direction) bool8 sub_8070F14(Entity * pokemon, s32 direction) { - struct Tile *tile; + const Tile *tile; tile = GetTile(pokemon->pos.x + gAdjacentTileOffsets[direction].x, pokemon->pos.y + gAdjacentTileOffsets[direction].y); @@ -128,7 +128,7 @@ bool8 sub_8070F14(Entity * pokemon, s32 direction) bool8 sub_8070F80(Entity * pokemon, s32 direction) { u8 terrain; - struct Tile *tile; + const Tile *tile; terrain = GetCrossableTerrain(GetEntInfo(pokemon)->id); @@ -173,7 +173,7 @@ bool8 sub_8070F80(Entity * pokemon, s32 direction) bool8 sub_8071058(Entity * pokemon, s32 direction) { u8 terrain; - struct Tile *tile; + const Tile *tile; terrain = GetCrossableTerrain(GetEntInfo(pokemon)->id); @@ -218,7 +218,7 @@ bool8 sub_8071058(Entity * pokemon, s32 direction) bool8 CanAttackInDirection(Entity *pokemon, s32 direction) { u8 crossableTerrain = GetCrossableTerrain(GetEntInfo(pokemon)->id); - struct Tile *tile; + const Tile *tile; if (crossableTerrain < CROSSABLE_TERRAIN_CREVICE) { crossableTerrain = CROSSABLE_TERRAIN_CREVICE; @@ -265,7 +265,8 @@ bool8 CanAttackInDirection(Entity *pokemon, s32 direction) bool8 CanAIMonsterMoveInDirection(Entity *pokemon, s32 direction, bool8 *pokemonInFront) { u8 crossableTerrain = GetCrossableTerrain(GetEntInfo(pokemon)->id); - struct Tile *frontTile, *currentTile; + const Tile *currentTile; + const Tile *frontTile; *pokemonInFront = FALSE; frontTile = GetTile(pokemon->pos.x + gAdjacentTileOffsets[direction].x, pokemon->pos.y + gAdjacentTileOffsets[direction].y); @@ -365,7 +366,7 @@ bool8 IsAtJunction(Entity *pokemon) } else { - struct Tile *mapTile; + const Tile *mapTile; char walkableNeighborFlags; if (gDungeonWaterType[gDungeon->tileset] == DUNGEON_WATER_TYPE_LAVA && crossableTerrain == CROSSABLE_TERRAIN_LIQUID diff --git a/src/dungeon_capabilities.c b/src/dungeon_capabilities.c index 94985585a..4c9dcc716 100644 --- a/src/dungeon_capabilities.c +++ b/src/dungeon_capabilities.c @@ -132,7 +132,7 @@ bool8 CannotAttack(Entity *pokemon, bool8 skipSleep) bool8 CanMoveInDirection(Entity *pokemon, u32 direction) { u8 crossableTerrain = GetCrossableTerrain(GetEntInfo(pokemon)->id); - struct Tile *currentMapTile = GetTile(pokemon->pos.x + gAdjacentTileOffsets[direction].x, + const Tile *currentMapTile = GetTile(pokemon->pos.x + gAdjacentTileOffsets[direction].x, pokemon->pos.y + gAdjacentTileOffsets[direction].y); if (currentMapTile->terrainType & TERRAIN_TYPE_IMPASSABLE_WALL || currentMapTile->monster != NULL) diff --git a/src/dungeon_cutscenes.c b/src/dungeon_cutscenes.c index 0a08d442f..597bf11f6 100644 --- a/src/dungeon_cutscenes.c +++ b/src/dungeon_cutscenes.c @@ -3828,7 +3828,7 @@ void sub_808B1CC(u8 itemID) pos.y = entity->pos.y; } sub_807FE04(&pos, 0); - tile = GetTileSafe(pos.x, pos.y); + tile = GetTileMut(pos.x, pos.y); tile->terrainType = tile->terrainType | TERRAIN_TYPE_STAIRS; if (((itemID != ITEM_NOTHING) && (sub_80860A8(itemID) == 0)) && (sub_80860A8(ITEM_MUSIC_BOX) == 0)) { @@ -4060,7 +4060,7 @@ void JirachiWish(void) } pos1.x = (jirachiEntity->pos.x + DungeonRandInt(3) - 1); pos1.y = (jirachiEntity->pos.y + DungeonRandInt(3) + -1); - if ((GetTileSafe(pos1.x, pos1.y)->terrainType & 3) != 0) { + if ((GetTileMut(pos1.x, pos1.y)->terrainType & 3) != 0) { PlaySoundEffect(0x14c); sub_808BB3C(&pos1); sub_8046860(jirachiEntity,&pos1,auStack152,9); @@ -4086,7 +4086,7 @@ void JirachiWish(void) pos2.x = (jirachiEntity->pos.x + DungeonRandInt(3) - 1); pos2.y = (jirachiEntity->pos.y + DungeonRandInt(3) + -1); - if ((GetTileSafe(pos2.x, pos2.y)->terrainType & 3) != 0) { + if ((GetTileMut(pos2.x, pos2.y)->terrainType & 3) != 0) { PlaySoundEffect(400); sub_808BB3C(&pos2); sub_8046860(jirachiEntity,&pos2,itemStack,9); @@ -4140,7 +4140,7 @@ void JirachiWish(void) pos3.x = (jirachiEntity->pos.x + DungeonRandInt(3) - 1); pos3.y = (jirachiEntity->pos.y + DungeonRandInt(3) + -1); - if ((GetTileSafe(pos3.x, pos3.y)->terrainType & 3) != 0) { + if ((GetTileMut(pos3.x, pos3.y)->terrainType & 3) != 0) { PlaySoundEffect(400); sub_808BB3C(&pos3); sub_8046860(jirachiEntity,&pos3,strengthItems,4); @@ -4303,9 +4303,9 @@ void JirachiWishGrantDialogue(Entity *jirachiEntity) // Warp Tile is created but not enabled until the Wish is done with EnableJirachiWishWarpTile void CreateJirachiWishWarpTile(void) { - struct Tile *tile; + Tile *tile; - tile = GetTileSafe(gDungeon->unkE220[7].x, gDungeon->unkE220[7].y); + tile = GetTileMut(gDungeon->unkE220[7].x, gDungeon->unkE220[7].y); tile->terrainType &= ~(TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY); tile->terrainType |= TERRAIN_TYPE_IMPASSABLE_WALL; tile->terrainType &= ~TERRAIN_TYPE_STAIRS; @@ -4317,9 +4317,9 @@ void CreateJirachiWishWarpTile(void) void EnableJirachiWishWarpTile(void) { - struct Tile *tile; + Tile *tile; - tile = GetTileSafe(gDungeon->unkE220[7].x, gDungeon->unkE220[7].y); + tile = GetTileMut(gDungeon->unkE220[7].x, gDungeon->unkE220[7].y); tile->terrainType &= ~(TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY); tile->terrainType |= TERRAIN_TYPE_NORMAL; tile->terrainType &= ~TERRAIN_TYPE_IMPASSABLE_WALL; diff --git a/src/dungeon_map_access.c b/src/dungeon_map_access.c index 98561554d..37a903e8c 100644 --- a/src/dungeon_map_access.c +++ b/src/dungeon_map_access.c @@ -16,8 +16,8 @@ #include "game_options.h" #include "dungeon_visibility.h" -extern unkStruct_202F190 gUnknown_80F69D4; -extern unkStruct_202F190 gUnknown_80F69EC; +extern const unkStruct_202F190 gUnknown_80F69D4; +extern const unkStruct_202F190 gUnknown_80F69EC; extern u8 gUnknown_80F6A04[]; extern u8 gUnknown_80F6A10[]; extern u8 gUnknown_80F6A28[]; @@ -32,9 +32,9 @@ extern const s16 gUnknown_80F6C06[]; EWRAM_DATA OpenedFile *gDungeonPaletteFile = {0}; EWRAM_DATA unkStruct_202EE8C gUnknown_202EE8C[32] = {0}; EWRAM_DATA OpenedFile *gUnknown_202F18C = {0}; -EWRAM_DATA unkStruct_202F190 gUnknown_202F190 = {0}; +EWRAM_DATA unkStruct_202F190 gOutOfBoundsTileData = {0}; -EWRAM_DATA_2 unkStruct_202F190 *gUnknown_203B430 = {0}; +EWRAM_DATA_2 const unkStruct_202F190 *gUnknown_203B430 = {0}; extern u8 sub_8043CE4(u32); extern void sub_80402AC(s32, s32); @@ -42,7 +42,7 @@ extern int sprintf(char *, const char *, ...); void sub_8049BB0(s32, s32); void sub_80498A8(s32, s32); -Tile *GetTile(s32 x, s32 y) +const Tile *GetTile(s32 x, s32 y) { if (x >= 0 && y >= 0 && x < DUNGEON_MAX_SIZE_X && y < DUNGEON_MAX_SIZE_Y) { @@ -51,12 +51,12 @@ Tile *GetTile(s32 x, s32 y) return (Tile *) gUnknown_203B430->unk0; } -Tile *GetTileSafe(s32 x, s32 y) +Tile *GetTileMut(s32 x, s32 y) { if (x < 0 || y < 0 || x >= DUNGEON_MAX_SIZE_X || y >= DUNGEON_MAX_SIZE_Y) { - Tile *tile = (Tile *) gUnknown_202F190.unk0; - gUnknown_202F190 = *gUnknown_203B430; + Tile *tile = (Tile *) gOutOfBoundsTileData.unk0; + gOutOfBoundsTileData = *gUnknown_203B430; return tile; } return gDungeon->tilePointers[y][x]; @@ -190,10 +190,10 @@ void sub_80498A8(int x,int y) sp_0x20 = GetTile(x, y)->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY); if (gDungeon->tileset >= 0x40) { if ((0x17 >= x) && (0x17 >= y)) { - GetTileSafe(x,y)->unk8 = gDungeon->unk12C24[y * 0x18 + x]; + GetTileMut(x,y)->unk8 = gDungeon->unk12C24[y * 0x18 + x]; } else { - GetTileSafe(x,y)->unk8 = 0; + GetTileMut(x,y)->unk8 = 0; } } else @@ -325,7 +325,7 @@ void sub_80498A8(int x,int y) if (IsBossFight()) { r4 = 0; } - GetTileSafe(x,y)->unk8 = gDungeon->unk12C24[r4 + r7 * 3]; + GetTileMut(x,y)->unk8 = gDungeon->unk12C24[r4 + r7 * 3]; } } @@ -436,17 +436,17 @@ void sub_8049BB0(s32 x, s32 y) if (y > 29) flags[CROSSABLE_TERRAIN_WALL] &= ~(0x80 | 0x1 | 0x2); - GetTileSafe(x, y)->walkableNeighborFlags[CROSSABLE_TERRAIN_REGULAR] = flags[CROSSABLE_TERRAIN_REGULAR]; - GetTileSafe(x, y)->walkableNeighborFlags[CROSSABLE_TERRAIN_LIQUID] = flags[CROSSABLE_TERRAIN_LIQUID]; - GetTileSafe(x, y)->walkableNeighborFlags[CROSSABLE_TERRAIN_CREVICE] = flags[CROSSABLE_TERRAIN_CREVICE]; - GetTileSafe(x, y)->walkableNeighborFlags[CROSSABLE_TERRAIN_WALL] = flags[CROSSABLE_TERRAIN_WALL]; + GetTileMut(x, y)->walkableNeighborFlags[CROSSABLE_TERRAIN_REGULAR] = flags[CROSSABLE_TERRAIN_REGULAR]; + GetTileMut(x, y)->walkableNeighborFlags[CROSSABLE_TERRAIN_LIQUID] = flags[CROSSABLE_TERRAIN_LIQUID]; + GetTileMut(x, y)->walkableNeighborFlags[CROSSABLE_TERRAIN_CREVICE] = flags[CROSSABLE_TERRAIN_CREVICE]; + GetTileMut(x, y)->walkableNeighborFlags[CROSSABLE_TERRAIN_WALL] = flags[CROSSABLE_TERRAIN_WALL]; } void sub_8049ED4(void) { bool32 hallucinating, unk1820F; u16 *src; - Tile *tile; + const Tile *tile; s32 r7; s32 i; s32 r10; @@ -562,7 +562,7 @@ void sub_8049ED4(void) void sub_804A1F0(s32 a0, s32 a1) { - Tile *tile; + const Tile *tile; u16 *src; bool32 hallucinating, unk1820F; s32 xTemp, yTemp; @@ -664,7 +664,7 @@ void sub_804A1F0(s32 a0, s32 a1) void sub_804A49C(s32 a0, s32 a1) { - Tile *tile; + const Tile *tile; u16 *src; bool32 hallucinating, unk1820F; s32 xTemp, yTemp; @@ -906,12 +906,12 @@ void sub_804AAAC(void) { s32 x; s32 y; - struct Tile *tile; + Tile *tile; for(y = 0; y < DUNGEON_MAX_SIZE_Y; y++) { for(x = 0; x < DUNGEON_MAX_SIZE_X; x++) { - tile = GetTileSafe(x,y); + tile = GetTileMut(x,y); tile->unk4 = 0; } } @@ -919,7 +919,7 @@ void sub_804AAAC(void) void sub_804AAD4(void) { - struct Tile *tile; + const Tile *tile; struct RoomData *room1; struct RoomData *room2; s32 roomIndex; @@ -986,8 +986,8 @@ void sub_804AAD4(void) void sub_804AC20(DungeonPos *pos) { s32 y; - struct Tile *tile2; - struct Tile *tile; + const Tile *tile2; + Tile *tile; s32 yMax; u32 visibilityRange; s32 xMin; @@ -1023,7 +1023,7 @@ void sub_804AC20(DungeonPos *pos) } for (y = yMin; y <= yMax; y++) { for (x = xMin; x <= xMax; x++) { - tile = GetTileSafe(x,y); + tile = GetTileMut(x,y); tile->unk4 = tile->unk4 | 3; sub_80402AC(x,y); } diff --git a/src/dungeon_move.c b/src/dungeon_move.c index d474afabd..6c0898b1a 100644 --- a/src/dungeon_move.c +++ b/src/dungeon_move.c @@ -2577,7 +2577,7 @@ void sub_80566F8(Entity *attacker, Move *move, s32 a2, bool8 a3, s32 itemId, s32 var_48 = gAdjacentTileOffsets[attackerInfo->action.direction].y; for (i = 0; i < a2; i++) { - Tile *tile; + const Tile *tile; if (var_68.x < 0 || var_68.y < 0 || var_68.x > 55 || var_68.y > 31) break; @@ -2622,7 +2622,7 @@ void sub_80566F8(Entity *attacker, Move *move, s32 a2, bool8 a3, s32 itemId, s32 for (i = 0; i < a2; i++) { DungeonPos var_68Before; - Tile *tile; + const Tile *tile; if (var_68.x < 0 || var_68.y < 0 || var_68.x > 55 || var_68.y > 31) break; diff --git a/src/dungeon_movement.c b/src/dungeon_movement.c index 70442bfbe..bd072f1d6 100644 --- a/src/dungeon_movement.c +++ b/src/dungeon_movement.c @@ -38,7 +38,7 @@ u8 GetCrossableTerrain(s16 species) } } -u8 sub_807034C(s16 id, struct Tile *tile) +u8 sub_807034C(s16 id, const Tile *tile) { s32 crossableTerrain; u16 tileFlags; @@ -68,7 +68,7 @@ u8 sub_807034C(s16 id, struct Tile *tile) u8 sub_80703A0(Entity *pokemon, DungeonPos *pos) { - struct Tile *tile; + const Tile *tile; u8 crossableTerrain; u16 tileFlags; EntityInfo *entityInfo; @@ -131,7 +131,7 @@ bool8 CanCrossWalls(Entity *pokemon) bool8 sub_807049C(Entity *pokemon, DungeonPos *pos) { s32 crossableTerrain; - struct Tile *tile; + const Tile *tile; u16 tileFlags; EntityInfo *entityInfo; @@ -173,7 +173,7 @@ bool8 sub_807049C(Entity *pokemon, DungeonPos *pos) bool8 sub_8070564(Entity *pokemon, DungeonPos *pos) { u8 crossableTerrain; - struct Tile *tile; + const Tile *tile; u16 tileFlags; EntityInfo *entityInfo; #ifndef NONMATCHING @@ -219,7 +219,7 @@ bool8 sub_8070564(Entity *pokemon, DungeonPos *pos) bool8 sub_80705F0(Entity *pokemon, DungeonPos *pos) { s32 crossableTerrain; - struct Tile *tile; + const Tile *tile; u16 tileFlags; EntityInfo *entityInfo; @@ -259,7 +259,7 @@ bool8 sub_80705F0(Entity *pokemon, DungeonPos *pos) bool8 sub_80706A4(Entity *pokemon, DungeonPos *pos) { s32 crossableTerrain; - struct Tile *tile; + const Tile *tile; u16 tileFlags; EntityInfo *entityInfo; diff --git a/src/dungeon_range.c b/src/dungeon_range.c index f06338f4a..1c933b0b3 100644 --- a/src/dungeon_range.c +++ b/src/dungeon_range.c @@ -9,7 +9,7 @@ bool8 IsPositionActuallyInSight(DungeonPos *pos1, DungeonPos *pos2) { u8 pos1Room; u8 visibility = gDungeon->unk181e8.visibilityRange; - struct Tile *tile1; + const Tile *tile1; if (visibility == 0) { visibility = 2; @@ -49,7 +49,7 @@ bool8 IsPositionActuallyInSight(DungeonPos *pos1, DungeonPos *pos2) bool8 IsPositionInSight(DungeonPos *pos1, DungeonPos *pos2) { - struct Tile *tile; + const Tile *tile; u8 pos1Room; s32 xDiff; s32 yDiff; @@ -99,7 +99,7 @@ returnFalse: void sub_80833E8(DungeonPos *param_1, s32 *param_2) { - struct Tile *tile; + const Tile *tile; struct RoomData *mapRoom; u32 visibility; u32 room; @@ -128,7 +128,7 @@ void sub_80833E8(DungeonPos *param_1, s32 *param_2) bool8 IsTargetTwoTilesAway(DungeonPos *pos1, DungeonPos *pos2) { s32 i; - struct Tile *tile; + const Tile *tile; s32 diff; s32 x1; s32 y1; diff --git a/src/dungeon_serializer.c b/src/dungeon_serializer.c index 2e290f492..e3f42f5f6 100644 --- a/src/dungeon_serializer.c +++ b/src/dungeon_serializer.c @@ -910,7 +910,7 @@ static void ReadDungeonTraps(DataSerializer *seri) ReadTilePos(seri, &pos); if (trapID != 0xFF) { - tile = GetTileSafe(pos.x, pos.y); + tile = GetTileMut(pos.x, pos.y); entity = sub_8045684(trapID, &pos, unk1); if (entity) { tile->object = entity; @@ -1090,7 +1090,7 @@ static void ReadMonster(DataSerializer *seri, bool8 isTeamMember, s32 index) if (mon != NULL) { monEntInfo = GetEntInfo(mon); - tile = GetTileSafe(monPos.x, monPos.y); + tile = GetTileMut(monPos.x, monPos.y); mon->prevPos = monPos; mon->pos = monPos; tile->monster = mon; @@ -1255,7 +1255,7 @@ void sub_8082B40(void) sub_806CCB4(entity, sub_806CEBC(entity)); pos = entity->pos; AddPokemonDungeonSprite(info->unk98, info->apparentID, &pos, 3); - entity->room = GetTileSafe(entity->pos.x, entity->pos.y)->room; + entity->room = GetTileMut(entity->pos.x, entity->pos.y)->room; } } } diff --git a/src/dungeon_util.c b/src/dungeon_util.c index 096b35346..b414cc1ac 100644 --- a/src/dungeon_util.c +++ b/src/dungeon_util.c @@ -65,14 +65,14 @@ Item* GetItemData_1(Entity *entity) return entity->axObj.info.item; } -Tile *GetTileAtEntity(Entity *entity) +const Tile *GetTileAtEntity(Entity *entity) { return GetTile(entity->pos.x, entity->pos.y); } Tile *GetTileAtEntitySafe(Entity *entity) { - return GetTileSafe(entity->pos.x, entity->pos.y); + return GetTileMut(entity->pos.x, entity->pos.y); } void sub_804513C(void) diff --git a/src/move_actions.c b/src/move_actions.c index 3226a0a5e..8543a2eb9 100644 --- a/src/move_actions.c +++ b/src/move_actions.c @@ -333,7 +333,7 @@ bool8 VitalThrowMoveAction(Entity * pokemon, Entity * target, Move *move, s32 pa bool8 DigMoveAction(Entity * pokemon, Entity * target, Move *move, s32 param_4) { - struct Tile *tile; + Tile *tile; bool8 flag; flag = FALSE; @@ -2661,7 +2661,7 @@ bool8 sub_805A85C(Entity * pokemon, Entity * target, Move *move, u32 param_4) DungeonPos pos1; Move stackMove; PixelPos pos2; - struct Tile *tile; + Tile *tile; Entity *entity; s32 temp; s32 temp2; @@ -2704,7 +2704,7 @@ _0805A8C2: sub_803E46C(0x2c); } } - tile = GetTileSafe(pos1.x,pos1.y); + tile = GetTileMut(pos1.x,pos1.y); entity = tile->monster; if (entity != NULL) { if (GetEntityType(entity) == ENTITY_MONSTER) { diff --git a/src/move_checks.c b/src/move_checks.c index d955fc4aa..f45de8ee4 100644 --- a/src/move_checks.c +++ b/src/move_checks.c @@ -359,7 +359,7 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) break; case MOVE_DIG: { - struct Tile *tile = GetTileAtEntitySafe(pokemon); + Tile *tile = GetTileAtEntitySafe(pokemon); if (!IsTileGround(tile) || (tile->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY)) != TERRAIN_TYPE_NORMAL) { return FALSE; diff --git a/src/move_effects_target.c b/src/move_effects_target.c index ec2624629..f34bd5771 100644 --- a/src/move_effects_target.c +++ b/src/move_effects_target.c @@ -468,8 +468,8 @@ void BurnedStatusTarget(Entity * pokemon, Entity * target, u8 param_3, bool8 dis bool8 isNotBurned; bool8 hasSynchronized; EntityInfo *entityInfo; - struct Tile *tile_1; - struct Tile *tile_2; + const Tile *tile_1; + const Tile *tile_2; Entity *entity; s32 index; @@ -556,7 +556,7 @@ void PoisonedStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessag bool8 isNotPoisoned; bool8 hasSynchronized; EntityInfo *entityInfo; - struct Tile *tile; + const Tile *tile; Entity *entity; s32 index; @@ -645,7 +645,7 @@ void BadlyPoisonedStatusTarget(Entity * pokemon, Entity * target, bool8 displayM bool8 isNotBadlyPoisoned; bool8 hasSynchronized; EntityInfo *entityInfo; - struct Tile *tile; + const Tile *tile; Entity *entity; s32 index; @@ -725,7 +725,7 @@ void BadlyPoisonedStatusTarget(Entity * pokemon, Entity * target, bool8 displayM void FrozenStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessage) { EntityInfo *entityInfo; - struct Tile *tile; + const Tile *tile; if (!EntityExists(target)) { return; diff --git a/src/status.c b/src/status.c index 4690c7e3d..03d770618 100644 --- a/src/status.c +++ b/src/status.c @@ -433,7 +433,7 @@ void CringeStatusTarget(Entity * pokemon,Entity * target, bool8 displayMessage) void ParalyzeStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessage) { - struct Tile *mapTile; + const Tile *mapTile; EntityInfo *entityInfo; Entity *mapPokemonEntity; int index; diff --git a/src/status_actions.c b/src/status_actions.c index 8df3e799f..82c782218 100644 --- a/src/status_actions.c +++ b/src/status_actions.c @@ -940,7 +940,7 @@ bool8 sub_805BF34(Entity * pokemon, Entity * target, Move *move, s32 param_4) bool8 TrapbustOrbAction(Entity * pokemon,Entity * target, Move *move, s32 param_4) { - struct Tile *tile; + const Tile *tile; Entity *object; Trap *trapData; s32 bottomRightCornerX, bottomRightCornerY; @@ -972,7 +972,7 @@ bool8 TrapbustOrbAction(Entity * pokemon,Entity * target, Move *move, s32 param_ ++topLeftCornerY; --topLeftCornerY; for (xCoord = bottomRightCornerX; xCoord <= topLeftCornerX; xCoord++) { for (yCoord = bottomRightCornerY; yCoord <= topLeftCornerY; yCoord++) { - object = GetTileSafe(xCoord, yCoord)->object; + object = GetTileMut(xCoord, yCoord)->object; if (((object != 0) && (GetEntityType(object) == ENTITY_TRAP)) && (trapData = GetTrapData(object), trapData->id != TRAP_WONDER_TILE)) { pos.y = yCoord; @@ -1094,7 +1094,7 @@ bool8 sub_805C2A0(Entity *pokemon, Entity *target, Move *move, s32 param_4) bool8 FillInOrbAction(Entity *pokemon,Entity *target, Move *move, s32 param_4) { - struct Tile *tileToFill; + Tile *tileToFill; EntityInfo *targetInfo; int y; bool8 filledInTile; @@ -1114,7 +1114,7 @@ bool8 FillInOrbAction(Entity *pokemon,Entity *target, Move *move, s32 param_4) tileCoords.y = target->pos.y + gAdjacentTileOffsets[targetInfo->action.direction].y; sub_8042A54(&tileCoords); - tileToFill = GetTileSafe(tileCoords.x,tileCoords.y); + tileToFill = GetTileMut(tileCoords.x,tileCoords.y); if ((tileToFill->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY)) == TERRAIN_TYPE_SECONDARY) { tileToFill->terrainType = (tileToFill->terrainType & ~(TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY)) | TERRAIN_TYPE_NORMAL; diff --git a/src/tile_types.c b/src/tile_types.c index 440a643ae..f489665f8 100644 --- a/src/tile_types.c +++ b/src/tile_types.c @@ -91,7 +91,7 @@ void sub_8042A14(DungeonPos *); bool8 PosHasItem(DungeonPos *pos) { - struct Tile *tile; + const Tile *tile; Entity *entity; tile = GetTile(pos->x,pos->y); @@ -104,7 +104,7 @@ bool8 PosHasItem(DungeonPos *pos) Entity *GetMonsterAtPos(DungeonPos *pos) { - struct Tile *tile; + const Tile *tile; Entity *entity; tile = GetTile(pos->x,pos->y); @@ -117,7 +117,7 @@ Entity *GetMonsterAtPos(DungeonPos *pos) bool8 sub_804AD34(DungeonPos *pos) { - struct Tile *tile; + Tile *tile; s32 x; Entity * entity; s32 y; @@ -125,7 +125,7 @@ bool8 sub_804AD34(DungeonPos *pos) s32 index; iVar8 = 0; - tile = GetTileSafe(pos->x,pos->y); + tile = GetTileMut(pos->x,pos->y); if (!(tile->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY))) if(!(tile->terrainType & (TERRAIN_TYPE_UNK_8 | TERRAIN_TYPE_IMPASSABLE_WALL))){ iVar8 = 1; @@ -157,13 +157,13 @@ bool8 sub_804AD34(DungeonPos *pos) bool8 sub_804AE08(DungeonPos *pos) { - struct Tile *tile; + Tile *tile; s32 x; s32 y; bool8 uVar6; uVar6 = FALSE; - tile = GetTileSafe(pos->x,pos->y); + tile = GetTileMut(pos->x,pos->y); if (!(tile->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY))) if(!(tile->terrainType & (TERRAIN_TYPE_UNK_8 | TERRAIN_TYPE_IMPASSABLE_WALL))) { @@ -184,13 +184,13 @@ bool8 sub_804AE08(DungeonPos *pos) void sub_804AE84(DungeonPos *pos) { - struct Tile *tile; + Tile *tile; s32 x; Entity * entity; s32 index; s32 y; - tile = GetTileSafe(pos->x,pos->y); + tile = GetTileMut(pos->x,pos->y); if ((tile->unk4 & 0x10) != 0) { tile->unk4 = tile->unk4 & 0xffef; diff --git a/src/trap.c b/src/trap.c index 2d51f8b40..71e798fdb 100644 --- a/src/trap.c +++ b/src/trap.c @@ -100,7 +100,7 @@ void sub_807FC3C(DungeonPos *pos, u32 trapID, u32 param_3) bool8 CanLayTrap(DungeonPos *pos) { - struct Tile *tile = GetTileSafe(pos->x, pos->y); + Tile *tile = GetTileMut(pos->x, pos->y); if (tile->terrainType & TERRAIN_TYPE_STAIRS || tile->room == CORRIDOR_ROOM || tile->terrainType & TERRAIN_TYPE_NATURAL_JUNCTION) @@ -126,7 +126,7 @@ bool8 LayTrap(DungeonPos *pos, u8 trapID, u8 param_3) int counter; u16 terrainType; - tile = GetTileSafe(pos->x, pos->y); + tile = GetTileMut(pos->x, pos->y); if (TRAP_SPIKE_TRAP < trapID) { counter = 0; while ((counter < 0x1e && (trapID = sub_803D6FC(), trapID == TRAP_WONDER_TILE))) { @@ -188,7 +188,7 @@ bool8 sub_807FE04(DungeonPos *pos, char param_2) { Tile *tile; - tile = GetTileSafe(pos->x,pos->y); + tile = GetTileMut(pos->x,pos->y); if ((tile->object != NULL) && (GetEntityType(tile->object) == ENTITY_TRAP)) { tile->object->type = 0; tile->object = NULL; @@ -204,7 +204,7 @@ bool8 sub_807FE04(DungeonPos *pos, char param_2) bool8 sub_807FE44(DungeonPos *pos, char param_2) { - Tile *tile; + const Tile *tile; tile = GetTile(pos->x,pos->y); if ((tile->object != NULL) && (GetEntityType(tile->object) == ENTITY_TRAP)) { @@ -236,7 +236,7 @@ void sub_807FE9C(Entity *pokemon, DungeonPos *pos, int param_3, char param_4) Entity *target; u8 *text; - tile = GetTileSafe(pos->x,pos->y); + tile = GetTileMut(pos->x,pos->y); entity = tile->object; flag1 = FALSE; if (entity == NULL) { diff --git a/tmp/gettile.cocci b/tmp/gettile.cocci new file mode 100644 index 000000000..ce7dc37b0 --- /dev/null +++ b/tmp/gettile.cocci @@ -0,0 +1,42 @@ +@ r1 disable optional_qualifier exists @ +identifier tile; +@@ +- Tile *tile; +++ const Tile *tile; + ... + tile = GetTile(...) +@ r2 disable optional_qualifier exists @ +identifier tile; +@@ +- Tile *tile +++ const Tile *tile + = GetTile(...); +@ decls disable optional_qualifier @ +identifier tile; +@@ +( + Tile *tile; +| + Tile *tile = ...; +) +@ mutated depends on decls exists @ +identifier decls.tile; +assignment operator op; +identifier f; +@@ +( + tile->f op ...; +| + f(<+... tile ...+>) +) +@ notmutated depends on decls && !mutated disable optional_qualifier @ +identifier decls.tile; +@@ +( +- Tile *tile; +++ const Tile *tile; +| +- Tile *tile +++ const Tile *tile + = ...; +) diff --git a/tmp/position.cocci b/tmp/position.cocci deleted file mode 100644 index ff2de880e..000000000 --- a/tmp/position.cocci +++ /dev/null @@ -1,17 +0,0 @@ -@@ -typedef Position; -@@ -- struct Position -+ Position -@@ -typedef Position32; -typedef PixelPos; -@@ -- Position32 -+ PixelPos -@@ -typedef Position; -typedef DungeonPos; -@@ -- Position -+ DungeonPos