mirror of
https://github.com/pret/pmd-red.git
synced 2024-11-23 13:09:56 +00:00
Match sub_800533C
This commit is contained in:
parent
088162e8bd
commit
932d0945e0
@ -5,8 +5,8 @@
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start sub_800558C
|
||||
sub_800558C:
|
||||
thumb_func_start DoAxFrame_800558C
|
||||
DoAxFrame_800558C:
|
||||
push {r4-r7,lr}
|
||||
sub sp, 0x4
|
||||
adds r5, r0, 0
|
||||
@ -72,7 +72,7 @@ _08005602:
|
||||
bx r0
|
||||
.align 2, 0
|
||||
_0800560C: .4byte 0x0000f7ff
|
||||
thumb_func_end sub_800558C
|
||||
thumb_func_end DoAxFrame_800558C
|
||||
|
||||
thumb_func_start sub_8005610
|
||||
sub_8005610:
|
||||
|
@ -154,7 +154,7 @@ _0800DDCA:
|
||||
str r0, [sp, 0x4]
|
||||
mov r0, r8
|
||||
adds r1, r4, 0
|
||||
bl sub_800558C
|
||||
bl DoAxFrame_800558C
|
||||
_0800DE26:
|
||||
movs r0, 0x1
|
||||
_0800DE28:
|
||||
@ -6081,7 +6081,7 @@ sub_8010A88:
|
||||
add r3, sp, 0x8
|
||||
str r3, [sp, 0x4]
|
||||
movs r3, 0x3
|
||||
bl sub_800558C
|
||||
bl DoAxFrame_800558C
|
||||
_08010AF6:
|
||||
lsls r0, r5, 16
|
||||
asrs r0, 16
|
||||
@ -6118,7 +6118,7 @@ _08010B04:
|
||||
str r3, [sp, 0x4]
|
||||
adds r0, r5, 0
|
||||
movs r3, 0x1
|
||||
bl sub_800558C
|
||||
bl DoAxFrame_800558C
|
||||
_08010B40:
|
||||
adds r7, 0x44
|
||||
subs r6, 0x1
|
||||
@ -6632,7 +6632,7 @@ sub_8010F28:
|
||||
str r3, [sp, 0x4]
|
||||
adds r0, r4, 0
|
||||
movs r3, 0x3
|
||||
bl sub_800558C
|
||||
bl DoAxFrame_800558C
|
||||
movs r7, 0
|
||||
mov r10, r6
|
||||
ldr r6, _0801109C
|
||||
@ -6667,7 +6667,7 @@ _08010F98:
|
||||
str r0, [sp, 0x4]
|
||||
adds r0, r4, 0
|
||||
movs r3, 0x1
|
||||
bl sub_800558C
|
||||
bl DoAxFrame_800558C
|
||||
_08010FD8:
|
||||
adds r6, 0x50
|
||||
adds r7, 0x1
|
||||
@ -6737,7 +6737,7 @@ _0801101E:
|
||||
add r3, sp, 0x8
|
||||
str r3, [sp, 0x4]
|
||||
movs r3, 0x2
|
||||
bl sub_800558C
|
||||
bl DoAxFrame_800558C
|
||||
_08011062:
|
||||
adds r6, 0x3C
|
||||
ldr r4, [sp, 0x14]
|
||||
|
@ -5208,7 +5208,7 @@ _0806CAD2:
|
||||
ldr r1, [sp, 0x2C]
|
||||
ldr r2, [sp, 0x30]
|
||||
mov r3, r9
|
||||
bl sub_800558C
|
||||
bl DoAxFrame_800558C
|
||||
b _0806CB16
|
||||
_0806CAF8:
|
||||
cmp r1, 0x1
|
||||
@ -5224,7 +5224,7 @@ _0806CAF8:
|
||||
ldr r1, [sp, 0x2C]
|
||||
ldr r2, [sp, 0x30]
|
||||
mov r3, r9
|
||||
bl sub_800558C
|
||||
bl DoAxFrame_800558C
|
||||
_0806CB16:
|
||||
ldr r0, [r6, 0xC]
|
||||
cmp r0, 0
|
||||
|
@ -1877,7 +1877,7 @@ _080A71BC:
|
||||
adds r0, r7, 0
|
||||
movs r2, 0xD0
|
||||
movs r3, 0
|
||||
bl sub_800558C
|
||||
bl DoAxFrame_800558C
|
||||
adds r0, r7, 0
|
||||
adds r0, 0x70
|
||||
mov r3, r9
|
||||
@ -1909,7 +1909,7 @@ _080A7234:
|
||||
adds r0, r7, 0
|
||||
adds r1, r5, 0
|
||||
mov r2, r8
|
||||
bl sub_800558C
|
||||
bl DoAxFrame_800558C
|
||||
movs r0, 0
|
||||
strb r0, [r4]
|
||||
mov r2, r10
|
||||
@ -1942,7 +1942,7 @@ _080A7274:
|
||||
adds r0, r7, 0
|
||||
movs r2, 0xD0
|
||||
movs r3, 0
|
||||
bl sub_800558C
|
||||
bl DoAxFrame_800558C
|
||||
movs r0, 0
|
||||
strb r0, [r4]
|
||||
_080A72A6:
|
||||
|
61
asm/sprite.s
61
asm/sprite.s
@ -5,67 +5,6 @@
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start sub_800533C
|
||||
sub_800533C:
|
||||
push {r4-r7,lr}
|
||||
mov r7, r8
|
||||
push {r7}
|
||||
mov r8, r1
|
||||
adds r5, r2, 0
|
||||
adds r7, r3, 0
|
||||
ldr r1, [sp, 0x18]
|
||||
lsls r1, 24
|
||||
lsrs r6, r1, 24
|
||||
movs r2, 0x18
|
||||
ldrsh r1, [r5, r2]
|
||||
lsls r1, 2
|
||||
adds r1, r0
|
||||
ldr r4, [r1]
|
||||
ldr r1, _08005368
|
||||
movs r2, 0x14
|
||||
ldrsh r0, [r5, r2]
|
||||
lsls r0, 5
|
||||
ldr r2, _0800536C
|
||||
adds r0, r2
|
||||
str r0, [r1]
|
||||
b _0800538E
|
||||
.align 2, 0
|
||||
_08005368: .4byte gCharMemCursor
|
||||
_0800536C: .4byte 0x06010000
|
||||
_08005370:
|
||||
cmp r6, 0
|
||||
beq _08005382
|
||||
movs r1, 0
|
||||
ldrsh r0, [r4, r1]
|
||||
cmp r0, 0
|
||||
blt _08005382
|
||||
lsls r0, 2
|
||||
add r0, r8
|
||||
ldr r2, [r0]
|
||||
_08005382:
|
||||
adds r0, r4, 0
|
||||
adds r1, r5, 0
|
||||
adds r3, r7, 0
|
||||
bl sub_8004EA8
|
||||
adds r4, 0xA
|
||||
_0800538E:
|
||||
movs r2, 0
|
||||
ldrh r1, [r4]
|
||||
ldr r0, _080053A8
|
||||
cmp r1, r0
|
||||
bne _08005370
|
||||
ldrh r0, [r4, 0x2]
|
||||
cmp r0, r1
|
||||
bne _08005370
|
||||
pop {r3}
|
||||
mov r8, r3
|
||||
pop {r4-r7}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.align 2, 0
|
||||
_080053A8: .4byte 0x0000ffff
|
||||
thumb_func_end sub_800533C
|
||||
|
||||
thumb_func_start sub_80053AC
|
||||
sub_80053AC:
|
||||
push {r4-r6,lr}
|
||||
|
@ -46,6 +46,35 @@ struct UnkSpriteMem
|
||||
/* 0x4 */ s32 byteCount;
|
||||
};
|
||||
|
||||
// size: 0x20
|
||||
struct axdata1
|
||||
{
|
||||
/* 0x0 */ s16 xPos;
|
||||
/* 0x2 */ s16 yPos;
|
||||
/* 0x4 */ u16 xOffset;
|
||||
/* 0x6 */ u16 yOffset;
|
||||
/* 0x8 */ u16 xShadow;
|
||||
/* 0xA */ u16 yShadow;
|
||||
u32 unkC;
|
||||
u32 unk10;
|
||||
/* 0x14 */ s16 vramTileOrMaybeAnimTimer;
|
||||
s16 unk16;
|
||||
/* 0x18 */ s16 poseId;
|
||||
/* 0x1A */ s16 lastPoseId;
|
||||
u8 fill1C[0x1E - 0x1C];
|
||||
u8 paletteNum;
|
||||
};
|
||||
|
||||
// size: 0xA
|
||||
struct __attribute__ ((packed, aligned(2))) ax_pose
|
||||
{
|
||||
s16 sprite;
|
||||
u16 unk2; // Always 0 in red (except for end markers which are 0xFFFF)
|
||||
u16 flags1;
|
||||
u16 flags2;
|
||||
u16 flags3;
|
||||
};
|
||||
|
||||
void AddSprite(struct unkSprite *, s32, struct UnkSpriteMem *, struct unkStruct_2039DB0 *);
|
||||
void BlinkSavingIcon(void);
|
||||
void CopySpritesToOam(void);
|
||||
|
@ -45,8 +45,7 @@ void sub_80A62F0(void)
|
||||
gUnknown_2039DD4 = 22;
|
||||
gUnknown_2039DD0 = 1;
|
||||
|
||||
for (r0 = 0; r0 < 22; r0 = (s16)(r0 + 1), sub0++)
|
||||
{
|
||||
for (r0 = 0; r0 < 22; r0 = (s16)(r0 + 1), sub0++) {
|
||||
sub0->unk0 = 0;
|
||||
sub0->unk4 = r0 * 16;
|
||||
sub0->unk8 = 0;
|
||||
|
148
src/sprite.c
148
src/sprite.c
@ -3,12 +3,14 @@
|
||||
#include "sprite.h"
|
||||
|
||||
extern u16 gUnknown_2025670;
|
||||
extern s16 gUnknown_2025672[8];
|
||||
extern s16 gUnknown_2025682[9];
|
||||
extern struct Position gUnknown_2025694;
|
||||
extern u32 gUnknown_2025698;
|
||||
extern struct SpriteList gUnknown_20256A0;
|
||||
extern struct UnkSpriteLink gUnknown_2025EA8[128];
|
||||
extern struct unkSprite gUnknown_20262A8[128];
|
||||
extern u32 gSpriteCount; /* 20266A8 */
|
||||
extern s32 gSpriteCount; /* 20266A8 */
|
||||
extern struct unkStruct_20266B0 gUnknown_20266B0[160];
|
||||
extern void *gCharMemCursor; /* 2026E30 */
|
||||
extern struct unkStruct_20266B0 *gUnknown_203B074;
|
||||
@ -16,7 +18,7 @@ extern struct unkStruct_20266B0 *gUnknown_203B074;
|
||||
// code.c
|
||||
extern void nullsub_3(s32, s32);
|
||||
|
||||
void sub_80052BC(struct UnkSpriteMem *);
|
||||
void RegisterSpriteParts_80052BC(struct UnkSpriteMem *);
|
||||
|
||||
void InitSprites(void)
|
||||
{
|
||||
@ -135,9 +137,112 @@ void sub_8004E8C(struct unkStruct_2039DB0 *a0)
|
||||
a0->unkA = 0;
|
||||
}
|
||||
|
||||
// Need more structs decomped first https://decomp.me/scratch/VYqKb
|
||||
// https://decomp.me/scratch/VYqKb
|
||||
// spriteMasks is a u16[6]
|
||||
#if NONMATCHING
|
||||
void sub_8004EA8(struct ax_pose *a0, struct axdata1 *a1, struct UnkSpriteMem *a2, u16 *spriteMasks)
|
||||
{
|
||||
// size: 0xC
|
||||
struct UnkStackFor8004EA8
|
||||
{
|
||||
u16 unk0;
|
||||
u8 unk2;
|
||||
s8 unk3;
|
||||
u16 flags1;
|
||||
u16 flags2;
|
||||
u16 flags3;
|
||||
u16 unkA;
|
||||
} sp;
|
||||
struct unkSprite *sprite;
|
||||
u32 uVar9;
|
||||
s32 r7;
|
||||
|
||||
s32 x;
|
||||
s32 y;
|
||||
s32 tileNum;
|
||||
s32 earlyMask;
|
||||
|
||||
if (a2 != NULL)
|
||||
RegisterSpriteParts_80052BC(a2);
|
||||
|
||||
if (gSpriteCount >= 128)
|
||||
return;
|
||||
|
||||
sp.unk0 = a0->sprite;
|
||||
*((u16 *)&sp.unk2) = a0->unk2; // ?????????
|
||||
sp.flags1 = a0->flags1 & ~(0x100 | 0x200);
|
||||
sp.flags2 = a0->flags2 & ~(0x200 | 0x400 | 0x800);
|
||||
sp.flags3 = a0->flags3;
|
||||
sp.unkA = ((a0->flags2 & (0x200 | 0x400 | 0x800)) >> 9) | ((a0->flags1 & (0x1 | 0x2 | 0x4 | 0x8 | 0x10 | 0x20 | 0x40 | 0x80 | 0x100 | 0x200)) << 4);
|
||||
sprite = gUnknown_20262A8 + gSpriteCount;
|
||||
r7 = a1->unk16 + sp.unk3;
|
||||
|
||||
if (r7 < 0)
|
||||
r7 = 0;
|
||||
if (r7 > 255)
|
||||
r7 = 255;
|
||||
|
||||
if (spriteMasks == NULL) {
|
||||
sprite->unk0 = sp.flags1;
|
||||
sprite->unk2 = sp.flags2;
|
||||
sprite->unk4 = sp.flags3;
|
||||
sprite->unk6 = sp.unkA;
|
||||
}
|
||||
else {
|
||||
sprite->unk0 = (spriteMasks[0] & sp.flags1) | spriteMasks[3];
|
||||
sprite->unk2 = (spriteMasks[1] & sp.flags2) | spriteMasks[4];
|
||||
sprite->unk4 = (spriteMasks[2] & sp.flags3) | spriteMasks[5];
|
||||
sprite->unk6 = sp.unkA;
|
||||
}
|
||||
|
||||
if (sp.unk2 != 0 && gUnknown_2025672[sp.unk2] != 0) {
|
||||
tileNum = gUnknown_2025672[sp.unk2] & 0x3FF;
|
||||
}
|
||||
else {
|
||||
tileNum = (sprite->unk4 & 0x3FF) + a1->vramTileOrMaybeAnimTimer;
|
||||
tileNum &= 0x3FF;
|
||||
}
|
||||
|
||||
// Set tileNum, maintain priority/paletteNum
|
||||
sprite->unk4 = tileNum | (sprite->unk4 & 0xFC00);
|
||||
|
||||
x = (sprite->unk2 & 0x1FF) - 256;
|
||||
x += a1->xPos;
|
||||
if (x < -64)
|
||||
return;
|
||||
if (x >= DISPLAY_WIDTH)
|
||||
return;
|
||||
|
||||
// Set x, maintain matrixNum/size
|
||||
sprite->unk2 = (x & 0x1FF) | (sprite->unk2 & 0xFE00);
|
||||
|
||||
uVar9 = sprite->unk6 << 16;
|
||||
earlyMask = 0xFFF;
|
||||
|
||||
y = (uVar9 >> 20) - 512;
|
||||
y += a1->yPos;
|
||||
if (y < -64)
|
||||
return;
|
||||
if (y >= DISPLAY_HEIGHT)
|
||||
return;
|
||||
|
||||
// Set y, maintain affineMode/objMode/mosaic/bpp/shape
|
||||
sprite->unk0 = (y & 0xFF) | (sprite->unk0 & 0xFF00);
|
||||
|
||||
// Set paletteNum, maintain tileNum/priority
|
||||
if (((uVar9 >> 17) & 1) == 0)
|
||||
sprite->unk4 = ((a1->paletteNum & 0xF) << 12) | (sprite->unk4 & earlyMask);
|
||||
|
||||
if (sp.unk2 != 0)
|
||||
sprite->unk4 = ((gUnknown_2025682[sp.unk2] & 0xF) << 12) | (sprite->unk4 & earlyMask);
|
||||
|
||||
gUnknown_2025EA8[gSpriteCount].unk0 = gUnknown_20256A0.sprites[r7].unk0;
|
||||
gUnknown_20256A0.sprites[r7].unk0 = gUnknown_2025EA8 + gSpriteCount;
|
||||
gSpriteCount++;
|
||||
}
|
||||
#else
|
||||
NAKED
|
||||
void sub_8004EA8(s32 a0, s16 *a1, u32 *a2, u16 *a3)
|
||||
void sub_8004EA8(struct ax_pose *a0, struct axdata1 *a1, struct UnkSpriteMem *a2, u16 *spriteMasks)
|
||||
{
|
||||
asm_unified(
|
||||
"push {r4-r7,lr}\n"
|
||||
@ -151,7 +256,7 @@ void sub_8004EA8(s32 a0, s16 *a1, u32 *a2, u16 *a3)
|
||||
"\tadds r6, r3, 0\n"
|
||||
"\tcmp r0, 0\n"
|
||||
"\tbeq _08004EC2\n"
|
||||
"\tbl sub_80052BC\n"
|
||||
"\tbl RegisterSpriteParts_80052BC\n"
|
||||
"_08004EC2:\n"
|
||||
"\tldr r0, _08004F40\n"
|
||||
"\tldr r7, [r0]\n"
|
||||
@ -399,6 +504,7 @@ void sub_8004EA8(s32 a0, s16 *a1, u32 *a2, u16 *a3)
|
||||
"_080050A8: .4byte gUnknown_2025EA8\n"
|
||||
"_080050AC: .4byte gUnknown_20256A0");
|
||||
}
|
||||
#endif // NONMATCHING
|
||||
|
||||
// a2 and a3 are always called with NULL lol
|
||||
#ifdef NONMATCHING // https://decomp.me/scratch/YCfKG
|
||||
@ -440,7 +546,7 @@ void AddSprite(struct unkSprite *a0, s32 a1, struct UnkSpriteMem *a2, struct unk
|
||||
spr->unk0 |= uVar1;
|
||||
|
||||
if (a2 != NULL)
|
||||
sub_80052BC(a2);
|
||||
RegisterSpriteParts_80052BC(a2);
|
||||
|
||||
a = &gUnknown_2025EA8[0];
|
||||
a += gSpriteCount;
|
||||
@ -534,7 +640,7 @@ void AddSprite(struct unkSprite *a0, s32 a1, struct UnkSpriteMem *a2, struct unk
|
||||
"\tmov r0, r8\n"
|
||||
"\tcmp r0, 0\n"
|
||||
"\tbeq _0800514E\n"
|
||||
"\tbl sub_80052BC\n"
|
||||
"\tbl RegisterSpriteParts_80052BC\n"
|
||||
"_0800514E:\n"
|
||||
"\tldr r0, _08005174\n"
|
||||
"\tldr r4, _08005178\n"
|
||||
@ -588,11 +694,11 @@ void CopySpritesToOam(void)
|
||||
{
|
||||
struct UnkSpriteLink *sLink;
|
||||
struct unkSprite *spr;
|
||||
volatile u16 *oam;
|
||||
vu16 *oam;
|
||||
s32 count;
|
||||
|
||||
sLink = &gUnknown_20256A0.sprites[0];
|
||||
oam = (u16 *)(OAM + OAM_SIZE); // End of OAM. Work backwards
|
||||
oam = (vu16 *)(OAM + OAM_SIZE); // End of OAM. Work backwards
|
||||
count = 0;
|
||||
|
||||
while (sLink != NULL && (u32)oam > (OAM + sizeof(struct OamData))) {
|
||||
@ -687,12 +793,12 @@ void BlinkSavingIcon(void)
|
||||
}
|
||||
|
||||
#ifdef NONMATCHING // https://decomp.me/scratch/taTIU
|
||||
extern u32 sub_80052BC_end[0] asm("gCharMemCursor");
|
||||
void sub_80052BC(struct UnkSpriteMem *a0)
|
||||
extern u32 RegisterSpriteParts_80052BC_end[0] asm("gCharMemCursor");
|
||||
void RegisterSpriteParts_80052BC(struct UnkSpriteMem *a0)
|
||||
{
|
||||
if (a0->byteCount) {
|
||||
struct unkStruct_20266B0 **r5 = &gUnknown_203B074;
|
||||
void *r6 = sub_80052BC_end;
|
||||
void *r6 = RegisterSpriteParts_80052BC_end;
|
||||
void **r4 = &gCharMemCursor;
|
||||
do {
|
||||
struct unkStruct_20266B0 *r2 = *r5;
|
||||
@ -709,7 +815,7 @@ void sub_80052BC(struct UnkSpriteMem *a0)
|
||||
}
|
||||
#else
|
||||
NAKED
|
||||
void sub_80052BC(struct UnkSpriteMem *a0)
|
||||
void RegisterSpriteParts_80052BC(struct UnkSpriteMem *a0)
|
||||
{
|
||||
asm_unified(
|
||||
"push {r4-r6,lr}\n"
|
||||
@ -761,4 +867,20 @@ void sub_8005304(void)
|
||||
else
|
||||
CpuClear(s->dest, s->byteCount);
|
||||
}
|
||||
}
|
||||
|
||||
// spriteMasks is a u16[6]. a4 might be a bool8
|
||||
void sub_800533C(struct ax_pose **a0, struct UnkSpriteMem **a1, struct axdata1 *a2, u16 *spriteMasks, char a4)
|
||||
{
|
||||
struct UnkSpriteMem *mem;
|
||||
struct ax_pose *r4;
|
||||
|
||||
r4 = a0[a2->poseId];
|
||||
gCharMemCursor = OBJ_VRAM0 + (a2->vramTileOrMaybeAnimTimer * 0x20);
|
||||
for (mem = NULL; (u16)r4->sprite != 0xFFFF || r4->unk2 != 0xFFFF; r4++, mem = NULL) {
|
||||
if (a4 != 0 && r4->sprite > -1)
|
||||
mem = a1[r4->sprite];
|
||||
|
||||
sub_8004EA8(r4, a2, mem, spriteMasks);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user