Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions asm/macros/scrcmd.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1991,15 +1991,15 @@
.short 340
.endm

.macro ScrCmd_155 arg0, arg1
.macro GetTrainerInfoTrainerClass variant, destVar
.short 341
.short \arg0
.short \arg1
.short \variant
.short \destVar
.endm

.macro ScrCmd_156 arg0
.macro SetTrainerInfoAppearance appearance
.short 342
.short \arg0
.short \appearance
.endm

.macro CheckPokedexAcquired destVarID
Expand Down Expand Up @@ -3981,10 +3981,10 @@
.short \arg3
.endm

.macro ScrCmd_29C arg0, arg1
.macro CalculateTrainerInfoAppearance variant, destVar
.short 668
.short \arg0
.short \arg1
.short \variant
.short \destVar
.endm

.macro AddMenuEntry entryStringID, entryIndex
Expand Down
2 changes: 1 addition & 1 deletion generated/vars_flags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ FLAG_GOT_POTION_FROM_ROUTE_201_CASHIER
FLAG_UNK_0x006D
FLAG_UNK_0x006E
FLAG_UNK_0x006F
FLAG_CHOSE_TRAINER_CLASS
FLAG_CHOSE_UNION_ROOM_APPEARANCE
FLAG_UNK_0x0071
FLAG_UNK_0x0072
FLAG_UNK_0x0073
Expand Down
18 changes: 18 additions & 0 deletions include/appearance.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef POKEPLATINUM_APPEARENCE_H
#define POKEPLATINUM_APPEARENCE_H

#include "string_template.h"

enum AppearanceDataParam {
APPEARANCE_DATA_INDEX = 0,
APPEARANCE_DATA_TRAINER_CLASS_2,
APPEARANCE_DATA_TRAINER_CLASS_1,
};

void Appearance_LoadVariants(u32 trainerId, int trainerGender, StringTemplate *stringTemplate);
int Appearance_CalculateFromTrainerInfo(u32 trainerId, int trainerGender, u32 variant);
int Appearance_GetIndex(int gender, int appearance);
int Appearance_GetData(int gender, int appearance, enum AppearanceDataParam param);
u16 *sub_0205CA4C(enum HeapID heapID);

#endif // POKEPLATINUM_APPEARENCE_H
12 changes: 0 additions & 12 deletions include/unk_0205C980.h

This file was deleted.

2 changes: 1 addition & 1 deletion platinum.us/main.lsf
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ Static main
Object main.nef.p/src_unk_0205A0D8.c.o
Object main.nef.p/src_unk_0205B33C.c.o
Object main.nef.p/src_unk_0205C22C.c.o
Object main.nef.p/src_unk_0205C980.c.o
Object main.nef.p/src_appearance.c.o
Object main.nef.p/src_unk_0205CA94.c.o
Object main.nef.p/src_field_message.c.o
Object main.nef.p/src_map_tile_behavior.c.o
Expand Down
10 changes: 5 additions & 5 deletions res/field/scripts/scripts_oreburgh_city_pokecenter_1f.s
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ OreburghCityPokecenter1F_Psychic:
PlayFanfare SEQ_SE_CONFIRM
LockAll
FacePlayer
GoToIfSet FLAG_CHOSE_TRAINER_CLASS, OreburghCityPokecenter1F_HowAboutTellingMeWhatKindOfTrainerYouLike
GoToIfSet FLAG_CHOSE_UNION_ROOM_APPEARANCE, OreburghCityPokecenter1F_HowAboutTellingMeWhatKindOfTrainerYouLike
Message OreburghCityPokecenter1F_Text_WhatIsYourFavoriteKindOfTrainerCanYouTellMe
GoTo OreburghCityPokecenter1F_WhichKindOfTrainerWouldYouLikeToBe

