mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-06 05:07:48 +02:00
#368 getSector ARM (IWRAM)
This commit is contained in:
@@ -185,7 +185,7 @@ void Sector::getTriggerFloorCeiling(int32 x, int32 y, int32 z, int32* floor, int
|
|||||||
} while (!FD_END(cmd));
|
} while (!FD_END(cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef USE_ASM
|
||||||
const Sector* Room::getSector(int32 x, int32 z) const
|
const Sector* Room::getSector(int32 x, int32 z) const
|
||||||
{
|
{
|
||||||
// TODO remove clamp?
|
// TODO remove clamp?
|
||||||
@@ -194,6 +194,7 @@ const Sector* Room::getSector(int32 x, int32 z) const
|
|||||||
|
|
||||||
return sectors + sx * info->zSectors + sz;
|
return sectors + sx * info->zSectors + sz;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
const Sector* Room::getWaterSector(int32 x, int32 z) const
|
const Sector* Room::getWaterSector(int32 x, int32 z) const
|
||||||
{
|
{
|
||||||
|
44
src/platform/gba/asm/getSector.s
Normal file
44
src/platform/gba/asm/getSector.s
Normal 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
|
Reference in New Issue
Block a user