mirror of
https://github.com/pret/pmd-red.git
synced 2024-11-26 22:40:33 +00:00
Rename and doc SpriteOAM with defines
This commit is contained in:
parent
0225356d59
commit
1d49c480eb
@ -292,7 +292,12 @@ gUnknown_81076BC: @ 81076BC
|
||||
|
||||
.global gUnknown_81076C4
|
||||
gUnknown_81076C4: @ 81076C4
|
||||
.byte 0xfc, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff
|
||||
.4byte -4
|
||||
.4byte -8
|
||||
.4byte -16
|
||||
.4byte -4
|
||||
.4byte -8
|
||||
.4byte -16
|
||||
.string "pksdir0\0"
|
||||
|
||||
.global gIQSkillGroups
|
||||
|
@ -14,7 +14,7 @@ struct RescuePasswordMenu
|
||||
struct MenuStruct unk8[4];
|
||||
struct UnkTextStruct2 unk148[4];
|
||||
struct UnkTextStruct2 unk1A8[4];
|
||||
struct unkSprite unk208;
|
||||
struct SpriteOAM unk208;
|
||||
u32 unk210;
|
||||
};
|
||||
|
||||
|
@ -4,24 +4,13 @@
|
||||
#include "axdata.h"
|
||||
#include "ground_sprite.h"
|
||||
#include "position.h"
|
||||
|
||||
// size: 0x8
|
||||
struct unkSprite
|
||||
{
|
||||
// y/affineMode/objMode/mosaic/bpp/shape
|
||||
u16 unk0;
|
||||
// x/matrixNum/size
|
||||
u16 unk2;
|
||||
// tileNum/priority/paletteNum
|
||||
u16 unk4;
|
||||
u16 unk6;
|
||||
};
|
||||
#include "sprite_oam.h"
|
||||
|
||||
// size: 0x8
|
||||
struct UnkSpriteLink
|
||||
{
|
||||
struct UnkSpriteLink *unk0;
|
||||
struct unkSprite *unk4;
|
||||
struct SpriteOAM *unk4;
|
||||
};
|
||||
|
||||
// size: 0x808
|
||||
@ -92,7 +81,7 @@ struct Dungeon_Sub17B44
|
||||
struct Dungeon_Sub17B44_Sub4 *unk4;
|
||||
};
|
||||
|
||||
void AddSprite(struct unkSprite *, s32, struct UnkSpriteMem *, struct unkStruct_2039DB0 *);
|
||||
void AddSprite(struct SpriteOAM *, s32, struct UnkSpriteMem *, struct unkStruct_2039DB0 *);
|
||||
void BlinkSavingIcon(void);
|
||||
void CopySpritesToOam(void);
|
||||
void InitSprites(void);
|
||||
|
92
include/sprite_oam.h
Normal file
92
include/sprite_oam.h
Normal file
@ -0,0 +1,92 @@
|
||||
#ifndef GUARD_SPRITE_OAM_H
|
||||
#define GUARD_SPRITE_OAM_H
|
||||
|
||||
// size: 0x8. Similar to struct OamData but unk6 is not copied to OAM
|
||||
struct SpriteOAM
|
||||
{
|
||||
// y:8 affineMode1:1 affineMode2:1 objMode:2 mosaic:1 bpp:1 shape:2
|
||||
/* 0x0 */ u16 atrib1;
|
||||
// x:9 matrixNum:5 size:2
|
||||
/* 0x2 */ u16 atrib2;
|
||||
// tileNum:10 priority:2 paletteNum:4
|
||||
/* 0x4 */ u16 atrib3;
|
||||
// unk6_0:1 unk6_1:1 unk6_2:2? unk6_4:12
|
||||
u16 unk6;
|
||||
};
|
||||
|
||||
// The SpriteOAM struct is handled with macros most likely.
|
||||
// Most funcs that deal with it look the same and do some weird bit manipulations one by one on the attributes.
|
||||
|
||||
// atrib1
|
||||
|
||||
#define SPRITEOAM_MAX_Y 0xFF
|
||||
#define SPRITEOAM_SHIFT_Y 0
|
||||
#define SPRITEOAM_MASK_Y (SPRITEOAM_MAX_Y << SPRITEOAM_SHIFT_Y)
|
||||
|
||||
#define SPRITEOAM_MAX_AFFINEMODE1 1
|
||||
#define SPRITEOAM_SHIFT_AFFINEMODE1 8
|
||||
#define SPRITEOAM_MASK_AFFINEMODE1 (SPRITEOAM_MAX_AFFINEMODE1 << SPRITEOAM_SHIFT_AFFINEMODE1)
|
||||
|
||||
#define SPRITEOAM_MAX_AFFINEMODE2 1
|
||||
#define SPRITEOAM_SHIFT_AFFINEMODE2 9
|
||||
#define SPRITEOAM_MASK_AFFINEMODE2 (SPRITEOAM_MAX_AFFINEMODE2 << SPRITEOAM_SHIFT_AFFINEMODE2)
|
||||
|
||||
#define SPRITEOAM_MAX_OBJMODE 3
|
||||
#define SPRITEOAM_SHIFT_OBJMODE 10
|
||||
#define SPRITEOAM_MASK_OBJMODE (SPRITEOAM_MAX_OBJMODE << SPRITEOAM_SHIFT_OBJMODE)
|
||||
|
||||
#define SPRITEOAM_MAX_MOSAIC 1
|
||||
#define SPRITEOAM_SHIFT_MOSAIC 12
|
||||
#define SPRITEOAM_MASK_MOSAIC (SPRITEOAM_MAX_MOSAIC << SPRITEOAM_SHIFT_MOSAIC)
|
||||
|
||||
#define SPRITEOAM_MAX_BPP 1
|
||||
#define SPRITEOAM_SHIFT_BPP 13
|
||||
#define SPRITEOAM_MASK_BPP (SPRITEOAM_MAX_BPP << SPRITEOAM_SHIFT_BPP)
|
||||
|
||||
#define SPRITEOAM_MAX_SHAPE 3
|
||||
#define SPRITEOAM_SHIFT_SHAPE 14
|
||||
#define SPRITEOAM_MASK_SHAPE (SPRITEOAM_MAX_SHAPE << SPRITEOAM_SHIFT_SHAPE)
|
||||
|
||||
// atrib2
|
||||
|
||||
#define SPRITEOAM_MAX_X 0x1FF
|
||||
#define SPRITEOAM_SHIFT_X 0
|
||||
#define SPRITEOAM_MASK_X (SPRITEOAM_MAX_X << SPRITEOAM_SHIFT_X)
|
||||
|
||||
#define SPRITEOAM_MAX_MATRIXNUM 0x1F
|
||||
#define SPRITEOAM_SHIFT_MATRIXNUM 9
|
||||
#define SPRITEOAM_MASK_MATRIXNUM (SPRITEOAM_MAX_MATRIXNUM << SPRITEOAM_SHIFT_MATRIXNUM)
|
||||
|
||||
#define SPRITEOAM_MAX_SIZE 3
|
||||
#define SPRITEOAM_SHIFT_SIZE 12
|
||||
#define SPRITEOAM_MASK_SIZE (SPRITEOAM_MAX_SIZE << SPRITEOAM_SHIFT_SIZE)
|
||||
|
||||
// atrib3
|
||||
|
||||
#define SPRITEOAM_MAX_TILENUM 0x3FF
|
||||
#define SPRITEOAM_SHIFT_TILENUM 0
|
||||
#define SPRITEOAM_MASK_TILENUM (SPRITEOAM_MAX_TILENUM << SPRITEOAM_SHIFT_TILENUM)
|
||||
|
||||
#define SPRITEOAM_MAX_PRIORITY 3
|
||||
#define SPRITEOAM_SHIFT_PRIORITY 10
|
||||
#define SPRITEOAM_MASK_PRIORITY (SPRITEOAM_MAX_PRIORITY << SPRITEOAM_SHIFT_PRIORITY)
|
||||
|
||||
#define SPRITEOAM_MAX_PALETTENUM 0xF
|
||||
#define SPRITEOAM_SHIFT_PALETTENUM 12
|
||||
#define SPRITEOAM_MASK_PALETTENUM (SPRITEOAM_MAX_PALETTENUM << SPRITEOAM_SHIFT_PALETTENUM)
|
||||
|
||||
// unk6
|
||||
|
||||
#define SPRITEOAM_MAX_UNK6_0 1
|
||||
#define SPRITEOAM_SHIFT_UNK6_0 0
|
||||
#define SPRITEOAM_MASK_UNK6_0 (SPRITEOAM_MAX_UNK6_0 << SPRITEOAM_SHIFT_UNK6_0)
|
||||
|
||||
#define SPRITEOAM_MAX_UNK6_1 1
|
||||
#define SPRITEOAM_SHIFT_UNK6_1 1
|
||||
#define SPRITEOAM_MASK_UNK6_1 (SPRITEOAM_MAX_UNK6_1 << SPRITEOAM_SHIFT_UNK6_1)
|
||||
|
||||
#define SPRITEOAM_MAX_UNK6_4 0xFFF
|
||||
#define SPRITEOAM_SHIFT_UNK6_4 4
|
||||
#define SPRITEOAM_MASK_UNK6_4 (SPRITEOAM_MAX_UNK6_4 << SPRITEOAM_SHIFT_UNK6_4)
|
||||
|
||||
#endif // GUARD_SPRITE_OAM_H
|
@ -19,7 +19,7 @@ struct unkStruct_203B35C
|
||||
u32 unk0;
|
||||
u32 linkStatus;
|
||||
u32 state;
|
||||
struct unkSprite unkC;
|
||||
struct SpriteOAM unkC;
|
||||
u32 unk14;
|
||||
u8 fill18[0x1C - 0x18];
|
||||
struct MenuStruct unk1C[4];
|
||||
@ -782,57 +782,67 @@ void sub_80376CC(void)
|
||||
#endif
|
||||
u32 r1;
|
||||
u32 r4;
|
||||
|
||||
|
||||
r1 = gUnknown_203B35C->unkC.unk0;
|
||||
r0 = 0xfeff;
|
||||
r1 = gUnknown_203B35C->unkC.atrib1;
|
||||
r0 = (u16)~SPRITEOAM_MASK_AFFINEMODE1;
|
||||
r0 &= r1;
|
||||
r0 &= 0xfdff;
|
||||
r0 &= 0xf3ff;
|
||||
r0 &= 0xefff;
|
||||
r0 &= 0xdfff;
|
||||
r2 = 0x4000;
|
||||
r0 &= 0x3fff;
|
||||
r0 |= r2;
|
||||
gUnknown_203B35C->unkC.unk0 = r0;
|
||||
|
||||
r2 = 0x3F0;
|
||||
r1 = gUnknown_203B35C->unkC.unk4;
|
||||
r0 = 0xFC00;
|
||||
r0 &= (u16)~SPRITEOAM_MASK_AFFINEMODE2;
|
||||
|
||||
r0 &= (u16)~SPRITEOAM_MASK_OBJMODE;
|
||||
|
||||
r0 &= (u16)~SPRITEOAM_MASK_MOSAIC;
|
||||
|
||||
r0 &= (u16)~SPRITEOAM_MASK_BPP;
|
||||
|
||||
r2 = 1 << SPRITEOAM_SHIFT_SHAPE;
|
||||
r0 &= (u16)~SPRITEOAM_MASK_SHAPE;
|
||||
r0 |= r2;
|
||||
|
||||
gUnknown_203B35C->unkC.atrib1 = r0;
|
||||
|
||||
r2 = 0x3F0 << SPRITEOAM_SHIFT_TILENUM;
|
||||
r1 = gUnknown_203B35C->unkC.atrib3;
|
||||
r0 = (u16)~SPRITEOAM_MASK_TILENUM;
|
||||
r0 &= r1;
|
||||
r0 |= r2;
|
||||
r0 &= 0xf3ff;
|
||||
r2 = 0xF;
|
||||
r4 = 0xF000;
|
||||
r0 &= 0xfff;
|
||||
|
||||
r0 &= (u16)~SPRITEOAM_MASK_PRIORITY;
|
||||
|
||||
r2 = (u16)~SPRITEOAM_MASK_UNK6_4;
|
||||
|
||||
r4 = 15 << SPRITEOAM_SHIFT_PALETTENUM;
|
||||
r0 &= (u16)~SPRITEOAM_MASK_PALETTENUM;
|
||||
r0 |= r4;
|
||||
|
||||
gUnknown_203B35C->unkC.unk4 = r0;
|
||||
r0 = 0;
|
||||
gUnknown_203B35C->unkC.unk2 = r0;
|
||||
gUnknown_203B35C->unkC.atrib3 = r0;
|
||||
|
||||
r1 = 0xC00;
|
||||
r0 = 0; // Set x/matrixNum/size to 0
|
||||
gUnknown_203B35C->unkC.atrib2 = r0;
|
||||
|
||||
r1 = 192 << SPRITEOAM_SHIFT_UNK6_4;
|
||||
r0 = gUnknown_203B35C->unkC.unk6;
|
||||
r2 &= r0;
|
||||
r2 |= r1;
|
||||
gUnknown_203B35C->unkC.unk6 = r2;
|
||||
|
||||
}
|
||||
|
||||
void sub_8037748(void)
|
||||
{
|
||||
u32 temp2;
|
||||
u16 temp2;
|
||||
|
||||
gUnknown_203B35C->unkC.unk2 = (gUnknown_203B35C->unkC.unk2 & 0xfe00) | 0x70;
|
||||
gUnknown_203B35C->unkC.atrib2 &= ~SPRITEOAM_MASK_X; // Clear x
|
||||
gUnknown_203B35C->unkC.atrib2 |= 112; // Set x to 112
|
||||
|
||||
temp2 = 0x680;
|
||||
gUnknown_203B35C->unkC.unk6 = (gUnknown_203B35C->unkC.unk6 & 0xf) | temp2;
|
||||
temp2 = 104 << SPRITEOAM_SHIFT_UNK6_4;
|
||||
gUnknown_203B35C->unkC.unk6 &= ~SPRITEOAM_MASK_UNK6_4;
|
||||
gUnknown_203B35C->unkC.unk6 |= temp2;
|
||||
|
||||
if ((gUnknown_203B35C->unk14 & 8) != 0) {
|
||||
AddSprite(&gUnknown_203B35C->unkC, 0x100, NULL, NULL);
|
||||
}
|
||||
xxx_draw_string_80144C4();
|
||||
gUnknown_203B35C->unk14++;
|
||||
if ((gUnknown_203B35C->unk14 & 8) != 0)
|
||||
AddSprite(&gUnknown_203B35C->unkC, 0x100, NULL, NULL);
|
||||
|
||||
xxx_draw_string_80144C4();
|
||||
gUnknown_203B35C->unk14++;
|
||||
}
|
||||
|
||||
u32 sub_8037798(void)
|
||||
|
@ -28,9 +28,9 @@ struct unkStruct_808E9EC
|
||||
u8 unk12;
|
||||
u8 unk13;
|
||||
};
|
||||
extern u32 gUnknown_81076C4[];
|
||||
extern s32 gUnknown_81076C4[6]; // x-coord positioning for shadow sprites
|
||||
|
||||
extern struct unkSprite gUnknown_202F3E8[3]; // Shadow sprites of some kind
|
||||
extern struct SpriteOAM gUnknown_202F3E8[3]; // Shadow sprites of some kind
|
||||
extern s16 gUnknown_810AC60; // 0xC
|
||||
extern s16 gUnknown_810AC62; // 0xC
|
||||
extern s16 gUnknown_810AC68; // 0x8
|
||||
@ -55,29 +55,30 @@ extern void sub_809447C(struct unkStruct_8094924*, void*);
|
||||
extern void sub_808F428(struct unkStruct_8094924*, struct unkStruct_808E6F4*);
|
||||
|
||||
|
||||
bool8 sub_808E668(s16 a1, s16* a2, s16* a3)
|
||||
bool8 sub_808E668(s16 species, s16* a2, s16* a3)
|
||||
{
|
||||
u32 shifted = a1 << 16;
|
||||
if (species != MONSTER_DIGLETT && species != MONSTER_DUGTRIO) {
|
||||
u8 shadowSize = GetShadowSize(species);
|
||||
u32 x, unk6;
|
||||
struct SpriteOAM* spr;
|
||||
|
||||
if (((shifted - 0x320000) >> 16) > 1) {
|
||||
u8 shadowSize = GetShadowSize(a1);
|
||||
u32 unk2, unk6;
|
||||
struct unkSprite* arg0;
|
||||
|
||||
unk2 = a2[0] + a3[8];
|
||||
x = a2[0] + a3[8];
|
||||
unk6 = a2[1] + a3[9];
|
||||
unk2 += gUnknown_81076C4[shadowSize];
|
||||
x += gUnknown_81076C4[shadowSize];
|
||||
unk6 -= 4;
|
||||
unk2 &= 0x1ff;
|
||||
x &= SPRITEOAM_MAX_X;
|
||||
|
||||
arg0 = &gUnknown_202F3E8[shadowSize];
|
||||
arg0->unk2 = (arg0->unk2 & 0xfe00) | unk2;
|
||||
unk6 &= 0xfff;
|
||||
unk6 <<= 4;
|
||||
arg0->unk6 = (arg0->unk6 & 0xf) | unk6;
|
||||
AddSprite(arg0, 0, NULL, NULL);
|
||||
spr = &gUnknown_202F3E8[shadowSize];
|
||||
spr->atrib2 &= ~SPRITEOAM_MASK_X;
|
||||
spr->atrib2 |= x;
|
||||
unk6 &= SPRITEOAM_MAX_UNK6_4;
|
||||
unk6 <<= SPRITEOAM_SHIFT_UNK6_4;
|
||||
spr->unk6 &= ~SPRITEOAM_MASK_UNK6_4;
|
||||
spr->unk6 |= unk6;
|
||||
AddSprite(spr, 0, NULL, NULL);
|
||||
}
|
||||
return 1;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -692,39 +692,43 @@ void sub_8039174(void)
|
||||
#else
|
||||
u32 r2; // r4 but should be r2
|
||||
#endif //NONMATCHING
|
||||
struct unkSprite* spr; // r2 but should be r3
|
||||
struct SpriteOAM* spr; // r2 but should be r3
|
||||
u16 r4; // r3 but should be r4
|
||||
|
||||
|
||||
spr = &gRescuePasswordMenu->unk208;
|
||||
|
||||
spr->unk0 &= ~0x100;
|
||||
spr->unk0 &= ~0x200;
|
||||
r4 = ~(0x800 | 0x400);
|
||||
spr->unk0 &= r4;
|
||||
spr->unk0 &= ~0x1000;
|
||||
spr->unk0 &= ~0x2000;
|
||||
r2 = 0x4000;
|
||||
temp = 0x8000;
|
||||
temp = ~(temp | 0x4000);
|
||||
spr->unk0 &= temp;
|
||||
spr->unk0 |= r2;
|
||||
spr->atrib1 &= ~SPRITEOAM_MASK_AFFINEMODE1;
|
||||
|
||||
r2 = 0x200 | 0x100 | 0x80 | 0x40 | 0x20 | 0x10;
|
||||
spr->unk4 &= ~(0x200 | 0x100 | 0x80 | 0x40 | 0x20 | 0x10 | 0x8 | 0x4 | 0x2 | 0x1);
|
||||
spr->unk4 |= r2;
|
||||
spr->unk4 &= r4;
|
||||
r2 = 0x1 | 0x2 | 0x4 | 0x8;
|
||||
r4 = 0x1000 | 0x2000 | 0x4000 | 0x8000;
|
||||
temp = ~r4;
|
||||
spr->unk4 &= temp;
|
||||
spr->unk4 |= r4;
|
||||
spr->atrib1 &= ~SPRITEOAM_MASK_AFFINEMODE2;
|
||||
|
||||
spr->atrib1 &= ~SPRITEOAM_MASK_OBJMODE;
|
||||
|
||||
spr->atrib1 &= ~SPRITEOAM_MASK_MOSAIC;
|
||||
|
||||
spr->atrib1 &= ~SPRITEOAM_MASK_BPP;
|
||||
|
||||
r2 = 1 << SPRITEOAM_SHIFT_SHAPE;
|
||||
spr->atrib1 &= ~SPRITEOAM_MASK_SHAPE;
|
||||
spr->atrib1 |= r2;
|
||||
|
||||
r2 = 0x3F0 << SPRITEOAM_SHIFT_TILENUM;
|
||||
spr->atrib3 &= ~SPRITEOAM_MASK_TILENUM;
|
||||
spr->atrib3 |= r2;
|
||||
|
||||
spr->atrib3 &= ~SPRITEOAM_MASK_PRIORITY;
|
||||
|
||||
r2 = (u16)~SPRITEOAM_MASK_UNK6_4;
|
||||
|
||||
r4 = 15 << SPRITEOAM_SHIFT_PALETTENUM;
|
||||
spr->atrib3 &= ~SPRITEOAM_MASK_PALETTENUM;
|
||||
spr->atrib3 |= r4;
|
||||
|
||||
#ifndef NONMATCHING
|
||||
while (0) ;
|
||||
#endif //NONMATCHING
|
||||
spr->unk2 = 0; // Without the while(0), this 0 is loaded super early and also into r3
|
||||
spr->atrib2 = 0; // Without the while(0), this 0 is loaded super early and also into r3
|
||||
|
||||
temp = 0x800 | 0x400;
|
||||
temp = 192 << SPRITEOAM_SHIFT_UNK6_4;
|
||||
r2 &= spr->unk6;
|
||||
r2 |= temp;
|
||||
spr->unk6 = r2;
|
||||
@ -732,22 +736,21 @@ void sub_8039174(void)
|
||||
|
||||
void sub_80391F8(void)
|
||||
{
|
||||
struct unkSprite *iVar2;
|
||||
u32 temp;
|
||||
u32 temp2;
|
||||
struct SpriteOAM *spr;
|
||||
u32 val;
|
||||
|
||||
iVar2 = &gRescuePasswordMenu->unk208;
|
||||
|
||||
temp = (iVar2->unk2 & 0xfe00);
|
||||
iVar2->unk2 = temp | 0x70;
|
||||
spr = &gRescuePasswordMenu->unk208;
|
||||
|
||||
temp2 = 0x700;
|
||||
temp = (iVar2->unk6 & 0xf);
|
||||
iVar2->unk6 = temp | temp2;
|
||||
spr->atrib2 &= ~SPRITEOAM_MASK_X;
|
||||
spr->atrib2 |= 112;
|
||||
|
||||
if ((gRescuePasswordMenu->unk210 & 8) != 0) {
|
||||
AddSprite(iVar2, 0x100, NULL, NULL);
|
||||
}
|
||||
xxx_draw_string_80144C4();
|
||||
gRescuePasswordMenu->unk210 += 1;
|
||||
val = 112 << SPRITEOAM_SHIFT_UNK6_4;
|
||||
spr->unk6 &= ~SPRITEOAM_MASK_UNK6_4;
|
||||
spr->unk6 |= val;
|
||||
|
||||
if (gRescuePasswordMenu->unk210 & 8)
|
||||
AddSprite(spr, 0x100, NULL, NULL);
|
||||
|
||||
xxx_draw_string_80144C4();
|
||||
gRescuePasswordMenu->unk210++;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ struct unkStruct_203B360
|
||||
u32 unk4;
|
||||
struct MenuStruct unk8[4];
|
||||
struct UnkTextStruct2 unk148[4];
|
||||
struct unkSprite unk1A8;
|
||||
struct SpriteOAM unk1A8;
|
||||
u32 unk1B0; // Sprite count?
|
||||
};
|
||||
|
||||
@ -286,50 +286,58 @@ void sub_8038830(void)
|
||||
u32 r1;
|
||||
u32 r4;
|
||||
u32 r5;
|
||||
struct unkSprite *sprite;
|
||||
|
||||
struct SpriteOAM *sprite;
|
||||
|
||||
r5 = 0;
|
||||
sprite = &gUnknown_203B364->unk1A8;
|
||||
|
||||
r1 = sprite->unk0;
|
||||
r0 = 0xfeff;
|
||||
r1 = sprite->atrib1;
|
||||
r0 = (u16)~SPRITEOAM_MASK_AFFINEMODE1;
|
||||
r0 &= r1;
|
||||
r0 &= 0xfdff;
|
||||
r0 &= 0xf3ff;
|
||||
r0 &= 0xefff;
|
||||
r0 &= 0xdfff;
|
||||
r2 = 0x4000;
|
||||
r0 &= 0x3fff;
|
||||
r0 |= r2;
|
||||
sprite->unk0 = r0;
|
||||
|
||||
r2 = 0x3F0;
|
||||
r1 = sprite->unk4;
|
||||
r0 = 0xFC00;
|
||||
r0 &= (u16)~SPRITEOAM_MASK_AFFINEMODE2;
|
||||
|
||||
r0 &= (u16)~SPRITEOAM_MASK_OBJMODE;
|
||||
|
||||
r0 &= (u16)~SPRITEOAM_MASK_MOSAIC;
|
||||
|
||||
r0 &= (u16)~SPRITEOAM_MASK_BPP;
|
||||
|
||||
r2 = 1 << SPRITEOAM_SHIFT_SHAPE;
|
||||
r0 &= (u16)~SPRITEOAM_MASK_SHAPE;
|
||||
r0 |= r2;
|
||||
sprite->atrib1 = r0;
|
||||
|
||||
r2 = 0x3F0 << SPRITEOAM_SHIFT_TILENUM;
|
||||
r1 = sprite->atrib3;
|
||||
r0 = (u16)~SPRITEOAM_MASK_TILENUM;
|
||||
r0 &= r1;
|
||||
r0 |= r2;
|
||||
r0 &= 0xf3ff;
|
||||
r2 = 0xF;
|
||||
r4 = 0xF000;
|
||||
r0 &= 0xfff;
|
||||
|
||||
r0 &= (u16)~SPRITEOAM_MASK_PRIORITY;
|
||||
|
||||
r2 = (u16)~SPRITEOAM_MASK_UNK6_4;
|
||||
|
||||
r4 = 15 << SPRITEOAM_SHIFT_PALETTENUM;
|
||||
r0 &= (u16)~SPRITEOAM_MASK_PALETTENUM;
|
||||
r0 |= r4;
|
||||
sprite->atrib3 = r0;
|
||||
|
||||
sprite->unk4 = r0;
|
||||
|
||||
sprite->unk2 = 0x70;
|
||||
sprite->atrib2 = 112; // Set x to 112. Set matrixNum/size to 0
|
||||
|
||||
r1 = 0x680;
|
||||
r1 = 104 << SPRITEOAM_SHIFT_UNK6_4;
|
||||
r2 &= sprite->unk6;
|
||||
r2 |= r1;
|
||||
sprite->unk6 = r2;
|
||||
|
||||
|
||||
gUnknown_203B364->unk1B0 = r5;
|
||||
ResetSprites(FALSE);
|
||||
}
|
||||
|
||||
void sub_80388C4(void) {
|
||||
if ((gUnknown_203B364->unk1B0 & 8) != 0) {
|
||||
AddSprite(&gUnknown_203B364->unk1A8, 0x100, NULL, NULL);
|
||||
}
|
||||
gUnknown_203B364->unk1B0++;
|
||||
void sub_80388C4(void)
|
||||
{
|
||||
if (gUnknown_203B364->unk1B0 & 8)
|
||||
AddSprite(&gUnknown_203B364->unk1A8, 0x100, NULL, NULL);
|
||||
|
||||
gUnknown_203B364->unk1B0++;
|
||||
}
|
||||
|
79
src/sprite.c
79
src/sprite.c
@ -3,14 +3,14 @@
|
||||
#include "random.h"
|
||||
#include "sprite.h"
|
||||
|
||||
extern u16 gUnknown_2025670;
|
||||
extern u16 gUnknown_2025670; // Number of sprites in OAM?
|
||||
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 struct SpriteOAM gUnknown_20262A8[128];
|
||||
extern s32 gSpriteCount; /* 20266A8 */
|
||||
extern struct unkStruct_20266B0 gUnknown_20266B0[160];
|
||||
extern void *gCharMemCursor; /* 2026E30 */
|
||||
@ -33,8 +33,8 @@ void ResetSprites(bool8 a0)
|
||||
s32 i;
|
||||
struct UnkSpriteLink *a;
|
||||
struct UnkSpriteLink *b;
|
||||
struct unkSprite *c;
|
||||
struct unkSprite *d;
|
||||
struct SpriteOAM *c;
|
||||
struct SpriteOAM *d;
|
||||
struct UnkSpriteLink *e;
|
||||
|
||||
gSpriteCount = 0;
|
||||
@ -155,7 +155,7 @@ void sub_8004EA8(struct ax_pose *a0, struct axdata1 *a1, struct UnkSpriteMem *a2
|
||||
u16 flags3;
|
||||
u16 unkA;
|
||||
} sp;
|
||||
struct unkSprite *sprite;
|
||||
struct SpriteOAM *sprite;
|
||||
u32 uVar9;
|
||||
s32 r7;
|
||||
|
||||
@ -185,15 +185,15 @@ void sub_8004EA8(struct ax_pose *a0, struct axdata1 *a1, struct UnkSpriteMem *a2
|
||||
r7 = 255;
|
||||
|
||||
if (spriteMasks == NULL) {
|
||||
sprite->unk0 = sp.flags1;
|
||||
sprite->unk2 = sp.flags2;
|
||||
sprite->unk4 = sp.flags3;
|
||||
sprite->atrib1 = sp.flags1;
|
||||
sprite->atrib2 = sp.flags2;
|
||||
sprite->atrib3 = 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->atrib1 = (spriteMasks[0] & sp.flags1) | spriteMasks[3];
|
||||
sprite->atrib2 = (spriteMasks[1] & sp.flags2) | spriteMasks[4];
|
||||
sprite->atrib3 = (spriteMasks[2] & sp.flags3) | spriteMasks[5];
|
||||
sprite->unk6 = sp.unkA;
|
||||
}
|
||||
|
||||
@ -201,14 +201,14 @@ void sub_8004EA8(struct ax_pose *a0, struct axdata1 *a1, struct UnkSpriteMem *a2
|
||||
tileNum = gUnknown_2025672[sp.unk2] & 0x3FF;
|
||||
}
|
||||
else {
|
||||
tileNum = (sprite->unk4 & 0x3FF) + a1->vramTileOrMaybeAnimTimer;
|
||||
tileNum = (sprite->atrib3 & 0x3FF) + a1->vramTileOrMaybeAnimTimer;
|
||||
tileNum &= 0x3FF;
|
||||
}
|
||||
|
||||
// Set tileNum, maintain priority/paletteNum
|
||||
sprite->unk4 = tileNum | (sprite->unk4 & 0xFC00);
|
||||
sprite->atrib3 = tileNum | (sprite->atrib3 & 0xFC00);
|
||||
|
||||
x = (sprite->unk2 & 0x1FF) - 256;
|
||||
x = (sprite->atrib2 & 0x1FF) - 256;
|
||||
x += a1->xPos;
|
||||
if (x < -64)
|
||||
return;
|
||||
@ -216,7 +216,7 @@ void sub_8004EA8(struct ax_pose *a0, struct axdata1 *a1, struct UnkSpriteMem *a2
|
||||
return;
|
||||
|
||||
// Set x, maintain matrixNum/size
|
||||
sprite->unk2 = (x & 0x1FF) | (sprite->unk2 & 0xFE00);
|
||||
sprite->atrib2 = (x & 0x1FF) | (sprite->atrib2 & 0xFE00);
|
||||
|
||||
uVar9 = sprite->unk6 << 16;
|
||||
earlyMask = 0xFFF;
|
||||
@ -229,14 +229,14 @@ void sub_8004EA8(struct ax_pose *a0, struct axdata1 *a1, struct UnkSpriteMem *a2
|
||||
return;
|
||||
|
||||
// Set y, maintain affineMode/objMode/mosaic/bpp/shape
|
||||
sprite->unk0 = (y & 0xFF) | (sprite->unk0 & 0xFF00);
|
||||
sprite->atrib1 = (y & 0xFF) | (sprite->atrib1 & 0xFF00);
|
||||
|
||||
// Set paletteNum, maintain tileNum/priority
|
||||
if (((uVar9 >> 17) & 1) == 0)
|
||||
sprite->unk4 = ((a1->paletteNum & 0xF) << 12) | (sprite->unk4 & earlyMask);
|
||||
sprite->atrib3 = ((a1->paletteNum & 0xF) << 12) | (sprite->atrib3 & earlyMask);
|
||||
|
||||
if (sp.unk2 != 0)
|
||||
sprite->unk4 = ((gUnknown_2025682[sp.unk2] & 0xF) << 12) | (sprite->unk4 & earlyMask);
|
||||
sprite->atrib3 = ((gUnknown_2025682[sp.unk2] & 0xF) << 12) | (sprite->atrib3 & earlyMask);
|
||||
|
||||
gUnknown_2025EA8[gSpriteCount].unk0 = gUnknown_20256A0.sprites[r7].unk0;
|
||||
gUnknown_20256A0.sprites[r7].unk0 = gUnknown_2025EA8 + gSpriteCount;
|
||||
@ -510,10 +510,10 @@ void sub_8004EA8(struct ax_pose *a0, struct axdata1 *a1, struct UnkSpriteMem *a2
|
||||
|
||||
// a2 and a3 are always called with NULL lol
|
||||
#ifdef NONMATCHING // https://decomp.me/scratch/YCfKG
|
||||
void AddSprite(struct unkSprite *a0, s32 a1, struct UnkSpriteMem *a2, struct unkStruct_2039DB0 *a3)
|
||||
void AddSprite(struct SpriteOAM *a0, s32 a1, struct UnkSpriteMem *a2, struct unkStruct_2039DB0 *a3)
|
||||
{
|
||||
s32 uVar1;
|
||||
struct unkSprite *spr;
|
||||
s32 yPos;
|
||||
struct SpriteOAM *spr;
|
||||
struct UnkSpriteLink *a;
|
||||
struct UnkSpriteLink *b;
|
||||
|
||||
@ -528,24 +528,23 @@ void AddSprite(struct unkSprite *a0, s32 a1, struct UnkSpriteMem *a2, struct unk
|
||||
a1 = 255;
|
||||
|
||||
if (a3 == NULL) {
|
||||
spr->unk0 = a0->unk0;
|
||||
spr->unk2 = a0->unk2;
|
||||
spr->unk4 = a0->unk4;
|
||||
spr->atrib1 = a0->atrib1;
|
||||
spr->atrib2 = a0->atrib2;
|
||||
spr->atrib3 = a0->atrib3;
|
||||
spr->unk6 = a0->unk6;
|
||||
}
|
||||
else {
|
||||
spr->unk0 = (a0->unk0 & a3->unk0) | a3->unk6;
|
||||
spr->unk2 = (a0->unk2 & a3->unk2) | a3->unk8;
|
||||
spr->unk4 = (a0->unk4 & a3->unk4) | a3->unkA;
|
||||
spr->atrib1 = (a0->atrib1 & a3->unk0) | a3->unk6;
|
||||
spr->atrib2 = (a0->atrib2 & a3->unk2) | a3->unk8;
|
||||
spr->atrib3 = (a0->atrib3 & a3->unk4) | a3->unkA;
|
||||
spr->unk6 = a0->unk6;
|
||||
}
|
||||
|
||||
uVar1 = spr->unk6 / 16;
|
||||
nullsub_3(uVar1, 0);
|
||||
// uVar1 is the Y position of the sprite, then the rest remains
|
||||
uVar1 &= 0xFF;
|
||||
spr->unk0 &= 0xFF00;
|
||||
spr->unk0 |= uVar1;
|
||||
yPos = spr->unk6 / 16;
|
||||
nullsub_3(yPos, 0);
|
||||
yPos &= SPRITEOAM_MAX_Y;
|
||||
spr->atrib1 &= ~SPRITEOAM_MASK_Y;
|
||||
spr->atrib1 |= yPos;
|
||||
|
||||
if (a2 != NULL)
|
||||
RegisterSpriteParts_80052BC(a2);
|
||||
@ -561,7 +560,7 @@ void AddSprite(struct unkSprite *a0, s32 a1, struct UnkSpriteMem *a2, struct unk
|
||||
}
|
||||
#else
|
||||
NAKED
|
||||
void AddSprite(struct unkSprite *a0, s32 a1, struct UnkSpriteMem *a2, struct unkStruct_2039DB0 *a3)
|
||||
void AddSprite(struct SpriteOAM *a0, s32 a1, struct UnkSpriteMem *a2, struct unkStruct_2039DB0 *a3)
|
||||
{
|
||||
asm_unified(
|
||||
"push {r4-r7,lr}\n"
|
||||
@ -695,7 +694,7 @@ void sub_8005180(void)
|
||||
void CopySpritesToOam(void)
|
||||
{
|
||||
struct UnkSpriteLink *sLink;
|
||||
struct unkSprite *spr;
|
||||
struct SpriteOAM *spr;
|
||||
vu16 *oam;
|
||||
s32 count;
|
||||
|
||||
@ -711,13 +710,13 @@ void CopySpritesToOam(void)
|
||||
// Skip affineParam
|
||||
oam -= 2;
|
||||
// Set tileNum/priority/paletteNum
|
||||
*oam = spr->unk4;
|
||||
*oam = spr->atrib3;
|
||||
// Set x/matrixNum/size
|
||||
oam--;
|
||||
*oam = spr->unk2;
|
||||
*oam = spr->atrib2;
|
||||
// Set y/affineMode/objMode/mosaic/bpp/shape
|
||||
oam--;
|
||||
*oam = spr->unk0;
|
||||
*oam = spr->atrib1;
|
||||
|
||||
count++;
|
||||
}
|
||||
@ -946,15 +945,13 @@ void sub_800545C(struct Entity_Sub28 *a0, struct Dungeon_Sub17B44_Sub4 *a1, u32
|
||||
void sub_80054BC(struct axPokemon *a0)
|
||||
{
|
||||
struct ax_anim *aData;
|
||||
s32 flag;
|
||||
s16 flag;
|
||||
|
||||
if (a0->axdata.flags & 0x2000)
|
||||
flag = 0;
|
||||
else
|
||||
flag = a0->axdata.flags >> 15;
|
||||
|
||||
flag++; flag--;
|
||||
|
||||
if (flag == 0)
|
||||
return;
|
||||
|
||||
|
@ -15,7 +15,7 @@ struct unkStruct_203B360
|
||||
u32 unk4; // state
|
||||
struct MenuStruct unk8[4];
|
||||
struct UnkTextStruct2 unk148[4];
|
||||
struct unkSprite unk1A8;
|
||||
struct SpriteOAM unk1A8;
|
||||
u32 unk1B0; // sprite count?
|
||||
};
|
||||
|
||||
@ -135,43 +135,52 @@ void sub_8038440(void)
|
||||
u32 r1;
|
||||
u32 r4;
|
||||
u32 r5;
|
||||
struct unkSprite *sprite;
|
||||
|
||||
struct SpriteOAM *sprite;
|
||||
|
||||
r5 = 0;
|
||||
sprite = &gUnknown_203B360->unk1A8;
|
||||
|
||||
r1 = sprite->unk0;
|
||||
r0 = 0xfeff;
|
||||
r1 = sprite->atrib1;
|
||||
r0 = (u16)~SPRITEOAM_MASK_AFFINEMODE1;
|
||||
r0 &= r1;
|
||||
r0 &= 0xfdff;
|
||||
r0 &= 0xf3ff;
|
||||
r0 &= 0xefff;
|
||||
r0 &= 0xdfff;
|
||||
r2 = 0x4000;
|
||||
r0 &= 0x3fff;
|
||||
r0 |= r2;
|
||||
sprite->unk0 = r0;
|
||||
|
||||
r2 = 0x3F0;
|
||||
r1 = sprite->unk4;
|
||||
r0 = 0xFC00;
|
||||
r0 &= (u16)~SPRITEOAM_MASK_AFFINEMODE2;
|
||||
|
||||
r0 &= (u16)~SPRITEOAM_MASK_OBJMODE;
|
||||
|
||||
r0 &= (u16)~SPRITEOAM_MASK_MOSAIC;
|
||||
|
||||
r0 &= (u16)~SPRITEOAM_MASK_BPP;
|
||||
|
||||
r2 = 1 << SPRITEOAM_SHIFT_SHAPE;
|
||||
r0 &= (u16)~SPRITEOAM_MASK_SHAPE;
|
||||
r0 |= r2;
|
||||
|
||||
sprite->atrib1 = r0;
|
||||
|
||||
r2 = 0x3F0 << SPRITEOAM_SHIFT_TILENUM;
|
||||
r1 = sprite->atrib3;
|
||||
r0 = (u16)~SPRITEOAM_MASK_TILENUM;
|
||||
r0 &= r1;
|
||||
r0 |= r2;
|
||||
r0 &= 0xf3ff;
|
||||
r2 = 0xF;
|
||||
r4 = 0xF000;
|
||||
r0 &= 0xfff;
|
||||
|
||||
r0 &= (u16)~SPRITEOAM_MASK_PRIORITY;
|
||||
|
||||
r2 = (u16)~SPRITEOAM_MASK_UNK6_4;
|
||||
|
||||
r4 = 15 << SPRITEOAM_SHIFT_PALETTENUM;
|
||||
r0 &= (u16)~SPRITEOAM_MASK_PALETTENUM;
|
||||
r0 |= r4;
|
||||
|
||||
sprite->unk4 = r0;
|
||||
|
||||
sprite->unk2 = 0x70;
|
||||
|
||||
r1 = 0x700;
|
||||
sprite->atrib3 = r0;
|
||||
|
||||
sprite->atrib2 = 112; // Set x to 112. Set matrixNum/size to 0
|
||||
|
||||
r1 = 112 << SPRITEOAM_SHIFT_UNK6_4;
|
||||
r2 &= sprite->unk6;
|
||||
r2 |= r1;
|
||||
sprite->unk6 = r2;
|
||||
|
||||
|
||||
gUnknown_203B360->unk1B0 = r5;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user