Match FindPalette

This commit is contained in:
Tal Hayon 2022-01-25 00:52:18 +02:00
parent 97164d57cd
commit 6a10dfe491
2 changed files with 14 additions and 29 deletions

View File

@ -1,28 +0,0 @@
.syntax unified
push {lr}
adds r2, r0, #0
cmp r2, #5
bhi _0801D116
b _0801D12E
_0801D112:
adds r0, r1, #0
b _0801D12E
_0801D116:
movs r1, #6
ldr r0, _0801D130 @ =gPaletteList
adds r0, #0x18
_0801D11C:
ldrh r3, [r0, #2]
cmp r2, r3
beq _0801D112
adds r0, #4
adds r1, #1
cmp r1, #0xf
bls _0801D11C
movs r0, #1
rsbs r0, r0, #0
_0801D12E:
pop {pc}
.align 2, 0
_0801D130: .4byte gPaletteList
.syntax divided

View File

@ -29,7 +29,20 @@ ASM_FUNC("asm/non_matching/color/sub_0801D000.inc", void sub_0801D000(u32 a1));
ASM_FUNC("asm/non_matching/color/LoadObjPalette.inc", u32 LoadObjPalette(Entity* entity, u32 a2));
ASM_FUNC("asm/non_matching/color/FindPalette.inc", s32 FindPalette(u32 a1));
s32 FindPalette(u32 a1) {
u32 index;
Palette* palette;
if (a1 <= 5)
return a1;
for (index = 6, palette = gPaletteList; index < 0x10; index++) {
if (a1 == palette[index]._2) {
return index;
}
}
return -1;
}
ASM_FUNC("asm/non_matching/color/FindFreeObjPalette.inc", u32 FindFreeObjPalette(u32 a1));