Expand All @@ -64,7 +64,7 @@ OreburghCityPokecenter1F_WhichKindOfTrainerWouldYouLikeToBe:
SetVar VAR_0x8008, VAR_RESULT
GoToIfEq VAR_0x8008, 4, OreburghCityPokecenter1F_OKThenIllJustTalkToYouLater
GoToIfEq VAR_0x8008, -2, OreburghCityPokecenter1F_OKThenIllJustTalkToYouLater
ScrCmd_155 VAR_0x8004, VAR_0x8005
GetTrainerInfoTrainerClass VAR_0x8004, VAR_0x8005
BufferTrainerClassNameWithArticle 0, VAR_0x8005
CapitalizeFirstLetter 0
Message OreburghCityPokecenter1F_Text_AskThisIsTheKindOfTrainerYouWantToBe
Expand All @@ -82,9 +82,9 @@ OreburghCityPokecenter1F_OKThenIllJustTalkToYouLater:
OreburghCityPokecenter1F_SetTrainerClass:
BufferTrainerClassNameWithArticle 0, VAR_0x8005
Message OreburghCityPokecenter1F_Text_ISeeSoThisIsTheKindOfTrainerYouLike
SetFlag FLAG_CHOSE_TRAINER_CLASS
ScrCmd_29C VAR_0x8004, VAR_0x8005
ScrCmd_156 VAR_0x8005
SetFlag FLAG_CHOSE_UNION_ROOM_APPEARANCE
CalculateTrainerInfoAppearance VAR_0x8004, VAR_0x8005
SetTrainerInfoAppearance VAR_0x8005
GoTo OreburghCityPokecenter1F_OKThenIllJustTalkToYouLater

OreburghCityPokecenter1F_Gentleman:
Expand Down
124 changes: 124 additions & 0 deletions src/appearance.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#include "appearance.h"

#include <nitro.h>
#include <string.h>

#include "generated/trainer_classes.h"

#include "graphics.h"
#include "heap.h"
#include "string_template.h"

#define APPEARANCES_COUNT 8
#define VARIANTS_COUNT 4

typedef struct Appearance {
int index;
int class1;
int class2;
} Appearance;

static const Appearance sTrainerAppearances[APPEARANCES_COUNT * 2] = {
// male appearances
{ 3, TRAINER_CLASS_SCHOOL_KID_MALE, TRAINER_CLASS_SCHOOL_KID_MALE },
{ 5, TRAINER_CLASS_BUG_CATCHER, TRAINER_CLASS_BUG_CATCHER },
{ 11, TRAINER_CLASS_ACE_TRAINER_MALE, TRAINER_CLASS_ACE_TRAINER_MALE },
{ 31, TRAINER_CLASS_ROUGHNECK, TRAINER_CLASS_ROUGHNECK },
{ 50, TRAINER_CLASS_RUIN_MANIAC, TRAINER_CLASS_RUIN_MANIAC },
{ 51, TRAINER_CLASS_BLACK_BELT, TRAINER_CLASS_BLACK_BELT },
{ 62, TRAINER_CLASS_RICH_BOY, TRAINER_CLASS_RICH_BOY },
{ 70, TRAINER_CLASS_PSYCHIC_MALE, TRAINER_CLASS_PSYCHIC_MALE },

// female appearances
{ 6, TRAINER_CLASS_LASS, TRAINER_CLASS_LASS },
{ 7, TRAINER_CLASS_BATTLE_GIRL, TRAINER_CLASS_BATTLE_GIRL },
{ 13, TRAINER_CLASS_BEAUTY, TRAINER_CLASS_BEAUTY },
{ 14, TRAINER_CLASS_ACE_TRAINER_FEMALE, TRAINER_CLASS_ACE_TRAINER_FEMALE },
{ 35, TRAINER_CLASS_IDOL, TRAINER_CLASS_IDOL },
{ 37, TRAINER_CLASS_SOCIALITE, TRAINER_CLASS_SOCIALITE },
{ 42, TRAINER_CLASS_COWGIRL, TRAINER_CLASS_COWGIRL },
{ 63, TRAINER_CLASS_LADY, TRAINER_CLASS_LADY }
};

static const int sAppearanceShuffleTable[APPEARANCES_COUNT][VARIANTS_COUNT] = {
{ 0, 1, 2, 3 },
{ 1, 6, 7, 0 },
{ 2, 3, 4, 5 },
{ 3, 0, 5, 6 },
{ 4, 1, 2, 7 },
{ 5, 2, 7, 0 },
{ 6, 3, 4, 1 },
{ 7, 4, 5, 6 }
};

void Appearance_LoadVariants(u32 trainerId, int trainerGender, StringTemplate *stringTemplate)
{
int rnd = trainerId % APPEARANCES_COUNT;
int variant;

for (variant = 0; variant < VARIANTS_COUNT; variant++) {
int appearanceIndex = sAppearanceShuffleTable[rnd][variant] + APPEARANCES_COUNT * trainerGender;
StringTemplate_SetTrainerClassName(stringTemplate, variant, sTrainerAppearances[appearanceIndex].class1);
}
}

int Appearance_CalculateFromTrainerInfo(u32 trainerId, int trainerGender, u32 variant)
{
int rnd = trainerId % APPEARANCES_COUNT;
int appearanceIndex = sAppearanceShuffleTable[rnd][variant] + APPEARANCES_COUNT * trainerGender;

return sTrainerAppearances[appearanceIndex].index;
}

