match obj update pos2

This commit is contained in:
DizzyEggg 2018-02-06 17:42:24 +01:00
parent eb6aed50e5
commit 9e43b01a4c

View File

@ -240,12 +240,26 @@ static const AffineAnimCmdFunc sAffineAnimCmdFuncs[] =
AffineAnimCmd_frame,
};
static const s32 sUnknown_082EC6F4[24] =
static const s32 sUnknown_082EC6F4[3][4][2] =
{
8, 8, 0x10, 0x10, 0x20, 0x20,
0x40, 0x40, 0x10, 8, 0x20, 8,
0x20, 0x10, 0x40, 0x20, 8, 0x10,
8, 0x20, 0x10, 0x20, 0x20, 0x40,
{
{8, 8},
{0x10, 0x10},
{0x20, 0x20},
{0x40, 0x40},
},
{
{0x10, 8},
{0x20, 8},
{0x20, 0x10},
{0x40, 0x20},
},
{
{8, 0x10},
{8, 0x20},
{0x10, 0x20},
{0x20, 0x40},
},
};
static const struct OamDimensions sOamDimensions[3][4] =
@ -1207,106 +1221,26 @@ s32 sub_8007E28(s32 a0, s32 a1, s32 a2)
return a2 - ((u32)(a2 * a1) / (u32)(a0) + var1);
}
#ifdef NONMATCHING
void obj_update_pos2(struct Sprite* sprite, s32 a1, s32 a2)
void obj_update_pos2(struct Sprite *sprite, s32 a1, s32 a2)
{
s32 var0, var1, var2;
u8 matrixNum = sprite->oam.matrixNum;
u32 matrixNum = sprite->oam.matrixNum;
if (a1 != 0x800)
{
var0 = sUnknown_082EC6F4[sprite->oam.size * 8 + sprite->oam.shape * 32];
var0 = sUnknown_082EC6F4[sprite->oam.shape][sprite->oam.size][0];
var1 = var0 << 8;
var2 = (var0 << 16) / gOamMatrices[matrixNum].a;
sprite->pos2.x = sub_8007E28(var1, var2, a1);
}
if (a2 != 0x800)
{
var0 = sUnknown_082EC6F4[4 + (sprite->oam.size * 8 + sprite->oam.shape * 32)];
var0 = sUnknown_082EC6F4[sprite->oam.shape][sprite->oam.size][1];
var1 = var0 << 8;
var2 = (var0 << 16) / gOamMatrices[matrixNum].d;
sprite->pos2.y = sub_8007E28(var1, var2, a2);
}
}
#else
__attribute__((naked))
void obj_update_pos2(struct Sprite* sprite, s32 a1, s32 a2)
{
asm(".syntax unified\n\
push {r4-r7,lr}\n\
mov r7, r9\n\
mov r6, r8\n\
push {r6,r7}\n\
adds r5, r0, 0\n\
adds r6, r1, 0\n\
mov r8, r2\n\
ldrb r1, [r5, 0x3]\n\
lsls r0, r1, 26\n\
lsrs r7, r0, 27\n\
movs r0, 0x80\n\
lsls r0, 4\n\
mov r9, r0\n\
cmp r6, r9\n\
beq _08007EA2\n\
ldr r2, =sUnknown_082EC6F4\n\
lsrs r1, 6\n\
lsls r1, 3\n\
ldrb r0, [r5, 0x1]\n\
lsrs r0, 6\n\
lsls r0, 5\n\
adds r1, r0\n\
adds r1, r2\n\
ldr r0, [r1]\n\
lsls r4, r0, 8\n\
lsls r0, 16\n\
ldr r2, =gOamMatrices\n\
lsls r1, r7, 3\n\
adds r1, r2\n\
movs r2, 0\n\
ldrsh r1, [r1, r2]\n\
bl __divsi3\n\
adds r1, r0, 0\n\
adds r0, r4, 0\n\
adds r2, r6, 0\n\
bl sub_8007E28\n\
strh r0, [r5, 0x24]\n\
_08007EA2:\n\
cmp r8, r9\n\
beq _08007EDA\n\
ldr r2, =sUnknown_082EC6F4\n\
ldrb r1, [r5, 0x3]\n\
lsrs r1, 6\n\
lsls r1, 3\n\
ldrb r0, [r5, 0x1]\n\
lsrs r0, 6\n\
lsls r0, 5\n\
adds r1, r0\n\
adds r2, 0x4\n\
adds r1, r2\n\
ldr r0, [r1]\n\
lsls r4, r0, 8\n\
lsls r0, 16\n\
ldr r2, =gOamMatrices\n\
lsls r1, r7, 3\n\
adds r1, r2\n\
movs r2, 0x6\n\
ldrsh r1, [r1, r2]\n\
bl __divsi3\n\
adds r1, r0, 0\n\
adds r0, r4, 0\n\
mov r2, r8\n\
bl sub_8007E28\n\
strh r0, [r5, 0x26]\n\
_08007EDA:\n\
pop {r3,r4}\n\
mov r8, r3\n\
mov r9, r4\n\
pop {r4-r7}\n\
pop {r0}\n\
bx r0\n\
.pool\n\
.syntax divided");
}
#endif // NONMATCHING
void SetSpriteOamFlipBits(struct Sprite *sprite, u8 hFlip, u8 vFlip)
{