Correctly split effect files

This commit is contained in:
DizzyEggg 2025-07-09 16:16:24 +02:00
parent fad317fd6a
commit e598c8630a
12 changed files with 114 additions and 155 deletions

View File

@ -1,10 +0,0 @@
.section .rodata
.align 2,0
.string "pksdir0\0"
.string "pksdir0\0"

View File

@ -3,7 +3,7 @@
#include "structs/sprite_oam.h"
#include "structs/str_position.h"
#include "structs/code_800E9E4.h"
#include "code_800E9E4.h"
typedef struct unkStruct_80416E0
{
@ -17,6 +17,12 @@ typedef struct unkStruct_80416E0
unkStruct_2039DB0 spriteMasks;
} unkStruct_80416E0;
typedef struct unkStruct_800EA44
{
s16 unk0;
s16 unk2;
} unkStruct_800EA44;
struct UnkStruct_8040094
{
u16 unk0;

View File

@ -1,8 +1,6 @@
#ifndef GUARD_CODE_800E9E4_H
#define GUARD_CODE_800E9E4_H
#include "structs/code_800E9E4.h"
typedef struct unkStruct_80B9CC4
{
// size: 0x24
@ -37,6 +35,15 @@ typedef struct unkStruct_80BDBC4
s32 unk20; // Index into gUnknown_80C183C
} unkStruct_80BDBC4;
typedef struct unkStruct_80C183C
{
// size: 0xc
s16 unk0;
s16 unk2;
s32 unk4;
s32 unk8;
} unkStruct_80C183C;
const unkStruct_80B9CC4 *sub_800ECA4(s32 param_1);
const unkStruct_80BDBC4 *sub_800ECB8(u16 param_1);
const unkStruct_80C183C *sub_800ECD0(s32 param_1);

View File

@ -0,0 +1,9 @@
#ifndef GUARD_EFFECT_ANIM_FILE_H
#define GUARD_EFFECT_ANIM_FILE_H
#include "structs/str_file_system.h"
OpenedFile *OpenEffectFile(u32 animType, s32 effectID);
void CloseEffectFile(OpenedFile *file);
#endif // GUARD_EFFECT_ANIM_FILE_H

View File

@ -1,32 +0,0 @@
#ifndef GUARD_STRUCTS_CODE_800E9E4_H
#define GUARD_STRUCTS_CODE_800E9E4_H
typedef struct unkStruct_80B9C60
{
s32 unk0;
s32 unk1;
s32 unk2;
} unkStruct_80B9C60;
typedef struct unkStruct_80CE37C
{
s16 unk0;
s16 unk2;
} unkStruct_80CE37C;
typedef struct unkStruct_80C183C
{
// size: 0xc
s16 unk0;
s16 unk2;
s32 unk4;
s32 unk8;
} unkStruct_80C183C;
typedef struct unkStruct_800EA44
{
s16 unk0;
s16 unk2;
} unkStruct_800EA44;
#endif

View File

@ -85,6 +85,7 @@ SECTIONS {
src/code_800E9E4.o(.text);
src/code_800ED38.o(.text);
src/code_800F034.o(.text);
src/effect_anim_file.o(.text);
src/dungeon_pokemon_sprites.o(.text);
src/friend_areas_map.o(.text);
src/world_map.o(.text);
@ -453,8 +454,9 @@ SECTIONS {
data/data_80B9BB0.o(.rodata);
src/code_800DAC0.o(.rodata)
src/code_800E9E4.o(.rodata)
data/data_80B9BB8_2.o(.rodata);
src/code_800ED38.o(.rodata)
src/code_800F034.o(.rodata);
src/effect_anim_file.o(.rodata);
src/dungeon_pokemon_sprites.o(.rodata);
src/friend_areas_map.o(.rodata);
src/world_map.o(.rodata);

View File

@ -15,7 +15,7 @@
#include "cpu.h"
#include "code_800E9E4.h"
#include "graphics_memory.h"
#include "structs/code_800E9E4.h"
#include "effect_anim_file.h"
struct unkStruct_203B0CC_x94
{
@ -79,7 +79,6 @@ extern s16 gUnknown_2026E4E;
extern void sub_8009BE4(void);
extern void sub_800F204(OpenedFile *file);
extern struct unkStruct_800F18C *sub_800F18C(s32);
extern void sub_800F034(void);
extern void sub_800ED38(u32);
@ -89,7 +88,6 @@ extern void sub_800ED80();
extern void sub_800F094();
extern void sub_809971C(u16 a0, const RGB *a1, int a2);
extern u32 sub_800F19C(s32);
extern OpenedFile *sub_800F1C0(u32 animType, s32 effectID);
extern void sub_800F15C(s32 effectID);
s32 sub_800E700(s32);
@ -222,7 +220,7 @@ static void sub_800DCA8(struct unkStruct_203B0CC_sub *param_1)
param_1->unk4 = -1;
param_1->unk54 = 0;
if (param_1->unkB8 != NULL) {
sub_800F204(param_1->unkB8);
CloseEffectFile(param_1->unkB8);
param_1->unkB8 = NULL;
}
}
@ -649,7 +647,7 @@ static s32 sub_800E208(s32 a0, unkStruct_80416E0 *a1)
return -1;
if (strPtr->animType == 1 && gUnknown_203B0CC->fileSelection != 0)
return -1;
ptr->unkB8 = sub_800F1C0(strPtr->animType, strPtr->effectId);
ptr->unkB8 = OpenEffectFile(strPtr->animType, strPtr->effectId);
if (ptr->unkB8 == NULL)
return -1;
ptr->unk0 = a0;

View File

@ -5226,6 +5226,12 @@ static const unkStruct_80C183C gUnknown_80C183C[4336] = {
};
// Array of indexes into gUnknown_80B9CC4. One pair of indexes per entry
typedef struct unkStruct_80CE37C
{
s16 unk0;
s16 unk2;
} unkStruct_80CE37C;
static const unkStruct_80CE37C gUnknown_80CE37C[240] = {
[0] = {.unk0 = 0, .unk2 = 8},
[1] = {.unk0 = 0, .unk2 = 8},

View File

@ -1,4 +1,5 @@
#include "global.h"
#include "globaldata.h"
#include "bg_control.h"
#include "structs/axdata.h"
#include "graphics_memory.h"
@ -12,6 +13,7 @@
#include "memory.h"
#include "sprite.h"
#include "text_2.h"
#include "effect_anim_file.h"
struct unkStruct_203B0D0_sub
{
@ -33,12 +35,9 @@ struct unkStruct_203B0D0 {
struct unkStruct_203B0D0_sub unk4[2];
};
EWRAM_INIT struct unkStruct_203B0D0 *gUnknown_203B0D0 = NULL;
EWRAM_INIT void *gUnknown_203B0D4 = NULL; // TODO: figure out the actual struct
static EWRAM_INIT struct unkStruct_203B0D0 *gUnknown_203B0D0 = NULL;
OpenedFile *sub_800F1C0(s32, s32);
s32 sub_800F0F4(s32, s32);
void sub_800F204(OpenedFile *file);
void sub_800F13C(s32, OpenedFile *, const unkStruct_80B9CC4 *);
void sub_800F15C(s32);
@ -46,8 +45,7 @@ extern void sub_809971C(u16 a0, const RGB *a1, int a2);
void sub_800ED38(s32 r0)
{
if(gUnknown_203B0D0 == 0)
{
if (gUnknown_203B0D0 == 0) {
gUnknown_203B0D0 = MemoryAlloc(sizeof(struct unkStruct_203B0D0), 0xB);
MemoryClear8(gUnknown_203B0D0, sizeof(struct unkStruct_203B0D0));
}
@ -56,22 +54,17 @@ void sub_800ED38(s32 r0)
void sub_800ED64(void)
{
if(gUnknown_203B0D0)
{
MemoryFree(gUnknown_203B0D0);
gUnknown_203B0D0 = NULL;
}
TRY_FREE_AND_SET_NULL(gUnknown_203B0D0);
}
void sub_800ED80(void)
{
s32 index;
struct unkStruct_203B0D0_sub *sub;
gUnknown_203B0D0->unk0 = 0;
for(index = 0; index < 2; index++)
{
sub = &gUnknown_203B0D0->unk4[index];
for (index = 0; index < 2; index++) {
struct unkStruct_203B0D0_sub *sub = &gUnknown_203B0D0->unk4[index];
sub->unk0 = 0;
sub->file = NULL;
sub->fileData = NULL;
@ -82,10 +75,8 @@ bool8 sub_800EDB0(struct unkStruct_203B0D0_sub *r0)
{
s32 index;
for(index = 0; index < 2; index++)
{
if(gUnknown_203B0D0->unk4[index].unk0 == 0)
{
for (index = 0; index < 2; index++) {
if (gUnknown_203B0D0->unk4[index].unk0 == 0) {
gUnknown_203B0D0->unk4[index] = *r0;
return TRUE;
}
@ -97,8 +88,7 @@ void sub_800EDF0(u32 r0, OpenedFile *file)
{
struct unkStruct_203B0D0_sub stack;
switch(r0)
{
switch (r0) {
case 0:
stack.unk0 = 3;
stack.unkC = 0xE;
@ -125,38 +115,29 @@ void sub_800EDF0(u32 r0, OpenedFile *file)
void sub_800EE5C(s32 r0)
{
const unkStruct_80B9CC4 *ret;
OpenedFile *file;
s32 ret2;
const unkStruct_80B9CC4 *ret = sub_800ECA4(r0);
ret = sub_800ECA4(r0);
if(r0 != 0)
{
switch (ret->animType - 1) {
case 1 - 1:
case 2 - 1:
if (r0 == 0)
return;
if (ret->animType == 1 || ret->animType == 2)
return;
file = OpenEffectFile(ret->animType, ret->effectId);
if (file != NULL) {
s32 ret2 = sub_800F0F4(ret->animType, ret->effectId);
if (ret2 == -1) {
CloseEffectFile(file);
return;
default:
file = sub_800F1C0(ret->animType, ret->effectId);
if(file)
{
ret2 = sub_800F0F4(ret->animType, ret->effectId);
if(ret2 == -1)
{
sub_800F204(file);
return;
}
else if(ret2 != -2)
{
sub_800F13C(ret2, file, ret);
sub_800EDF0(ret2, file);
}
else {
sub_800F204(file);
}
sub_800F15C(ret->effectId);
}
}
else if(ret2 != -2) {
sub_800F13C(ret2, file, ret);
sub_800EDF0(ret2, file);
}
else {
CloseEffectFile(file);
}
sub_800F15C(ret->effectId);
}
}
@ -189,15 +170,13 @@ void sub_800EF28(u8 r0)
sub_800EE5C(sub_800ECE4(r0));
}
void sub_800EF40(u8 r0, u8 r1)
void sub_800EF40(u8 r0, bool8 r1)
{
s32 ret;
if(r1)
{
if (r1) {
ret = sub_800ECF8(r0);
}
else
{
else {
ret = sub_800ED0C(r0);
}
sub_800EE5C(ret);
@ -213,13 +192,13 @@ void sub_800EF64(void)
continue;
sub = &gUnknown_203B0D0->unk4[i];
switch(sub->unk0) {
switch (sub->unk0) {
case 1:
case 2:
break;
case 3:
sub_8005674(sub->fileData, sub->unk18);
switch(gUnknown_203B0D0->unk0) {
switch (gUnknown_203B0D0->unk0) {
case 1: {
const RGB *pal = sub->fileData->pal;
sub_809971C((sub->unkC + 16) * 16, pal, 0x10);
@ -231,7 +210,7 @@ void sub_800EF64(void)
}
}
if(sub->file != 0) {
sub_800F204(sub->file);
CloseEffectFile(sub->file);
sub->file = NULL;
}
break;
@ -245,7 +224,7 @@ void sub_800EF64(void)
}
sub_8009A1C(sub->fileData, sub->unkC, sub->unk10, sub->unk14);
if(sub->file != NULL) {
sub_800F204(sub->file);
CloseEffectFile(sub->file);
sub->file = NULL;
}
break;

View File

@ -1,9 +1,8 @@
#include "global.h"
#include "globaldata.h"
#include "code_800E9E4.h"
#include "def_filearchives.h"
#include "file_system.h"
#include "memory.h"
#include "file_system.h"
struct unkStruct_800F18C
{
@ -16,18 +15,17 @@ struct unkStruct_203B0D4
struct unkStruct_800F18C unk0[2];
};
extern struct unkStruct_203B0D4 *gUnknown_203B0D4;
static EWRAM_INIT struct unkStruct_203B0D4 *gUnknown_203B0D4 = NULL;
void sub_800F034(void)
{
s32 index;
if(gUnknown_203B0D4 == NULL)
{
if (gUnknown_203B0D4 == NULL) {
gUnknown_203B0D4 = MemoryAlloc(sizeof(struct unkStruct_203B0D4), 0xB);
MemoryClear8(gUnknown_203B0D4, sizeof(struct unkStruct_203B0D4));
}
for(index = 0; index < 2; index++)
{
for(index = 0; index < 2; index++) {
gUnknown_203B0D4->unk0[index].effectID = -1;
gUnknown_203B0D4->unk0[index].counter = 0;
}
@ -35,24 +33,19 @@ void sub_800F034(void)
void sub_800F078(void)
{
if(gUnknown_203B0D4)
{
MemoryFree(gUnknown_203B0D4);
gUnknown_203B0D4 = NULL;
}
TRY_FREE_AND_SET_NULL(gUnknown_203B0D4);
}
void sub_800F094(void)
{
s32 index;
for(index = 0; index < 2; index++)
{
for (index = 0; index < 2; index++) {
gUnknown_203B0D4->unk0[index].effectID = -1;
gUnknown_203B0D4->unk0[index].counter = 0;
}
}
s32 sub_800F0C0(s32 animType, s32 effectID)
UNUSED static s32 sub_800F0C0(s32 animType, s32 effectID)
{
if (animType == 3) {
if (gUnknown_203B0D4->unk0[0].effectID == effectID) return 0;
@ -63,7 +56,6 @@ s32 sub_800F0C0(s32 animType, s32 effectID)
return -3;
}
s32 sub_800F0F4(s32 animType, s32 effectID)
{
if (animType == 3) {
@ -77,9 +69,9 @@ s32 sub_800F0F4(s32 animType, s32 effectID)
return -1;
}
void sub_800F13C(s32 index, OpenedFile *file, unkStruct_80B9CC4 * r2)
void sub_800F13C(s32 index, OpenedFile *file, unkStruct_80B9CC4 *r2)
{
if(gUnknown_203B0D4->unk0[index].counter == 0)
if (gUnknown_203B0D4->unk0[index].counter == 0)
gUnknown_203B0D4->unk0[index].effectID = r2->effectId;
}
@ -87,10 +79,8 @@ void sub_800F15C(s32 effectID)
{
s32 index;
for(index = 0; index < 2; index++)
{
if(gUnknown_203B0D4->unk0[index].effectID == effectID)
{
for (index = 0; index < 2; index++) {
if( gUnknown_203B0D4->unk0[index].effectID == effectID) {
gUnknown_203B0D4->unk0[index].counter++;
break;
}
@ -110,27 +100,3 @@ s32 sub_800F19C(s32 index)
return 1;
}
OpenedFile * sub_800F1C0(u32 animType, s32 effectID)
{
u8 fileName [8];
switch(animType)
{
case 1:
case 2:
case 3:
sprintf(fileName,"efob%03d",effectID);
break;
case 4:
sprintf(fileName,"efbg%03d",effectID);
break;
}
return Call_OpenFileAndGetFileDataPtr(fileName,&gEffectFileArchive);
}
void sub_800F204(OpenedFile *file)
{
CloseFile(file);
}

27
src/effect_anim_file.c Normal file
View File

@ -0,0 +1,27 @@
#include "global.h"
#include "globaldata.h"
#include "file_system.h"
#include "def_filearchives.h"
OpenedFile *OpenEffectFile(u32 animType, s32 effectID)
{
u8 fileName[8];
switch (animType) {
case 1:
case 2:
case 3:
sprintf(fileName,"efob%03d",effectID);
break;
case 4:
sprintf(fileName,"efbg%03d",effectID);
break;
}
return Call_OpenFileAndGetFileDataPtr(fileName,&gEffectFileArchive);
}
void CloseEffectFile(OpenedFile *file)
{
CloseFile(file);
}

View File

@ -15,6 +15,7 @@
.include "src/cpu.o"
.include "src/code_800DAC0.o"
.include "src/code_800ED38.o"
.include "src/code_800F034.o"
.include "src/dungeon_pokemon_sprites.o"
.include "src/friend_areas_map.o"
.include "src/world_map.o"