mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 19:47:35 +01:00
Fakematch sub_819A080
Really wanted to match this one, but it just doesn't cooperate, oh well
This commit is contained in:
parent
ce941e6f56
commit
5fbb11313b
358
src/menu.c
358
src/menu.c
@ -1,6 +1,7 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "bg.h"
|
||||
#include "blit.h"
|
||||
#include "dma3.h"
|
||||
#include "event_data.h"
|
||||
#include "graphics.h"
|
||||
@ -2013,337 +2014,82 @@ void PrintPlayerNameOnWindow(u8 windowId, const u8 *src, u16 x, u16 y)
|
||||
AddTextPrinterParameterized(windowId, 1, gStringVar4, x, y, 0xFF, 0);
|
||||
}
|
||||
|
||||
//Screw this function, it's long and unreferenced and ugh
|
||||
// Unused. Similar to BlitBitmapRect4Bit.
|
||||
void sub_819A080(const struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height)
|
||||
{
|
||||
int loopSrcY, loopDstY, loopSrcX, loopDstX, xEnd, yEnd, multiplierSrcY, multiplierDstY;
|
||||
const u8 *pixelsSrc;
|
||||
u16 *pixelsDst;
|
||||
u16 toOrr;
|
||||
|
||||
struct UnkStruct_819A080 {
|
||||
u8 *unk00;
|
||||
u16 unk04;
|
||||
u16 unk06;
|
||||
};
|
||||
if (dst->width - dstX < width)
|
||||
xEnd = dst->width - dstX + srcX;
|
||||
else
|
||||
xEnd = width + srcX;
|
||||
|
||||
#ifdef NONMATCHING
|
||||
void sub_819A080(struct UnkStruct_819A080 *a0, struct UnkStruct_819A080 *a1, u16 a2, u16 a3, u16 a4, u16 a5, u16 a6, u16 a7)
|
||||
{
|
||||
// r3 = a3
|
||||
// r4 = a5
|
||||
// r1 = a6
|
||||
// r5 = a7
|
||||
// sp+00 = a0
|
||||
// sp+04 = a1
|
||||
// sp+08 = a2
|
||||
// sp+0c = a4
|
||||
int sp10 = a1->unk04 - a4 < a6 ? a1->unk04 - a4 + a2 : a6 + a2;
|
||||
int sp14 = a0->unk06 - a5 < a7 ? a3 + a0->unk06 - a5 : a3 + a7;
|
||||
int sp18 = (a0->unk04 + (a0->unk04 & 0x7)) / 8;
|
||||
int sp1c = (a1->unk04 + (a1->unk04 & 0x7)) / 8;
|
||||
int r12; // sp+20
|
||||
int r8; // sp+24
|
||||
int r5;
|
||||
int r6;
|
||||
u16 r2;
|
||||
if (dst->height - dstY < height)
|
||||
yEnd = srcY + dst->height - dstY;
|
||||
else
|
||||
yEnd = srcY + height;
|
||||
|
||||
for (r12 = a3, r8 = a5; r12 < sp14; r12++, r8++)
|
||||
multiplierSrcY = (src->width + (src->width & 7)) >> 3;
|
||||
multiplierDstY = (dst->width + (dst->width & 7)) >> 3;
|
||||
|
||||
for (loopSrcY = srcY, loopDstY = dstY; loopSrcY < yEnd; loopSrcY++, loopDstY++)
|
||||
{
|
||||
for (r5 = a2, r6 = a4; a5 < sp10; a5++, a6++)
|
||||
for (loopSrcX = srcX, loopDstX = dstX; loopSrcX < xEnd; loopSrcX++, loopDstX++)
|
||||
{
|
||||
u8 *r3 = a0->unk00 + ((r5 >> 1) & 0x3) + ((r5 >> 3) << 5) + (((r12 >> 3) * sp18) << 5) + ((r12 & 0x7) << 2);
|
||||
u8 *r4 = a1->unk00 + ((r6 >> 1) & 0x3) + ((r6 >> 3) << 5) + (((r8 >> 3) * sp1c) << 5) + ((r8 & 0x7) << 2);
|
||||
if (((uintptr_t)r4) & 0x1)
|
||||
pixelsSrc = src->pixels + ((loopSrcX >> 1) & 3) + ((loopSrcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 0x1d) >> 0x1B);
|
||||
pixelsDst = (void*) dst->pixels + ((loopDstX >> 1) & 3) + ((loopDstX >> 3) << 5) + ((( loopDstY >> 3) * multiplierDstY) << 5) + ((u32)( loopDstY << 0x1d) >> 0x1B);
|
||||
|
||||
if ((uintptr_t )pixelsDst & 0x1)
|
||||
{
|
||||
u16 *r4_2 = (u16 *)(r4 - 1);
|
||||
if (r6 & 0x1)
|
||||
pixelsDst = (void*)(pixelsDst) - 1;
|
||||
if (loopDstX & 0x1)
|
||||
{
|
||||
r2 = *r4_2 & 0x0fff;
|
||||
if (r5 & 0x1)
|
||||
*r4_2 = r2 | ((*r3 & 0xf0) << 8);
|
||||
toOrr = *pixelsDst & 0x0fff;
|
||||
if (loopSrcX & 0x1)
|
||||
*pixelsDst = toOrr | ((*pixelsSrc & 0xf0) << 8);
|
||||
else
|
||||
*r4_2 = r2 | ((*r3 & 0x0f) << 12);
|
||||
*pixelsDst = toOrr | ((*pixelsSrc & 0x0f) << 12);
|
||||
}
|
||||
else
|
||||
{
|
||||
r2 = *r4_2 * 0xf0ff;
|
||||
if (r5 & 0x1)
|
||||
*r4_2 = r2 | ((*r3 & 0xf0) << 4);
|
||||
toOrr = *pixelsDst & 0xf0ff;
|
||||
if (loopSrcX & 0x1)
|
||||
*pixelsDst = toOrr | ((*pixelsSrc & 0xf0) << 4);
|
||||
else
|
||||
*r4_2 = r2 | ((*r3 & 0x0f) << 8);
|
||||
*pixelsDst = toOrr | ((*pixelsSrc & 0x0f) << 8);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u16 *r4_2 = (u16 *)r4;
|
||||
if (r6 & 1)
|
||||
if (loopDstX & 1)
|
||||
{
|
||||
r2 = *r4_2 & 0xff0f;
|
||||
if (r5 & 1)
|
||||
*r4_2 = r2 | ((*r3 & 0xf0) << 0);
|
||||
toOrr = *pixelsDst & 0xff0f;
|
||||
if (loopSrcX & 1)
|
||||
*pixelsDst = toOrr | ((*pixelsSrc & 0xf0) << 0);
|
||||
else
|
||||
*r4_2 = r2 | ((*r3 & 0x0f) << 4);
|
||||
*pixelsDst = toOrr | ((*pixelsSrc & 0x0f) << 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
r2 = *r4_2 & 0xfff0;
|
||||
if (r5 & 1)
|
||||
*r4_2 = r2 | ((*r3 & 0xf0) >> 4);
|
||||
toOrr = *pixelsDst & 0xfff0;
|
||||
if (loopSrcX & 1)
|
||||
*pixelsDst = toOrr | ((*pixelsSrc & 0xf0) >> 4);
|
||||
else
|
||||
*r4_2 = r2 | ((*r3 & 0x0f) >> 0);
|
||||
*pixelsDst = toOrr | ((*pixelsSrc & 0x0f) >> 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Needed to match, urgh.
|
||||
#ifndef NONMATCHING
|
||||
asm("":::"r4");
|
||||
pixelsDst++;pixelsDst--;
|
||||
#endif // NONMATCHING
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
NAKED
|
||||
void sub_819A080(struct UnkStruct_819A080 *a0, struct UnkStruct_819A080 *a1, u16 a2, u16 a3, u16 a4, u16 a5, u16 a6, u16 a7)
|
||||
{
|
||||
asm("push {r4-r7,lr}\n\
|
||||
mov r7, r10\n\
|
||||
mov r6, r9\n\
|
||||
mov r5, r8\n\
|
||||
push {r5-r7}\n\
|
||||
sub sp, #0x28\n\
|
||||
str r0, [sp]\n\
|
||||
str r1, [sp, #0x4]\n\
|
||||
ldr r0, [sp, #0x48]\n\
|
||||
ldr r4, [sp, #0x4C]\n\
|
||||
ldr r1, [sp, #0x50]\n\
|
||||
ldr r5, [sp, #0x54]\n\
|
||||
lsl r2, #16\n\
|
||||
lsr r2, #16\n\
|
||||
str r2, [sp, #0x8]\n\
|
||||
lsl r3, #16\n\
|
||||
lsr r3, #16\n\
|
||||
lsl r0, #16\n\
|
||||
lsr r0, #16\n\
|
||||
str r0, [sp, #0xC]\n\
|
||||
lsl r4, #16\n\
|
||||
lsr r4, #16\n\
|
||||
lsl r1, #16\n\
|
||||
lsr r1, #16\n\
|
||||
lsl r5, #16\n\
|
||||
lsr r5, #16\n\
|
||||
ldr r2, [sp, #0x4]\n\
|
||||
ldrh r0, [r2, #0x4]\n\
|
||||
ldr r2, [sp, #0xC]\n\
|
||||
sub r0, r2\n\
|
||||
ldr r2, [sp, #0x8]\n\
|
||||
add r2, r1, r2\n\
|
||||
str r2, [sp, #0x10]\n\
|
||||
cmp r0, r1\n\
|
||||
bge _0819A0CC\n\
|
||||
ldr r1, [sp, #0x8]\n\
|
||||
add r0, r1\n\
|
||||
str r0, [sp, #0x10]\n\
|
||||
_0819A0CC:\n\
|
||||
ldr r2, [sp, #0x4]\n\
|
||||
ldrh r1, [r2, #0x6]\n\
|
||||
sub r0, r1, r4\n\
|
||||
cmp r0, r5\n\
|
||||
bge _0819A0DE\n\
|
||||
add r0, r3, r1\n\
|
||||
sub r0, r4\n\
|
||||
str r0, [sp, #0x14]\n\
|
||||
b _0819A0E2\n\
|
||||
_0819A0DE:\n\
|
||||
add r5, r3, r5\n\
|
||||
str r5, [sp, #0x14]\n\
|
||||
_0819A0E2:\n\
|
||||
ldr r0, [sp]\n\
|
||||
ldrh r1, [r0, #0x4]\n\
|
||||
mov r2, #0x7\n\
|
||||
add r0, r1, #0\n\
|
||||
and r0, r2\n\
|
||||
add r1, r0\n\
|
||||
asr r1, #3\n\
|
||||
str r1, [sp, #0x18]\n\
|
||||
ldr r0, [sp, #0x4]\n\
|
||||
ldrh r1, [r0, #0x4]\n\
|
||||
add r0, r1, #0\n\
|
||||
and r0, r2\n\
|
||||
add r1, r0\n\
|
||||
asr r1, #3\n\
|
||||
str r1, [sp, #0x1C]\n\
|
||||
mov r12, r3\n\
|
||||
mov r8, r4\n\
|
||||
ldr r1, [sp, #0x14]\n\
|
||||
cmp r12, r1\n\
|
||||
blt _0819A10C\n\
|
||||
b _0819A24A\n\
|
||||
_0819A10C:\n\
|
||||
ldr r5, [sp, #0x8]\n\
|
||||
ldr r6, [sp, #0xC]\n\
|
||||
mov r2, r12\n\
|
||||
add r2, #0x1\n\
|
||||
str r2, [sp, #0x20]\n\
|
||||
mov r0, r8\n\
|
||||
add r0, #0x1\n\
|
||||
str r0, [sp, #0x24]\n\
|
||||
ldr r1, [sp, #0x10]\n\
|
||||
cmp r5, r1\n\
|
||||
blt _0819A124\n\
|
||||
b _0819A23A\n\
|
||||
_0819A124:\n\
|
||||
mov r7, #0x1\n\
|
||||
mov r2, #0xF0\n\
|
||||
mov r10, r2\n\
|
||||
mov r0, #0xF\n\
|
||||
mov r9, r0\n\
|
||||
_0819A12E:\n\
|
||||
asr r0, r5, #1\n\
|
||||
mov r1, #0x3\n\
|
||||
and r0, r1\n\
|
||||
ldr r2, [sp]\n\
|
||||
ldr r1, [r2]\n\
|
||||
add r1, r0\n\
|
||||
asr r0, r5, #3\n\
|
||||
lsl r0, #5\n\
|
||||
add r1, r0\n\
|
||||
mov r2, r12\n\
|
||||
asr r0, r2, #3\n\
|
||||
ldr r2, [sp, #0x18]\n\
|
||||
mul r0, r2\n\
|
||||
lsl r0, #5\n\
|
||||
add r1, r0\n\
|
||||
mov r2, r12\n\
|
||||
lsl r0, r2, #29\n\
|
||||
lsr r0, #27\n\
|
||||
add r3, r1, r0\n\
|
||||
asr r0, r6, #1\n\
|
||||
mov r1, #0x3\n\
|
||||
and r0, r1\n\
|
||||
ldr r2, [sp, #0x4]\n\
|
||||
ldr r1, [r2]\n\
|
||||
add r1, r0\n\
|
||||
asr r0, r6, #3\n\
|
||||
lsl r0, #5\n\
|
||||
add r1, r0\n\
|
||||
mov r2, r8\n\
|
||||
asr r0, r2, #3\n\
|
||||
ldr r2, [sp, #0x1C]\n\
|
||||
mul r0, r2\n\
|
||||
lsl r0, #5\n\
|
||||
add r1, r0\n\
|
||||
mov r2, r8\n\
|
||||
lsl r0, r2, #29\n\
|
||||
lsr r0, #27\n\
|
||||
add r4, r1, r0\n\
|
||||
add r0, r4, #0\n\
|
||||
and r0, r7\n\
|
||||
cmp r0, #0\n\
|
||||
beq _0819A1DA\n\
|
||||
sub r4, #0x1\n\
|
||||
add r0, r6, #0\n\
|
||||
and r0, r7\n\
|
||||
cmp r0, #0\n\
|
||||
beq _0819A1B2\n\
|
||||
ldrh r0, [r4]\n\
|
||||
ldr r2, =0x00000fff\n\
|
||||
and r2, r0\n\
|
||||
add r0, r5, #0\n\
|
||||
and r0, r7\n\
|
||||
cmp r0, #0\n\
|
||||
beq _0819A1A8\n\
|
||||
ldrb r1, [r3]\n\
|
||||
mov r0, r10\n\
|
||||
and r0, r1\n\
|
||||
lsl r0, #8\n\
|
||||
b _0819A22A\n\
|
||||
.pool\n\
|
||||
_0819A1A8:\n\
|
||||
ldrb r1, [r3]\n\
|
||||
mov r0, r9\n\
|
||||
and r0, r1\n\
|
||||
lsl r0, #12\n\
|
||||
b _0819A22A\n\
|
||||
_0819A1B2:\n\
|
||||
ldrh r0, [r4]\n\
|
||||
ldr r2, =0x0000f0ff\n\
|
||||
and r2, r0\n\
|
||||
add r0, r5, #0\n\
|
||||
and r0, r7\n\
|
||||
cmp r0, #0\n\
|
||||
beq _0819A1D0\n\
|
||||
ldrb r1, [r3]\n\
|
||||
mov r0, r10\n\
|
||||
and r0, r1\n\
|
||||
lsl r0, #4\n\
|
||||
b _0819A22A\n\
|
||||
.pool\n\
|
||||
_0819A1D0:\n\
|
||||
ldrb r1, [r3]\n\
|
||||
mov r0, r9\n\
|
||||
and r0, r1\n\
|
||||
lsl r0, #8\n\
|
||||
b _0819A22A\n\
|
||||
_0819A1DA:\n\
|
||||
add r0, r6, #0\n\
|
||||
and r0, r7\n\
|
||||
cmp r0, #0\n\
|
||||
beq _0819A206\n\
|
||||
ldrh r0, [r4]\n\
|
||||
ldr r2, =0x0000ff0f\n\
|
||||
and r2, r0\n\
|
||||
add r0, r5, #0\n\
|
||||
and r0, r7\n\
|
||||
cmp r0, #0\n\
|
||||
beq _0819A1FC\n\
|
||||
ldrb r1, [r3]\n\
|
||||
mov r0, r10\n\
|
||||
b _0819A228\n\
|
||||
.pool\n\
|
||||
_0819A1FC:\n\
|
||||
ldrb r1, [r3]\n\
|
||||
mov r0, r9\n\
|
||||
and r0, r1\n\
|
||||
lsl r0, #4\n\
|
||||
b _0819A22A\n\
|
||||
_0819A206:\n\
|
||||
ldrh r0, [r4]\n\
|
||||
ldr r2, =0x0000fff0\n\
|
||||
and r2, r0\n\
|
||||
add r0, r5, #0\n\
|
||||
and r0, r7\n\
|
||||
cmp r0, #0\n\
|
||||
beq _0819A224\n\
|
||||
ldrb r1, [r3]\n\
|
||||
mov r0, r10\n\
|
||||
and r0, r1\n\
|
||||
lsr r0, #4\n\
|
||||
b _0819A22A\n\
|
||||
.pool\n\
|
||||
_0819A224:\n\
|
||||
ldrb r1, [r3]\n\
|
||||
mov r0, r9\n\
|
||||
_0819A228:\n\
|
||||
and r0, r1\n\
|
||||
_0819A22A:\n\
|
||||
orr r2, r0\n\
|
||||
strh r2, [r4]\n\
|
||||
add r5, #0x1\n\
|
||||
add r6, #0x1\n\
|
||||
ldr r0, [sp, #0x10]\n\
|
||||
cmp r5, r0\n\
|
||||
bge _0819A23A\n\
|
||||
b _0819A12E\n\
|
||||
_0819A23A:\n\
|
||||
ldr r1, [sp, #0x20]\n\
|
||||
mov r12, r1\n\
|
||||
ldr r2, [sp, #0x24]\n\
|
||||
mov r8, r2\n\
|
||||
ldr r0, [sp, #0x14]\n\
|
||||
cmp r12, r0\n\
|
||||
bge _0819A24A\n\
|
||||
b _0819A10C\n\
|
||||
_0819A24A:\n\
|
||||
add sp, #0x28\n\
|
||||
pop {r3-r5}\n\
|
||||
mov r8, r3\n\
|
||||
mov r9, r4\n\
|
||||
mov r10, r5\n\
|
||||
pop {r4-r7}\n\
|
||||
pop {r0}\n\
|
||||
bx r0\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
void sub_819A25C(u8 palOffset, u16 speciesId)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user