static int GetAppearanceIndex(int gender, int appearance)
{
for (int i = 0; i < APPEARANCES_COUNT; i++) {
if (sTrainerAppearances[i + gender * APPEARANCES_COUNT].index == appearance) {
return i + gender * APPEARANCES_COUNT;
}
}

return 0;
}

int Appearance_GetIndex(int gender, int appearance)
{
return GetAppearanceIndex(gender, appearance);
}

int Appearance_GetData(int gender, int appearance, enum AppearanceDataParam param)
{
int appearanceIndex = GetAppearanceIndex(gender, appearance);

switch (param) {
case APPEARANCE_DATA_INDEX:
return appearanceIndex;
case APPEARANCE_DATA_TRAINER_CLASS_1:
return sTrainerAppearances[appearanceIndex].class1;
case APPEARANCE_DATA_TRAINER_CLASS_2:
return sTrainerAppearances[appearanceIndex].class2;
default:
GF_ASSERT(FALSE);
return 0;
}
}

u16 *sub_0205CA4C(enum HeapID heapID)
{
u8 *v0, *v1;
NNSG2dPaletteData *v2, *v3;
u16 *v4, *v5;
int v6;

v0 = Graphics_GetPlttData(NARC_INDEX_GRAPHIC__RECORD, 7, &v2, heapID);
v4 = Heap_Alloc(heapID, 16 * 18 * 2);
v5 = (u16 *)v2->pRawData;

for (v6 = 0; v6 < 16 * 16; v6++) {
v4[v6] = v5[v6];
}

Heap_Free(v0);

return v4;
}
4 changes: 2 additions & 2 deletions src/field_battle_data_transfer.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "field/field_system.h"
#include "savedata/save_table.h"

#include "appearance.h"
#include "bag.h"
#include "battle_regulation.h"
#include "charcode_util.h"
Expand Down Expand Up @@ -55,7 +56,6 @@
#include "unk_0203266C.h"
#include "unk_020366A0.h"
#include "unk_020559DC.h"
#include "unk_0205C980.h"
#include "vars_flags.h"

