Skip to content

Commit

Permalink
Match last vram.c function. (#645)
Browse files Browse the repository at this point in the history
* Nuke sub_080AE218.inc

* Match last vram.c function

* Minor coding blip
  • Loading branch information
KEKW555 committed Dec 10, 2023
1 parent 5cb7b79 commit dbdb121
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 139 deletions.
138 changes: 0 additions & 138 deletions asm/non_matching/vram/sub_080AE218.inc

This file was deleted.

50 changes: 49 additions & 1 deletion src/vram.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "common.h"
#include "structures.h"
#include "fileselect.h"
#include "new_player.h"

extern u32 gFixedTypeGfxData[];

Expand Down Expand Up @@ -352,7 +353,54 @@ void CleanUpGFXSlots(void) {
}

// Swap gfx
ASM_FUNC("asm/non_matching/vram/sub_080AE218.inc", void sub_080AE218(u32 a, u32 b))
void sub_080AE218(u32 param1, u32 param2) {
struct_gUnk_020000C0_1* psVar6;
u32 r0, r1, r3, r7, r12;
u32 index1, index2;

r12 = (param2 << 4) + 0x140;
r3 = (param1 << 4) + 0x140;
r7 = r3 + ((u32)gGFXSlots.slots[param1].slotCount << 4);

for (index1 = 0; index1 < 0x50; index1++) {
Entity* ent = &(&gPlayerEntity)[index1];
if (ent->next != NULL) {
if (param1 == ent->spriteAnimation[0]) {
ent->spriteAnimation[0] = param2;
}
r0 = ent->spriteVramOffset;
if ((r3 <= r0) && (r7 > r0)) {
r0 = (r0 - r3);
r1 = r0 + r12;
ent->spriteVramOffset = r1;
}
}
}

for (index2 = 0; index2 < ARRAY_COUNT(gUnk_020000C0); index2++) {
for (index1 = 0; index1 < 4; index1++) {
psVar6 = gUnk_020000C0[index2].unk_00 + index1;
if ((((*(u8*)&psVar6->unk_00) & 1) != 0) && (((*(u8*)&psVar6->unk_00) & 2) == 0)) {
r1 = psVar6->unk_08.HALF_U.HI;
if ((r3 <= r1) && (r7 > r1)) {
r0 = (r1 - r3);
r1 = r0 + r12;
psVar6->unk_08.HALF_U.HI = r1;
}
}
}
}

for (index1 = 0; index1 < 0x80; index1++) {
r1 = gOAMControls.oam[index1].tileNum;
if ((r3 <= r1) && (r7 > r1)) {
r0 = (r1 - r3);
r1 = r0 + r12;
gOAMControls.oam[index1].tileNum = r1;
gOAMControls.field_0x0 = 1;
}
}
}

void MoveGFXSlots(u32 srcIndex, u32 targetIndex) {
s32 index;
Expand Down

0 comments on commit dbdb121

Please sign in to comment.