1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-01 02:40:43 +02:00

#368 getSector ARM (IWRAM)

This commit is contained in:
XProger
2022-02-12 07:50:28 +03:00
parent b6df8a2348
commit 6a70ec64b2
2 changed files with 46 additions and 1 deletions

View File

@@ -185,7 +185,7 @@ void Sector::getTriggerFloorCeiling(int32 x, int32 y, int32 z, int32* floor, int
} while (!FD_END(cmd));
}
#ifndef USE_ASM
const Sector* Room::getSector(int32 x, int32 z) const
{
// TODO remove clamp?
@@ -194,6 +194,7 @@ const Sector* Room::getSector(int32 x, int32 z) const
return sectors + sx * info->zSectors + sz;
}
#endif
const Sector* Room::getWaterSector(int32 x, int32 z) const
{

View File

@@ -0,0 +1,44 @@
#include "common_asm.inc"
this .req r0
x .req r1
z .req r2
info .req r3
roomX .req r12
roomZ .req roomX
sx .req x
sz .req z
sectors .req this
sectorsX .req roomX
sectorsZ .req roomZ
offset .req sectorsZ
// const Sector* Room::getSector(int32 x, int32 z) const
.global _ZNK4Room9getSectorEii
_ZNK4Room9getSectorEii:
ldr info, [this, #4]
// sx = X_CLAMP((x - (info->x << 8)) >> 10, 0, info->xSectors - 1);
ldrsh roomX, [info]
subs sx, x, roomX, lsl #8
movlt sx, #0
mov sx, sx, lsr #10
ldrb sectorsX, [info, #20]
cmp sx, sectorsX
subge sx, sectorsX, #1
// sz = X_CLAMP((z - (info->z << 8)) >> 10, 0, info->zSectors - 1);
ldrsh roomZ, [info, #2]
subs sz, z, roomZ, lsl #8
movlt sz, #0
mov sz, sz, lsr #10
ldrb sectorsZ, [info, #21]
cmp sz, sectorsZ
subge sz, sectorsZ, #1
// return sectors + sx * info->zSectors + sz;
ldr sectors, [this, #8]
mla offset, sx, sectorsZ, sz
add sectors, offset, lsl #3 // sizeof(Sector) == (1 << 3)
bx lr