Merge remote-tracking branch 'Egg/match_non'

This commit is contained in:
Diegoisawesome 2018-02-06 12:12:27 -06:00
commit 91387a95c3

View File

@ -891,238 +891,57 @@ void TintPalette_GrayScale2(u16 *palette, u16 count)
}
}
#ifdef NONMATCHING
void TintPalette_SepiaTone(u16 *palette, u16 count)
{
int red;
int green;
int blue;
u32 gray;
u32 sepia;
s8 r2;
s8 g2;
s8 b2;
s32 r, g, b, gray;
s32 i;
int i;
for (i = 0; i < count; i++)
for (i = 0; i < count; palette++, i++)
{
r = *palette & 0x1F;
g = (*palette >> 5) & 0x1F;
r = (*palette >> 0) & 0x1F;
g = (*palette >> 5) & 0x1F;
b = (*palette >> 10) & 0x1F;
r *= 0x4C;
r += g * 0x97;
r += b * 0x1D;
gray = (r * 76 + g * 151 + b * 29) >> 8;
gray = (s32)(r >> 8);
r = (u16)((307 * gray)) >> 8;
g = (u16)((256 * gray)) >> 8;
b = (u16)((240 * gray)) >> 8;
sepia = (gray * 0x133);
if (r > 31)
r = 31;
r2 = (u16)sepia >> 8;
g2 = gray;
b2 = (gray * 15);
if (r2 > 0x1F)
r2 = 0x1F;
*palette++ = b2 << 10 | g2 << 5 | r2;
*palette = (b << 10) | (g << 5) | (r << 0);
}
}
#else
__attribute__((naked))
void TintPalette_SepiaTone(u16 *palette, u16 count)
{
asm("push {r4-r7,lr}\n\
add r5, r0, #0\n\
lsl r1, #16\n\
lsr r1, #16\n\
cmp r1, #0\n\
beq _080A2BA2\n\
mov r7, #0x1F\n\
add r6, r1, #0\n\
_080A2B50:\n\
ldrh r0, [r5]\n\
mov r1, #0x1F\n\
and r1, r0\n\
lsl r0, #16\n\
lsr r2, r0, #21\n\
and r2, r7\n\
lsr r3, r0, #26\n\
and r3, r7\n\
mov r0, #0x4C\n\
mul r1, r0\n\
mov r0, #0x97\n\
mul r0, r2\n\
add r1, r0\n\
lsl r0, r3, #3\n\
sub r0, r3\n\
lsl r0, #2\n\
add r0, r3\n\
add r1, r0\n\
asr r1, #8\n\
ldr r0, =0x00000133\n\
mul r0, r1\n\
lsl r0, #16\n\
lsr r2, r0, #24\n\
lsl r0, r1, #24\n\
lsr r4, r0, #24\n\
lsl r0, r1, #4\n\
sub r0, r1\n\
lsl r0, #20\n\
lsr r3, r0, #24\n\
cmp r2, #0x1F\n\
ble _080A2B90\n\
mov r2, #0x1F\n\
_080A2B90:\n\
lsl r0, r3, #10\n\
lsl r1, r4, #5\n\
orr r0, r1\n\
orr r0, r2\n\
strh r0, [r5]\n\
add r5, #0x2\n\
sub r6, #0x1\n\
cmp r6, #0\n\
bne _080A2B50\n\
_080A2BA2:\n\
pop {r4-r7}\n\
pop {r0}\n\
bx r0\n\
.pool");
}
#endif // NONMATCHING
#ifdef NONMATCHING
void TintPalette_CustomTone(u16 *palette, u16 count, u16 a3, u16 a4, u16 a5)
void TintPalette_CustomTone(u16 *palette, u16 count, u16 rTone, u16 gTone, u16 bTone)
{
s32 r;
s32 g;
s32 b;
s32 gray;
u8 r2;
u8 g2;
u8 b2;
s32 r, g, b, gray;
s32 i;
int i;
for (i = 0; i < count; i++)
for (i = 0; i < count; palette++, i++)
{
r = *palette & 0x1F;
g = (*palette >> 5) & 0x1F;
r = (*palette >> 0) & 0x1F;
g = (*palette >> 5) & 0x1F;
b = (*palette >> 10) & 0x1F;
r *= 0x4C;
r += g * 0x97;
r += b * 0x1D;
gray = (r * 76 + g * 151 + b * 29) >> 8;
gray = r >> 8;
r = (u16)((rTone * gray)) >> 8;
g = (u16)((gTone * gray)) >> 8;
b = (u16)((bTone * gray)) >> 8;
r2 = (u16)(gray * a3) >> 8;
if (r > 31)
r = 31;
if (g > 31)
g = 31;
if (b > 31)
b = 31;
g2 = (u16)(gray * a4) >> 8;
b2 = (u16)(gray * a5) >> 8;
if (r2 > 0x1F)
r2 = 0x1F;
if (g2 > 0x1F)
g2 = 0x1F;
if (b2 > 0x1F)
b2 = 0x1F;
*palette++ = b2 << 10 | g2 << 5 | r2;
*palette = (b << 10) | (g << 5) | (r << 0);
}
return;
}
#else
__attribute__((naked))
void TintPalette_CustomTone(u16 *palette, u16 count, u16 a3, u16 a4, u16 a5)
{
asm("push {r4-r7,lr}\n\
mov r7, r9\n\
mov r6, r8\n\
push {r6,r7}\n\
add r5, r0, #0\n\
ldr r0, [sp, #0x1C]\n\
lsl r1, #16\n\
lsr r1, #16\n\
lsl r2, #16\n\
lsr r2, #16\n\
mov r9, r2\n\
lsl r3, #16\n\
lsr r3, #16\n\
mov r8, r3\n\
lsl r0, #16\n\
lsr r0, #16\n\
mov r12, r0\n\
cmp r1, #0\n\
beq _080A2C38\n\
mov r7, #0x1F\n\
add r6, r1, #0\n\
_080A2BD6:\n\
ldrh r0, [r5]\n\
mov r1, #0x1F\n\
and r1, r0\n\
lsl r0, #16\n\
lsr r2, r0, #21\n\
and r2, r7\n\
lsr r3, r0, #26\n\
and r3, r7\n\
mov r0, #0x4C\n\
mul r1, r0\n\
mov r0, #0x97\n\
mul r0, r2\n\
add r1, r0\n\
lsl r0, r3, #3\n\
sub r0, r3\n\
lsl r0, #2\n\
add r0, r3\n\
add r1, r0\n\
asr r1, #8\n\
mov r0, r9\n\
mul r0, r1\n\
lsl r0, #16\n\
lsr r4, r0, #24\n\
mov r0, r8\n\
mul r0, r1\n\
lsl r0, #16\n\
lsr r2, r0, #24\n\
mov r0, r12\n\
mul r0, r1\n\
lsl r0, #16\n\
lsr r3, r0, #24\n\
cmp r4, #0x1F\n\
ble _080A2C1A\n\
mov r4, #0x1F\n\
_080A2C1A:\n\
cmp r2, #0x1F\n\
ble _080A2C20\n\
mov r2, #0x1F\n\
_080A2C20:\n\
cmp r3, #0x1F\n\
ble _080A2C26\n\
mov r3, #0x1F\n\
_080A2C26:\n\
lsl r0, r3, #10\n\
lsl r1, r2, #5\n\
orr r0, r1\n\
orr r0, r4\n\
strh r0, [r5]\n\
add r5, #0x2\n\
sub r6, #0x1\n\
cmp r6, #0\n\
bne _080A2BD6\n\
_080A2C38:\n\
pop {r3,r4}\n\
mov r8, r3\n\
mov r9, r4\n\
pop {r4-r7}\n\
pop {r0}\n\
bx r0");
}
#endif
void sub_80A2C44(u32 a1, s8 a2, u8 a3, u8 a4, u16 a5, u8 a6, u8 a7)
{