save_trainer_hall.c

This commit is contained in:
PikalaxALT 2022-03-24 19:48:54 -04:00
parent 348bf8cd11
commit 93f51259fb
11 changed files with 294 additions and 157 deletions

View File

@ -27245,7 +27245,7 @@ ov112_021F3244: ; 0x021F3244
lsl r2, r2, #2
bl MIi_CpuClearFast
add r0, r4, #0
bl sub_020327DC
bl TrainerHallSet_SetZero
add r0, r4, #0
add r1, r5, #0
bl ov112_021F336C
@ -27273,10 +27273,10 @@ ov112_021F328C: ; 0x021F328C
str r1, [sp, #0x14]
str r0, [sp]
ldr r5, [sp, #0x10]
bl sub_0203277C
bl Save_TrainerHall_get
str r0, [sp, #8]
ldr r0, [sp, #4]
bl sub_020327F8
bl TrainerHallSet_CheckHasData
cmp r0, #0
bne _021F32B6
ldr r0, [sp, #8]
@ -27656,7 +27656,7 @@ ov112_021F35A4: ; 0x021F35A4
lsl r7, r7, #6
_021F35B0:
add r0, r5, #0
bl sub_020327F8
bl TrainerHallSet_CheckHasData
cmp r0, #0
beq _021F35C4
add r4, r4, #1
@ -27680,12 +27680,12 @@ ov112_021F35C8: ; 0x021F35C8
lsl r7, r7, #6
_021F35D6:
add r0, r5, #0
bl sub_020327F8
bl TrainerHallSet_CheckHasData
cmp r0, #0
beq _021F35F6
add r0, r5, #0
add r1, r6, #0
bl sub_02032808
bl TrainerHallTrainer_Compare
cmp r0, #0
beq _021F35F6
ldr r0, [sp]

View File

@ -20,7 +20,7 @@ ov25_022598C0: ; 0x022598C0
add r5, r0, #0
ldr r0, [r5, #0xc]
add r4, r1, #0
bl sub_0203277C
bl Save_TrainerHall_get
add r2, r0, #0
cmp r4, #0xa
bne _022598FE
@ -200,7 +200,7 @@ ScrCmd_809: ; 0x02259A30
add r0, #0x80
ldr r0, [r0]
ldr r0, [r0, #0xc]
bl sub_0203277C
bl Save_TrainerHall_get
cmp r4, #0xa
bne _02259A6C
ldr r1, _02259AA4 ; =ov25_02259D84
@ -606,7 +606,7 @@ ov25_02259D94: ; 0x02259D94
ov25_02259D9C: ; 0x02259D9C
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x0B, 0x02, GAME_VERSION, 0x00
.byte 0x0B, GAME_LANGUAGE, GAME_VERSION, 0x00
; ひかる$$$$$
.short 0x0033, 0x000C, 0x004C, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

View File

@ -1,136 +0,0 @@
.include "asm/macros.inc"
.include "global.inc"
.text
thumb_func_start sub_02032774
sub_02032774: ; 0x02032774
mov r0, #0xf
lsl r0, r0, #8
bx lr
.balign 4, 0
thumb_func_end sub_02032774
thumb_func_start sub_0203277C
sub_0203277C: ; 0x0203277C
ldr r3, _02032784 ; =SavArray_get
mov r1, #0x28
bx r3
nop
_02032784: .word SavArray_get
thumb_func_end sub_0203277C
thumb_func_start sub_02032788
sub_02032788: ; 0x02032788
push {r4, r5, r6, lr}
mov r2, #0xf
mov r1, #0
lsl r2, r2, #8
add r5, r0, #0
bl MI_CpuFill8
mov r6, #6
mov r4, #0
lsl r6, r6, #6
_0203279C:
add r0, r5, #0
bl sub_020327DC
add r4, r4, #1
add r5, r5, r6
cmp r4, #0xa
blt _0203279C
pop {r4, r5, r6, pc}
thumb_func_end sub_02032788
thumb_func_start sub_020327AC
sub_020327AC: ; 0x020327AC
push {r4, lr}
add r4, r0, #0
mov r1, #0
mov r2, #0x38
bl MI_CpuFill8
add r4, #0x24
add r0, r4, #0
mov r1, #0xa
bl StringFillEOS
pop {r4, pc}
thumb_func_end sub_020327AC
thumb_func_start sub_020327C4
sub_020327C4: ; 0x020327C4
push {r4, lr}
add r4, r0, #0
mov r1, #0
mov r2, #0x30
bl MI_CpuFill8
add r4, #8
add r0, r4, #0
mov r1, #8
bl StringFillEOS
pop {r4, pc}
thumb_func_end sub_020327C4
thumb_func_start sub_020327DC
sub_020327DC: ; 0x020327DC
push {r3, r4, r5, lr}
add r5, r0, #0
bl sub_020327C4
mov r4, #0
add r5, #0x30
_020327E8:
add r0, r5, #0
bl sub_020327AC
add r4, r4, #1
add r5, #0x38
cmp r4, #6
blt _020327E8
pop {r3, r4, r5, pc}
thumb_func_end sub_020327DC
thumb_func_start sub_020327F8
sub_020327F8: ; 0x020327F8
ldrh r0, [r0, #0x30]
lsl r0, r0, #0x15
lsr r0, r0, #0x15
beq _02032804
mov r0, #1
bx lr
_02032804:
mov r0, #0
bx lr
thumb_func_end sub_020327F8
thumb_func_start sub_02032808
sub_02032808: ; 0x02032808
push {r3, lr}
ldr r3, [r0]
ldr r2, [r1]
cmp r3, r2
bne _0203282A
ldrb r3, [r0, #6]
ldrb r2, [r1, #6]
cmp r3, r2
bne _0203282A
ldrb r3, [r0, #5]
ldrb r2, [r1, #5]
cmp r3, r2
bne _0203282A
ldrb r3, [r0, #7]
ldrb r2, [r1, #7]
cmp r3, r2
beq _0203282E
_0203282A:
mov r0, #0
pop {r3, pc}
_0203282E:
add r0, #8
add r1, #8
bl StringNotEqual
cmp r0, #0
bne _0203283E
mov r0, #1
pop {r3, pc}
_0203283E:
mov r0, #0
pop {r3, pc}
.balign 4, 0
thumb_func_end sub_02032808

View File

@ -1025,14 +1025,14 @@ ScrCmd_807: ; 0x0206DC50
add r7, r0, #0
ldr r0, [r4]
ldr r0, [r0, #0xc]
bl sub_0203277C
bl Save_TrainerHall_get
add r4, r0, #0
mov r0, #6
lsl r0, r0, #6
mul r0, r5
str r0, [sp]
add r0, r4, r0
bl sub_020327F8
bl TrainerHallSet_CheckHasData
strh r0, [r6]
ldrh r0, [r6]
cmp r0, #0

View File

@ -28495,12 +28495,12 @@
.public sub_02032728
.public sub_02032764
.public sub_0203276C
.public sub_02032774
.public sub_0203277C
.public sub_02032788
.public sub_020327DC
.public sub_020327F8
.public sub_02032808
.public Save_TrainerHall_sizeof
.public Save_TrainerHall_get
.public Save_TrainerHall_init
.public TrainerHallSet_SetZero
.public TrainerHallSet_CheckHasData
.public TrainerHallTrainer_Compare
.public sub_02032B84
.public sub_02032C1C
.public sub_02032E24

View File

@ -4,6 +4,168 @@
#define CHAR_NUL 0
#define CHAR_JP_SPACE 1
#define CHAR_JP_HIRA_A_SMALL 2
#define CHAR_JP_HIRA_A 3
#define CHAR_JP_HIRA_I_SMALL 4
#define CHAR_JP_HIRA_I 5
#define CHAR_JP_HIRA_U_SMALL 6
#define CHAR_JP_HIRA_U 7
#define CHAR_JP_HIRA_E_SMALL 8
#define CHAR_JP_HIRA_E 9
#define CHAR_JP_HIRA_O_SMALL 10
#define CHAR_JP_HIRA_O 11
#define CHAR_JP_HIRA_KA 12
#define CHAR_JP_HIRA_GA 13
#define CHAR_JP_HIRA_KI 14
#define CHAR_JP_HIRA_GI 15
#define CHAR_JP_HIRA_KU 16
#define CHAR_JP_HIRA_GU 17
#define CHAR_JP_HIRA_KE 18
#define CHAR_JP_HIRA_GE 19
#define CHAR_JP_HIRA_KO 20
#define CHAR_JP_HIRA_GO 21
#define CHAR_JP_HIRA_SA 22
#define CHAR_JP_HIRA_ZA 23
#define CHAR_JP_HIRA_SI 24
#define CHAR_JP_HIRA_ZI 25
#define CHAR_JP_HIRA_SU 26
#define CHAR_JP_HIRA_ZU 27
#define CHAR_JP_HIRA_SE 28
#define CHAR_JP_HIRA_ZE 29
#define CHAR_JP_HIRA_SO 30
#define CHAR_JP_HIRA_ZO 31
#define CHAR_JP_HIRA_TA 32
#define CHAR_JP_HIRA_DA 33
#define CHAR_JP_HIRA_TI 34
#define CHAR_JP_HIRA_DI 35
#define CHAR_JP_HIRA_TU_SMALL 36
#define CHAR_JP_HIRA_TU 37
#define CHAR_JP_HIRA_DU 38
#define CHAR_JP_HIRA_TE 39
#define CHAR_JP_HIRA_DE 40
#define CHAR_JP_HIRA_TO 41
#define CHAR_JP_HIRA_DO 42
#define CHAR_JP_HIRA_NA 43
#define CHAR_JP_HIRA_NI 44
#define CHAR_JP_HIRA_NU 45
#define CHAR_JP_HIRA_NE 46
#define CHAR_JP_HIRA_NO 47
#define CHAR_JP_HIRA_HA 48
#define CHAR_JP_HIRA_BA 49
#define CHAR_JP_HIRA_PA 50
#define CHAR_JP_HIRA_HI 51
#define CHAR_JP_HIRA_BI 52
#define CHAR_JP_HIRA_PI 53
#define CHAR_JP_HIRA_HU 54
#define CHAR_JP_HIRA_BU 55
#define CHAR_JP_HIRA_PU 56
#define CHAR_JP_HIRA_HE 57
#define CHAR_JP_HIRA_BE 58
#define CHAR_JP_HIRA_PE 59
#define CHAR_JP_HIRA_HO 60
#define CHAR_JP_HIRA_BO 61
#define CHAR_JP_HIRA_PO 62
#define CHAR_JP_HIRA_MA 63
#define CHAR_JP_HIRA_MI 64
#define CHAR_JP_HIRA_MU 65
#define CHAR_JP_HIRA_ME 66
#define CHAR_JP_HIRA_MO 67
#define CHAR_JP_HIRA_YA_SMALL 68
#define CHAR_JP_HIRA_YA 69
#define CHAR_JP_HIRA_YU_SMALL 70
#define CHAR_JP_HIRA_YU 71
#define CHAR_JP_HIRA_YO_SMALL 72
#define CHAR_JP_HIRA_YO 73
#define CHAR_JP_HIRA_RA 74
#define CHAR_JP_HIRA_RI 75
#define CHAR_JP_HIRA_RU 76
#define CHAR_JP_HIRA_RE 77
#define CHAR_JP_HIRA_RO 78
#define CHAR_JP_HIRA_WA 79
#define CHAR_JP_HIRA_WO 80
#define CHAR_JP_HIRA_N_ 81
#define CHAR_JP_KATA_A_SMALL 82
#define CHAR_JP_KATA_A 83
#define CHAR_JP_KATA_I_SMALL 84
#define CHAR_JP_KATA_I 85
#define CHAR_JP_KATA_U_SMALL 86
#define CHAR_JP_KATA_U 87
#define CHAR_JP_KATA_E_SMALL 88
#define CHAR_JP_KATA_E 89
#define CHAR_JP_KATA_O_SMALL 90
#define CHAR_JP_KATA_O 91
#define CHAR_JP_KATA_KA 92
#define CHAR_JP_KATA_GA 93
#define CHAR_JP_KATA_KI 94
#define CHAR_JP_KATA_GI 95
#define CHAR_JP_KATA_KU 96
#define CHAR_JP_KATA_GU 97
#define CHAR_JP_KATA_KE 98
#define CHAR_JP_KATA_GE 99
#define CHAR_JP_KATA_KO 100
#define CHAR_JP_KATA_GO 101
#define CHAR_JP_KATA_SA 102
#define CHAR_JP_KATA_ZA 103
#define CHAR_JP_KATA_SI 104
#define CHAR_JP_KATA_ZI 105
#define CHAR_JP_KATA_SU 106
#define CHAR_JP_KATA_ZU 107
#define CHAR_JP_KATA_SE 108
#define CHAR_JP_KATA_ZE 109
#define CHAR_JP_KATA_SO 110
#define CHAR_JP_KATA_ZO 111
#define CHAR_JP_KATA_TA 112
#define CHAR_JP_KATA_DA 113
#define CHAR_JP_KATA_TI 114
#define CHAR_JP_KATA_DI 115
#define CHAR_JP_KATA_TU_SMALL 116
#define CHAR_JP_KATA_TU 117
#define CHAR_JP_KATA_DU 118
#define CHAR_JP_KATA_TE 119
#define CHAR_JP_KATA_DE 120
#define CHAR_JP_KATA_TO 121
#define CHAR_JP_KATA_DO 122
#define CHAR_JP_KATA_NA 123
#define CHAR_JP_KATA_NI 124
#define CHAR_JP_KATA_NU 125
#define CHAR_JP_KATA_NE 126
#define CHAR_JP_KATA_NO 127
#define CHAR_JP_KATA_HA 128
#define CHAR_JP_KATA_BA 129
#define CHAR_JP_KATA_PA 130
#define CHAR_JP_KATA_HI 131
#define CHAR_JP_KATA_BI 132
#define CHAR_JP_KATA_PI 133
#define CHAR_JP_KATA_HU 134
#define CHAR_JP_KATA_BU 135
#define CHAR_JP_KATA_PU 136
#define CHAR_JP_KATA_HE 137
#define CHAR_JP_KATA_BE 138
#define CHAR_JP_KATA_PE 139
#define CHAR_JP_KATA_HO 140
#define CHAR_JP_KATA_BO 141
#define CHAR_JP_KATA_PO 142
#define CHAR_JP_KATA_MA 143
#define CHAR_JP_KATA_MI 144
#define CHAR_JP_KATA_MU 145
#define CHAR_JP_KATA_ME 146
#define CHAR_JP_KATA_MO 147
#define CHAR_JP_KATA_YA_SMALL 148
#define CHAR_JP_KATA_YA 149
#define CHAR_JP_KATA_YU_SMALL 150
#define CHAR_JP_KATA_YU 151
#define CHAR_JP_KATA_YO_SMALL 152
#define CHAR_JP_KATA_YO 153
#define CHAR_JP_KATA_RA 154
#define CHAR_JP_KATA_RI 155
#define CHAR_JP_KATA_RU 156
#define CHAR_JP_KATA_RE 157
#define CHAR_JP_KATA_RO 158
#define CHAR_JP_KATA_WA 159
#define CHAR_JP_KATA_WO 160
#define CHAR_JP_KATA_N_ 161
#define CHAR_JP_0 162
#define CHAR_JP_1 163
#define CHAR_JP_2 164

View File

@ -43,7 +43,7 @@
#define SAVE_UNK_37 37
#define SAVE_APRICORN_BOX 38
#define SAVE_POKEWALKER 39
#define SAVE_UNK_40 40
#define SAVE_TRAINER_HALL 40
#define SAVE_PCSTORAGE 41
#define SAVE_BLOCK_NUM 42

View File

@ -0,0 +1,61 @@
#ifndef POKEHEARTGOLD_SAVE_TRAINER_HALL_H
#define POKEHEARTGOLD_SAVE_TRAINER_HALL_H
#include "save.h"
#include "constants/pokemon.h"
#define TRAINER_HALL_SET_MAX 10
typedef struct TrainerHallTrainer {
u32 id;
u8 unk_04;
u8 language;
u8 version;
u8 unk7;
u16 otName[OT_NAME_LENGTH + 1];
u8 filler_18[0x18];
} TrainerHallTrainer; // size=0x30
typedef struct TrainerHallMon {
u16 species:11;
u16 forme:5;
u16 item;
u16 moves[MON_MOVES];
u32 pid;
u32 otid;
u32 hpIv:5;
u32 atkIv:5;
u32 defIv:5;
u32 spdIv:5;
u32 spAtkIv:5;
u32 spDefIv:5;
u32 dummy:2;
u8 hpEv;
u8 atkEv;
u8 defEv;
u8 spdEv;
u8 spAtkEv;
u8 spDefEv;
u8 unk_1E[6];
u16 nickname[POKEMON_NAME_LENGTH];
} TrainerHallMon; // size=0x38
typedef struct TrainerHallSet {
TrainerHallTrainer trainer;
TrainerHallMon party[PARTY_SIZE];
} TrainerHallSet;
typedef struct TrainerHallSave {
TrainerHallSet sets[TRAINER_HALL_SET_MAX];
} TrainerHallSave; // size=0xF00
u32 Save_TrainerHall_sizeof(void);
TrainerHallSave *Save_TrainerHall_get(SAVEDATA *saveData);
void Save_TrainerHall_init(TrainerHallSave *th);
void TrainerHallMon_SetZero(TrainerHallMon *mon);
void TrainerHallTrainer_SetZero(TrainerHallTrainer *trainer);
void TrainerHallSet_SetZero(TrainerHallSet *set);
BOOL TrainerHallSet_CheckHasData(const TrainerHallSet *set);
BOOL TrainerHallTrainer_Compare(const TrainerHallTrainer *a, const TrainerHallTrainer *b);
#endif //POKEHEARTGOLD_SAVE_TRAINER_HALL_H

View File

@ -134,7 +134,7 @@ Static main
Object src/unk_02031AF0.o
Object asm/unk_02031B0C.o
Object src/pokewalker.o
Object asm/unk_02032774.o
Object src/save_trainer_hall.o
Object asm/unk_02032844.o
Object asm/unk_02033AE0.o
Object asm/unk_02034354.o

View File

@ -45,7 +45,7 @@ DECL_CHUNK_EX(sub_020318C8, sub_020318CC)
DECL_CHUNK(SaveData_GSPlayerMisc)
DECL_CHUNK_EX(sub_02031904, sub_0203190C)
DECL_CHUNK(Save_ApricornBox)
DECL_CHUNK_EX(sub_02032774, sub_02032788)
DECL_CHUNK_EX(Save_TrainerHall_sizeof, Save_TrainerHall_init)
const struct SaveChunkHeader gSaveChunkHeaders[] = {
{ SAVE_SYSINFO, 0, (SAVESIZEFN)Sav2_SysInfo_sizeof, (SAVEINITFN)Sav2_SysInfo_init },
@ -88,7 +88,7 @@ const struct SaveChunkHeader gSaveChunkHeaders[] = {
{ SAVE_UNK_37, 0, (SAVESIZEFN)sub_02031904, (SAVEINITFN)sub_0203190C },
{ SAVE_APRICORN_BOX, 0, (SAVESIZEFN)Save_ApricornBox_sizeof, (SAVEINITFN)Save_ApricornBox_init },
{ SAVE_POKEWALKER, 0, (SAVESIZEFN)Pokewalker_sizeof, (SAVEINITFN)Pokewalker_init },
{ SAVE_UNK_40, 0, (SAVESIZEFN)sub_02032774, (SAVEINITFN)sub_02032788 },
{ SAVE_TRAINER_HALL, 0, (SAVESIZEFN)Save_TrainerHall_sizeof, (SAVEINITFN)Save_TrainerHall_init },
{ SAVE_PCSTORAGE, 1, (SAVESIZEFN)PCStorage_sizeof, (SAVEINITFN)PCStorage_init },
};
const int gNumSaveChunkHeaders = NELEMS(gSaveChunkHeaders);

50
src/save_trainer_hall.c Normal file
View File

@ -0,0 +1,50 @@
#include "save_trainer_hall.h"
#include "string_util.h"
#include "constants/species.h"
u32 Save_TrainerHall_sizeof(void) {
return sizeof(TrainerHallSave);
}
TrainerHallSave *Save_TrainerHall_get(SAVEDATA *saveData) {
return SavArray_get(saveData, SAVE_TRAINER_HALL);
}
void Save_TrainerHall_init(TrainerHallSave *th) {
int i;
MI_CpuClear8(th, sizeof(TrainerHallSave));
for (i = 0; i < TRAINER_HALL_SET_MAX; i++) {
TrainerHallSet_SetZero(&th->sets[i]);
}
}
void TrainerHallMon_SetZero(TrainerHallMon *mon) {
MI_CpuClear8(mon, sizeof(TrainerHallMon));
StringFillEOS(mon->nickname, POKEMON_NAME_LENGTH);
}
void TrainerHallTrainer_SetZero(TrainerHallTrainer *trainer) {
MI_CpuClear8(trainer, sizeof(TrainerHallTrainer));
StringFillEOS(trainer->otName, OT_NAME_LENGTH + 1);
}
void TrainerHallSet_SetZero(TrainerHallSet *set) {
int i;
TrainerHallTrainer_SetZero(&set->trainer);
for (i = 0; i < PARTY_SIZE; i++) {
TrainerHallMon_SetZero(&set->party[i]);
}
}
BOOL TrainerHallSet_CheckHasData(const TrainerHallSet *set) {
return set->party[0].species != SPECIES_NONE;
}
BOOL TrainerHallTrainer_Compare(const TrainerHallTrainer *a, const TrainerHallTrainer *b) {
if (a->id != b->id || a->version != b->version || a->language != b->language || a->unk7 != b->unk7) {
return FALSE;
}
return !StringNotEqual(a->otName, b->otName);
}