Skip to content

Commit

Permalink
certificates_app: Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tgsm committed Nov 28, 2023
1 parent cecbf74 commit f7950c0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
11 changes: 11 additions & 0 deletions include/certificates_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@
#define CERTIFICATE_NATIONAL_DEX 1
#define CERTIFICATE_SHINY_LEAVES 2

typedef enum CertificatesExecStates {
CERTIFICATES_EXECSTATE_SETUP,
CERTIFICATES_EXECSTATE_FADE_IN,
CERTIFICATES_EXECSTATE_WAIT_ONE_SECOND,
CERTIFICATES_EXECSTATE_MOVE_TO_BOTTOM_SCREEN,
CERTIFICATES_EXECSTATE_WAIT_FOR_INPUT,
CERTIFICATES_EXECSTATE_FADE_OUT,

CERTIFICATES_EXECSTATE_COUNT,
} CertificatesExecStates;

BOOL CertificatesApp_Init(OVY_MANAGER *manager, int *state);
BOOL CertificatesApp_Run(OVY_MANAGER *manager, int *state);
BOOL CertificatesApp_Exit(OVY_MANAGER *manager, int *state);
Expand Down
2 changes: 2 additions & 0 deletions include/unk_02013FDC.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@

void *sub_0201442C(NarcId narcId, s32 fileId, HeapID heapId);
void *sub_02014450(NarcId narcId, s32 fileId, HeapID heapId);
// FIXME: Types are probably wrong.
void sub_020145B4(void *a0, u32 a1, u32 a2, u32 a3, u32 a4, u32 a5, void *a6);

#endif //POKEHEARTGOLD_UNK_02013FDC_H
34 changes: 16 additions & 18 deletions src/certificates_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "system.h"
#include "text.h"
#include "unk_0200FA24.h"
#include "unk_02013FDC.h"
#include "unk_0203E348.h"
#include "unk_0205BB1C.h"

Expand Down Expand Up @@ -156,9 +157,6 @@ static s16 ov78_021E6920[3][2] = {
{ 140, 180 },
};

// FIXME: Types are probably wrong.
extern void sub_020145B4(void *a0, u32 a1, u32 a2, u32 a3, u32 a4, u32 a5, void *a6);

static void CertificatesApp_OnVBlank(CertificatesApp_Data *data);
static void CertificatesApp_SetupBgConfig(CertificatesApp_Data *data);
static void CertificatesApp_FreeBgConfig(CertificatesApp_Data *data);
Expand All @@ -178,7 +176,7 @@ static void ov78_021E652C(CertificatesApp_Data *data);
static void ov78_021E656C(Sprite *sprite, void *unkBuffer, u32 unkBufferSize, u32 srcOffset);
static void ov78_021E65BC(Sprite *sprite, u32 narcMemberNum, u32 a2, HeapID heapId);
static void ov78_021E6664(Sprite *sprite, PlayerProfile *profile, HeapID heapId);
static u32 ov78_021E6688(int species, int forme, int gender);
static u32 ov78_021E6688(int species, int form, int gender);
static void ov78_021E66D4(Sprite *sprite, Pokemon *pokemon, HeapID heapId, u32 a3);

BOOL CertificatesApp_Init(OVY_MANAGER *manager, int *state) {
Expand Down Expand Up @@ -234,7 +232,7 @@ BOOL CertificatesApp_Run(OVY_MANAGER *manager, int *state) {
BOOL ret = FALSE;

switch (*state) {
case 0:
case CERTIFICATES_EXECSTATE_SETUP:
ov78_021E5E44(data);
ov78_021E5EA4(data);
ov78_021E6068(data);
Expand All @@ -250,22 +248,22 @@ BOOL CertificatesApp_Run(OVY_MANAGER *manager, int *state) {

*state = 1;
break;
case 1:
case CERTIFICATES_EXECSTATE_FADE_IN:
if (IsPaletteFadeFinished() != TRUE) {
break;
}

data->waitFrames = 0;
*state = 2;
break;
case 2:
case CERTIFICATES_EXECSTATE_WAIT_ONE_SECOND:
if (data->waitFrames < 60) {
data->waitFrames++;
} else {
*state = 3;
}
break;
case 3:
case CERTIFICATES_EXECSTATE_MOVE_TO_BOTTOM_SCREEN:
if (data->unk40 > -192) {
data->unk40 -= 4;
ov78_021E5E54(data);
Expand All @@ -275,13 +273,13 @@ BOOL CertificatesApp_Run(OVY_MANAGER *manager, int *state) {
*state = 4;
}
break;
case 4:
case CERTIFICATES_EXECSTATE_WAIT_FOR_INPUT:
if ((gSystem.newKeys & PAD_BUTTON_A) == PAD_BUTTON_A || (gSystem.newKeys & PAD_BUTTON_B) == PAD_BUTTON_B || gSystem.touchNew != 0) {
BeginNormalPaletteFade(0, 0, 0, RGB_BLACK, 6, 1, data->heapId);
*state = 5;
}
break;
case 5:
case CERTIFICATES_EXECSTATE_FADE_OUT:
if (IsPaletteFadeFinished() == TRUE) {
ret = TRUE;
}
Expand Down Expand Up @@ -786,7 +784,7 @@ static void ov78_021E6664(Sprite *sprite, PlayerProfile *profile, HeapID heapId)
ov78_021E65BC(sprite, narcMemberNum, 21, heapId);
}

static u32 ov78_021E6688(int species, int forme, int gender) {
static u32 ov78_021E6688(int species, int form, int gender) {
u32 ret;
if (species <= SPECIES_NONE || species > MAX_SPECIES) {
ret = 1;
Expand All @@ -797,18 +795,18 @@ static u32 ov78_021E6688(int species, int forme, int gender) {
ret++;
}
} else {
if (forme > OverworldModelLookupFormCount(species)) {
forme = 0;
if (form > OverworldModelLookupFormCount(species)) {
form = 0;
}
ret += forme;
ret += form;
}
}
return ret;
}

static void ov78_021E66D4(Sprite *sprite, Pokemon *pokemon, HeapID heapId, u32 a3) {
u32 species = GetMonData(pokemon, MON_DATA_SPECIES, NULL);
u32 forme = GetMonData(pokemon, MON_DATA_FORM, NULL);
u32 form = GetMonData(pokemon, MON_DATA_FORM, NULL);
u32 gender = GetMonGender(pokemon);
BOOL shiny = MonIsShiny(pokemon);

Expand All @@ -823,11 +821,11 @@ static void ov78_021E66D4(Sprite *sprite, Pokemon *pokemon, HeapID heapId, u32 a

NARC *narc = NARC_New(NARC_data_mmodel_mmodel, heapId);

if (sub_02070438(species, forme) == 0) {
forme = 0;
if (sub_02070438(species, form) == 0) {
form = 0;
}

u32 member = ov78_021E6688(species, (u16)forme, gender);
u32 member = ov78_021E6688(species, (u16)form, gender);
NNSG3dResFileHeader *header = NARC_AllocAndReadWholeMember(narc, member, heapId);
NNSG3dResTex *tex = NNS_G3dGetTex(header);
void *address = (void*)tex + tex->texInfo.ofsTex;
Expand Down

0 comments on commit f7950c0

Please sign in to comment.