#include "res/text/bank/location_names.h"
Expand Down Expand Up @@ -401,7 +401,7 @@ void FieldBattleDTO_InitWithPartyOrder(FieldBattleDTO *dto, const FieldSystem *f
int unionAppearance = TrainerInfo_Appearance(trainerInfo);
int unionGender = TrainerInfo_Gender(trainerInfo);

dto->trainer[BATTLER_PLAYER_1].header.trainerType = sub_0205CA14(unionGender, unionAppearance, 1);
dto->trainer[BATTLER_PLAYER_1].header.trainerType = Appearance_GetData(unionGender, unionAppearance, APPEARANCE_DATA_TRAINER_CLASS_2);
CharCode_Copy(dto->trainer[BATTLER_PLAYER_1].name, TrainerInfo_Name(dto->trainerInfo[BATTLER_PLAYER_1]));
dto->trainer[BATTLER_PLAYER_2] = dto->trainer[BATTLER_PLAYER_1];
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/game_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "constants/game_options.h"
#include "constants/heap.h"

#include "appearance.h"
#include "berry_patches.h"
#include "game_options.h"
#include "heap.h"
Expand All @@ -20,7 +21,6 @@
#include "system_data.h"
#include "system_flags.h"
#include "trainer_info.h"
#include "unk_0205C980.h"
#include "unk_0206B9D8.h"
#include "vars_flags.h"

Expand Down Expand Up @@ -165,7 +165,7 @@ static void InitializeNewSave(enum HeapID heapID, SaveData *saveData, BOOL setTr
TrainerInfo_SetID(trainerInfo, rnd);
}

TrainerInfo_SetAppearance(trainerInfo, TrainerInfo_GetAppearanceIndex(rnd, TrainerInfo_Gender(trainerInfo), 0));
TrainerInfo_SetAppearance(trainerInfo, Appearance_CalculateFromTrainerInfo(rnd, TrainerInfo_Gender(trainerInfo), 0));

berryPatches = MiscSaveBlock_GetBerryPatches(saveData);
BerryPatches_Init(berryPatches, heapID, (const u16 *)sBerryInitTable, NELEMS(sBerryInitTable));
Expand Down
2 changes: 1 addition & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ pokeplatinum_c = files(
'unk_0205A0D8.c',
'unk_0205B33C.c',
'unk_0205C22C.c',
'unk_0205C980.c',
'appearance.c',
'unk_0205CA94.c',
'field_message.c',
'map_tile_behavior.c',
Expand Down
4 changes: 2 additions & 2 deletions src/overlay059/ov59_021D0D80.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "overlay059/ov59_021D2F88.h"
#include "overlay059/struct_ov59_021D109C.h"

#include "appearance.h"
#include "bg_window.h"
#include "char_transfer.h"
#include "communication_information.h"
Expand Down Expand Up @@ -54,7 +55,6 @@
#include "unk_020393C8.h"
#include "unk_0205B33C.h"
#include "unk_0205C22C.h"
#include "unk_0205C980.h"
#include "unk_020961E8.h"
#include "vram_transfer.h"

Expand Down Expand Up @@ -1655,7 +1655,7 @@ static void ov59_021D2860(NNSG2dCharacterData *param0[2], NNSG2dPaletteData *par
int v0;
u8 *v1, *v2;

v0 = sub_0205CA0C(param4, param3);
v0 = Appearance_GetIndex(param4, param3);

v1 = (u8 *)param0[1]->pRawData;
v2 = (u8 *)param1[1]->pRawData;
Expand Down
4 changes: 2 additions & 2 deletions src/overlay064/ov64_0222DCE0.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "overlay063/struct_ov63_0222BB38_decl.h"
#include "overlay064/struct_ov64_022302EC.h"

#include "appearance.h"
#include "ascii_util.h"
#include "bag.h"
#include "bg_window.h"
Expand Down Expand Up @@ -61,7 +62,6 @@
#include "unk_0202ACE0.h"
#include "unk_0203061C.h"
#include "unk_0203909C.h"
#include "unk_0205C980.h"
#include "unk_020890F4.h"
#include "vars_flags.h"
#include "vram_transfer.h"
Expand Down Expand Up @@ -3147,7 +3147,7 @@ static void ov64_02231164(UnkStruct_ov64_02230F98 *param0, UnkStruct_ov64_0222E0
UnkStruct_ov5_021DE5D0 v3;
u32 v0 = sub_0202AD2C(wifiList, param1->unk_08.unk_04[param1->unk_07], 8);
u32 v1 = sub_0202AD2C(wifiList, param1->unk_08.unk_04[param1->unk_07], 7);
sub_02076AAC(sub_0205CA14(v0, v1, 1), 2, &v3);
sub_02076AAC(Appearance_GetData(v0, v1, APPEARANCE_DATA_TRAINER_CLASS_2), 2, &v3);

void *buffer = Heap_Alloc(heapID, 0xC80);
CharacterSprite_LoadTiledData(v3.narcID, v3.unk_14, heapID, 0, 0, 10, 10, buffer);
Expand Down
4 changes: 2 additions & 2 deletions src/overlay094/ov94_02243EF8.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
#include "overlay094/application.h"
#include "overlay094/gts_application_state.h"

#include "appearance.h"
#include "graphics.h"
#include "heap.h"
#include "sound_playback.h"
#include "sprite.h"
#include "sys_task_manager.h"
#include "touch_screen.h"
#include "unk_0200679C.h"
#include "unk_0205C980.h"

typedef struct AvatarAnimationData {
int state;
Expand Down Expand Up @@ -302,7 +302,7 @@ static void ov94_02244378(NNSG2dCharacterData *param0, NNSG2dPaletteData *param1
int v0;
u8 *v1, *v2;

v0 = sub_0205CA0C(param4, param3);
v0 = Appearance_GetIndex(param4, param3);
v1 = (u8 *)param0->pRawData;
v2 = (u8 *)param1->pRawData;

Expand Down
4 changes: 2 additions & 2 deletions src/overlay109/ov109_021D3D50.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "overlay109/struct_ov109_021D5140_sub1.h"
#include "overlay109/struct_ov109_021D5140_sub2.h"

#include "appearance.h"
#include "bg_window.h"
#include "char_transfer.h"
#include "communication_information.h"
Expand Down Expand Up @@ -54,7 +55,6 @@
#include "unk_02038ED4.h"
#include "unk_020393C8.h"
#include "unk_0205B33C.h"
#include "unk_0205C980.h"
#include "unk_0209BDF8.h"
#include "vram_transfer.h"

Expand Down Expand Up @@ -1659,7 +1659,7 @@ static void ov109_021D57E0(NNSG2dCharacterData *param0[2], NNSG2dPaletteData *pa
int v0;
u8 *v1, *v2;

v0 = sub_0205CA0C(param4, param3);
v0 = Appearance_GetIndex(param4, param3);
v1 = (u8 *)param0[1]->pRawData;
v2 = (u8 *)param1[1]->pRawData;

Expand Down
Loading