Decompile sub_8093110 and sub_8093130

This commit is contained in:
Marijn van der Werf 2016-12-03 12:46:03 +01:00
parent d4247e6eed
commit 95ee1e7188
14 changed files with 476 additions and 612 deletions

View File

@ -367,7 +367,7 @@ sub_81101FC: @ 81101FC
lsls r1, r0, 3
subs r1, r0
lsls r1, 3
ldr r0, _08110220 @ =gUnknown_0202FFD4
ldr r0, _08110220 @ =gTrainerCards + 0x14
adds r1, r0
ldrh r0, [r1]
adds r0, 0x1
@ -382,7 +382,7 @@ _0811021A:
pop {r0}
bx r0
.align 2, 0
_08110220: .4byte gUnknown_0202FFD4
_08110220: .4byte gTrainerCards + 0x14
_08110224: .4byte 0x0000270f
thumb_func_end sub_81101FC
@ -392,7 +392,7 @@ sub_8110228: @ 8110228
lsls r1, r0, 3
subs r1, r0
lsls r1, 3
ldr r0, _0811024C @ =gUnknown_0202FFD6
ldr r0, _0811024C @ =gTrainerCards + 0x16
adds r1, r0
ldrh r0, [r1]
adds r0, 0x1
@ -407,7 +407,7 @@ _08110246:
pop {r0}
bx r0
.align 2, 0
_0811024C: .4byte gUnknown_0202FFD6
_0811024C: .4byte gTrainerCards + 0x16
_08110250: .4byte 0x0000270f
thumb_func_end sub_8110228
@ -452,7 +452,7 @@ sub_8110290: @ 8110290
lsls r2, r4, 3
subs r2, r4
lsls r2, 3
ldr r3, _081102D8 @ =gUnknown_0202FFF0
ldr r3, _081102D8 @ =gUnknown_0202FFF0 + 0x30
adds r1, r2, r3
subs r3, 0x30
adds r2, r3
@ -477,7 +477,7 @@ sub_8110290: @ 8110290
bx r0
.align 2, 0
_081102D4: .4byte gSaveBlock1 + 0x30B8
_081102D8: .4byte gUnknown_0202FFF0
_081102D8: .4byte gTrainerCards + 0x30
_081102DC: .4byte gUnknown_02024D26
_081102E0: .4byte gLinkPlayers
_081102E4: .4byte gLinkPlayerMapObjects

View File

@ -810,10 +810,10 @@ sub_8083314: @ 8083314
cmp r4, r0
bne _080833B6
movs r4, 0
ldr r6, _0808333C @ =gUnknown_0202FFC0
ldr r6, _0808333C @ =gTrainerCards
b _0808335A
.align 2, 0
_0808333C: .4byte gUnknown_0202FFC0
_0808333C: .4byte gTrainerCards
_08083340:
lsls r1, r4, 8
ldr r0, _08083394 @ =gBlockRecvBuffer

View File

@ -6,581 +6,6 @@
.text
thumb_func_start sub_8093110
sub_8093110: @ 8093110
push {lr}
bl sub_80932AC
ldr r0, _08093128 @ =sub_8093174
bl SetMainCallback2
ldr r0, _0809312C @ =0x02000000
adds r0, 0x9C
movs r1, 0x2
strb r1, [r0]
pop {r0}
bx r0
.align 2, 0
_08093128: .4byte sub_8093174
_0809312C: .4byte 0x02000000
thumb_func_end sub_8093110
thumb_func_start sub_8093130
sub_8093130: @ 8093130
push {r4,lr}
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
adds r0, r4, 0
bl sub_80932E4
ldr r0, _08093164 @ =sub_8093174
bl SetMainCallback2
ldr r2, _08093168 @ =0x02000000
ldr r3, _0809316C @ =gLinkPlayers
ldr r0, _08093170 @ =gLinkPlayerMapObjects
lsls r4, 2
adds r4, r0
ldrb r1, [r4, 0x1]
lsls r0, r1, 3
subs r0, r1
lsls r0, 2
adds r0, r3
ldrh r0, [r0, 0x1A]
adds r2, 0x9C
strb r0, [r2]
pop {r4}
pop {r0}
bx r0
.align 2, 0
_08093164: .4byte sub_8093174
_08093168: .4byte 0x02000000
_0809316C: .4byte gLinkPlayers
_08093170: .4byte gLinkPlayerMapObjects
thumb_func_end sub_8093130
thumb_func_start sub_8093174
sub_8093174: @ 8093174
push {lr}
ldr r0, _0809318C @ =gMain
ldr r1, _08093190 @ =0x0000043c
adds r0, r1
ldrb r0, [r0]
cmp r0, 0x8
bhi _08093232
lsls r0, 2
ldr r1, _08093194 @ =_08093198
adds r0, r1
ldr r0, [r0]
mov pc, r0
.align 2, 0
_0809318C: .4byte gMain
_08093190: .4byte 0x0000043c
_08093194: .4byte _08093198
.align 2, 0
_08093198:
.4byte _080931BC
.4byte _080931C6
.4byte _080931CC
.4byte _080931D2
.4byte _080931DC
.4byte _080931EC
.4byte _08093200
.4byte _08093206
.4byte _08093220
_080931BC:
bl sub_8093534
bl sub_8093688
b _0809320A
_080931C6:
bl sub_8093598
b _0809320A
_080931CC:
bl sub_80935EC
b _0809320A
_080931D2:
bl sub_8093610
bl sub_80937A4
b _0809320A
_080931DC:
bl sub_80937BC
ldr r1, _080931F8 @ =gMain
ldr r0, _080931FC @ =0x0000043c
adds r1, r0
ldrb r0, [r1]
adds r0, 0x1
strb r0, [r1]
_080931EC:
bl MultistepInitMenuWindowContinue
cmp r0, 0
beq _08093232
b _0809320A
.align 2, 0
_080931F8: .4byte gMain
_080931FC: .4byte 0x0000043c
_08093200:
bl sub_80937F0
b _0809320A
_08093206:
bl sub_80937D8
_0809320A:
ldr r1, _08093218 @ =gMain
ldr r0, _0809321C @ =0x0000043c
adds r1, r0
ldrb r0, [r1]
adds r0, 0x1
strb r0, [r1]
b _08093232
.align 2, 0
_08093218: .4byte gMain
_0809321C: .4byte 0x0000043c
_08093220:
bl nullsub_15
bl sub_8093800
bl sub_8093550
ldr r0, _08093238 @ =sub_809323C
bl SetMainCallback2
_08093232:
pop {r0}
bx r0
.align 2, 0
_08093238: .4byte sub_809323C
thumb_func_end sub_8093174
thumb_func_start sub_809323C
sub_809323C: @ 809323C
push {lr}
bl RunTasks
bl AnimateSprites
bl BuildOamBuffer
bl UpdatePaletteFade
pop {r0}
bx r0
thumb_func_end sub_809323C
thumb_func_start sub_8093254
sub_8093254: @ 8093254
push {lr}
bl LoadOam
bl ProcessSpriteCopyRequests
bl TransferPlttBuffer
ldr r2, _0809329C @ =0x02000000
ldrb r0, [r2, 0x6]
adds r0, 0x1
strb r0, [r2, 0x6]
lsls r0, 24
lsrs r0, 24
cmp r0, 0x3B
bls _0809327E
movs r0, 0
strb r0, [r2, 0x6]
ldrb r0, [r2, 0x5]
movs r1, 0x1
eors r0, r1
strb r0, [r2, 0x5]
_0809327E:
ldrb r0, [r2, 0x4]
cmp r0, 0
beq _08093298
ldr r1, _080932A0 @ =0x040000d4
ldr r0, _080932A4 @ =gUnknown_03004DE0
str r0, [r1]
movs r2, 0xF0
lsls r2, 3
adds r0, r2
str r0, [r1, 0x4]
ldr r0, _080932A8 @ =0x800000a0
str r0, [r1, 0x8]
ldr r0, [r1, 0x8]
_08093298:
pop {r0}
bx r0
.align 2, 0
_0809329C: .4byte 0x02000000
_080932A0: .4byte 0x040000d4
_080932A4: .4byte gUnknown_03004DE0
_080932A8: .4byte 0x800000a0
thumb_func_end sub_8093254
thumb_func_start sub_80932AC
sub_80932AC: @ 80932AC
push {r4,lr}
adds r4, r0, 0
ldr r0, _080932DC @ =nullsub_60
movs r1, 0xFF
bl CreateTask
adds r1, r0, 0
lsls r1, 24
lsrs r1, 24
lsls r0, r1, 2
adds r0, r1
lsls r0, 3
ldr r1, _080932E0 @ =gTasks
adds r0, r1
movs r1, 0
strh r1, [r0, 0x8]
adds r0, 0xC
adds r1, r4, 0
bl StoreWordInTwoHalfwords
pop {r4}
pop {r0}
bx r0
.align 2, 0
_080932DC: .4byte nullsub_60
_080932E0: .4byte gTasks
thumb_func_end sub_80932AC
thumb_func_start sub_80932E4
sub_80932E4: @ 80932E4
push {r4,r5,lr}
adds r4, r0, 0
adds r5, r1, 0
lsls r4, 24
lsrs r4, 24
ldr r0, _0809331C @ =nullsub_60
movs r1, 0xFF
bl CreateTask
adds r1, r0, 0
lsls r1, 24
lsrs r1, 24
lsls r0, r1, 2
adds r0, r1
lsls r0, 3
ldr r1, _08093320 @ =gTasks
adds r0, r1
movs r1, 0x1
strh r1, [r0, 0x8]
strh r4, [r0, 0xA]
adds r0, 0xC
adds r1, r5, 0
bl StoreWordInTwoHalfwords
pop {r4,r5}
pop {r0}
bx r0
.align 2, 0
_0809331C: .4byte nullsub_60
_08093320: .4byte gTasks
thumb_func_end sub_80932E4
thumb_func_start sub_8093324
sub_8093324: @ 8093324
push {r4,r5,lr}
ldr r0, _0809336C @ =nullsub_60
bl FindTaskIdByFunc
lsls r0, 24
lsrs r0, 24
lsls r1, r0, 2
adds r1, r0
lsls r1, 3
ldr r0, _08093370 @ =gTasks
adds r4, r1, r0
ldr r5, _08093374 @ =0x02000000
ldrh r0, [r4, 0x8]
strb r0, [r5, 0x1]
adds r0, r4, 0
adds r0, 0xC
adds r1, r5, 0
adds r1, 0x60
bl LoadWordFromTwoHalfwords
ldrb r0, [r5, 0x1]
cmp r0, 0
beq _0809337C
ldr r2, _08093378 @ =gUnknown_0202FFC0
movs r1, 0xA
ldrsh r0, [r4, r1]
lsls r1, r0, 3
subs r1, r0
lsls r1, 3
adds r1, r2
adds r0, r5, 0
adds r0, 0x64
movs r2, 0x38
bl memcpy
b _08093384
.align 2, 0
_0809336C: .4byte nullsub_60
_08093370: .4byte gTasks
_08093374: .4byte 0x02000000
_08093378: .4byte gUnknown_0202FFC0
_0809337C:
adds r0, r5, 0
adds r0, 0x64
bl sub_8093390
_08093384:
pop {r4,r5}
pop {r0}
bx r0
thumb_func_end sub_8093324
thumb_func_start nullsub_60
nullsub_60: @ 809338C
bx lr
thumb_func_end nullsub_60
thumb_func_start sub_8093390
sub_8093390: @ 8093390
push {r4-r7,lr}
adds r5, r0, 0
ldr r6, _080934A4 @ =gSaveBlock2
ldrb r0, [r6, 0x8]
strb r0, [r5]
ldrh r0, [r6, 0xE]
strh r0, [r5, 0x10]
ldrb r0, [r6, 0x10]
strh r0, [r5, 0x12]
movs r0, 0x1
bl sub_8053108
adds r4, r0, 0
movs r0, 0xA
bl sub_8053108
cmp r0, 0
bne _080933B6
movs r4, 0
_080933B6:
lsrs r0, r4, 16
strh r0, [r5, 0x6]
lsrs r0, r4, 8
movs r1, 0xFF
ands r0, r1
strh r0, [r5, 0x8]
ands r4, r1
strh r4, [r5, 0xA]
ldr r0, _080934A8 @ =0x00000801
bl FlagGet
strb r0, [r5, 0x2]
bl sub_8090FC0
strb r0, [r5, 0x3]
bl GetPokedexSeenCount
strh r0, [r5, 0xC]
ldrb r1, [r6, 0xB]
lsls r1, 8
ldrb r0, [r6, 0xA]
orrs r0, r1
strh r0, [r5, 0xE]
ldr r7, _080934AC @ =0x0000270f
movs r0, 0x17
adds r1, r7, 0
bl sav12_xor_get_clamped_above
strh r0, [r5, 0x14]
movs r0, 0x18
adds r1, r7, 0
bl sav12_xor_get_clamped_above
strh r0, [r5, 0x16]
ldr r1, _080934B0 @ =0x000003e7
movs r0, 0x23
bl sav12_xor_get_clamped_above
strh r0, [r5, 0x1C]
ldr r4, _080934B4 @ =0x0000ffff
movs r0, 0x22
adds r1, r4, 0
bl sav12_xor_get_clamped_above
strh r0, [r5, 0x1E]
movs r0, 0x15
adds r1, r4, 0
bl sav12_xor_get_clamped_above
strh r0, [r5, 0x20]
movs r1, 0xAE
lsls r1, 3
adds r0, r6, r1
ldrh r0, [r0]
strh r0, [r5, 0x18]
ldr r2, _080934B8 @ =0x00000572
adds r1, r6, r2
ldrh r1, [r1]
strh r1, [r5, 0x1A]
lsls r0, 16
lsrs r0, 16
cmp r0, r7
bls _08093436
strh r7, [r5, 0x18]
_08093436:
ldrh r0, [r5, 0x1A]
cmp r0, r7
bls _0809343E
strh r7, [r5, 0x1A]
_0809343E:
movs r4, 0
bl sub_80C4D50
lsls r0, 24
lsrs r0, 24
cmp r0, 0x4
bls _0809344E
movs r4, 0x1
_0809344E:
strb r4, [r5, 0x4]
ldr r0, _080934BC @ =gSaveBlock1
movs r2, 0x92
lsls r2, 3
adds r1, r0, r2
ldr r1, [r1]
str r1, [r5, 0x24]
movs r2, 0
adds r6, r5, 0
adds r6, 0x30
adds r3, r5, 0
adds r3, 0x28
ldr r1, _080934C0 @ =0x00002b1c
adds r4, r0, r1
_0809346A:
lsls r0, r2, 1
adds r1, r3, r0
adds r0, r4
ldrh r0, [r0]
strh r0, [r1]
adds r0, r2, 0x1
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0x3
bls _0809346A
movs r2, 0
adds r3, r6, 0
ldr r4, _080934A4 @ =gSaveBlock2
_08093484:
adds r1, r3, r2
adds r0, r2, r4
ldrb r0, [r0]
strb r0, [r1]
adds r0, r2, 0x1
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0x7
bls _08093484
adds r0, r5, 0
bl sub_80934F4
strb r0, [r5, 0x1]
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_080934A4: .4byte gSaveBlock2
_080934A8: .4byte 0x00000801
_080934AC: .4byte 0x0000270f
_080934B0: .4byte 0x000003e7
_080934B4: .4byte 0x0000ffff
_080934B8: .4byte 0x00000572
_080934BC: .4byte gSaveBlock1
_080934C0: .4byte 0x00002b1c
thumb_func_end sub_8093390
thumb_func_start sub_80934C4
sub_80934C4: @ 80934C4
lsls r0, 24
lsrs r0, 24
ldr r2, _080934D8 @ =gUnknown_0202FFC0
lsls r1, r0, 3
subs r1, r0
lsls r1, 3
adds r1, r2
ldrb r0, [r1, 0x1]
bx lr
.align 2, 0
_080934D8: .4byte gUnknown_0202FFC0
thumb_func_end sub_80934C4
thumb_func_start sav12_xor_get_clamped_above
sav12_xor_get_clamped_above: @ 80934DC
push {r4,lr}
adds r4, r1, 0
lsls r0, 24
lsrs r0, 24
bl sub_8053108
cmp r0, r4
bls _080934EE
adds r0, r4, 0
_080934EE:
pop {r4}
pop {r1}
bx r1
thumb_func_end sav12_xor_get_clamped_above
thumb_func_start sub_80934F4
sub_80934F4: @ 80934F4
push {lr}
adds r1, r0, 0
movs r2, 0
ldrh r0, [r1, 0x6]
cmp r0, 0
bne _08093506
ldr r0, [r1, 0x8]
cmp r0, 0
beq _08093508
_08093506:
movs r2, 0x1
_08093508:
ldrb r0, [r1, 0x3]
cmp r0, 0
beq _08093514
adds r0, r2, 0x1
lsls r0, 24
lsrs r2, r0, 24
_08093514:
ldrh r0, [r1, 0x1A]
cmp r0, 0x31
bls _08093520
adds r0, r2, 0x1
lsls r0, 24
lsrs r2, r0, 24
_08093520:
ldrb r0, [r1, 0x4]
cmp r0, 0
beq _0809352C
adds r0, r2, 0x1
lsls r0, 24
lsrs r2, r0, 24
_0809352C:
adds r0, r2, 0
pop {r1}
bx r1
thumb_func_end sub_80934F4
thumb_func_start sub_8093534
sub_8093534: @ 8093534
push {lr}
movs r0, 0
bl SetVBlankCallback
movs r0, 0
bl SetHBlankCallback
movs r1, 0x80
lsls r1, 19
movs r0, 0
strh r0, [r1]
pop {r0}
bx r0
thumb_func_end sub_8093534
thumb_func_start sub_8093550
sub_8093550: @ 8093550
push {r4,lr}
ldr r0, _08093588 @ =sub_8093254
bl SetVBlankCallback
ldr r3, _0809358C @ =0x04000208
ldrh r2, [r3]
movs r0, 0
strh r0, [r3]
ldr r4, _08093590 @ =0x04000200
ldrh r0, [r4]
movs r1, 0x3
orrs r0, r1
strh r0, [r4]
strh r2, [r3]
ldr r2, _08093594 @ =REG_DISPSTAT
ldrh r0, [r2]
movs r1, 0x18
orrs r0, r1
strh r0, [r2]
movs r1, 0x80
lsls r1, 19
movs r2, 0xFA
lsls r2, 5
adds r0, r2, 0
strh r0, [r1]
pop {r4}
pop {r0}
bx r0
.align 2, 0
_08093588: .4byte sub_8093254
_0809358C: .4byte 0x04000208
_08093590: .4byte 0x04000200
_08093594: .4byte REG_DISPSTAT
thumb_func_end sub_8093550
thumb_func_start sub_8093598
sub_8093598: @ 8093598
push {r4-r7,lr}

View File

@ -20,7 +20,7 @@ void current_map_music_set__default_for_battle(u16);
// asm/rom_8040EB4.o
void StoreWordInTwoHalfwords(u16 *, u32);
void LoadWordFromTwoHalfwords(u16 *, u32);
void LoadWordFromTwoHalfwords(u16 *, u32 *);
// asm/daycare.o
u8 daycare_count_pokemon(u8 *);
@ -244,10 +244,6 @@ void sub_8089668(void);
void sub_8089944(int i, int i1, int i2, int i3, int i4, int i5, int i6);
void sub_8089A70(void);
// asm/trainer_card.o
void sub_8093110(void (*)(void));
void sub_8093130(u8, void (*)(void));
// asm/rom_8094928.o
void sub_80961D8(void);
u8 pokemon_ailments_get_primary(u32);
@ -317,6 +313,7 @@ void sub_80C4940(void);
void sub_80C4980(u8);
// asm/script_pokemon_util_80C4BF0.o
u8 sub_80C4D50(void);
void ShowContestWinner(void);
void HealPlayerParty();
u8 ScriptGiveMon(u16, u8, u16, u32, u32, u8);

View File

@ -228,7 +228,9 @@ struct SaveBlock1
/*0x2B04*/ u16 outbreakPokemonMoves[4];
/*0x2B0C*/ u8 unk2B0C;
/*0x2B0D*/ u8 outbreakPokemonProbability;
/*0x2B0E*/ u8 filler_2B0E[0x2C6];
/*0x2B0E*/ u8 filler_2B0E[0xE];
/*0x2B1C*/ u16 unk2B1C[4];
/*0x2B24*/ u8 filler_2B24[0x2B0];
/*0x2DD4*/ struct EasyChatPair easyChatPairs[5]; //Dewford trend [0] and some other stuff
/*0x2DFC*/ u8 filler_2DFC[0x100];
/*0x2EFC*/ struct SB1_2EFC_Struct sb1_2EFC_struct[5];
@ -270,6 +272,14 @@ struct Pokedex
/*0x44*/ u8 seen[52];
};
struct SaveBlock2_Sub
{
/*0x0000, 0x00A8*/ u8 filler_000[0x4C8];
/*0x04C8, 0x0570*/ u16 var_4C8;
/*0x04CA, 0x0572*/ u16 var_4CA;
/*0x04CC, 0x0574*/ u8 filler_4CC[0x31C];
};
struct SaveBlock2
{
/*0x00*/ u8 playerName[8];
@ -291,7 +301,7 @@ struct SaveBlock2
/*0x90*/ u8 filler_90[0x8];
/*0x98*/ struct Time localTimeOffset;
/*0xA0*/ struct Time lastBerryTreeUpdate;
/*0xA8*/ u8 filler_A8[0x7E8];
/*0xA8*/ struct SaveBlock2_Sub filler_A8;
};
struct UnkStruct_8054FF8_Substruct

View File

@ -138,7 +138,7 @@ u8 *GetPokemonCategory(u16);
bool8 sub_8090D90(u16, u8);
u16 GetNationalPokedexCount(u8);
u16 GetHoennPokedexCount(u8);
bool8 sub_8090FC0(void);
u16 sub_8090FF4(void);
void sub_8091060(u16);
void sub_8091154(u16 order, int i, int i1);

View File

@ -9,6 +9,13 @@ struct UnkPlayerStruct
u8 player_field_1;
};
struct LinkPlayerMapObject {
u8 active;
u8 linkPlayerId;
u8 mapObjId;
u8 mode;
};
// sub_8052F5C
// flag_var_implications_of_teleport_
// new_game
@ -17,7 +24,7 @@ void sub_8053050(void);
// sub_805308C
void sub_80530AC(void);
void sav12_xor_increment(u8 index);
u32 sub_8053108(u8);
u32 sub_8053108(u8 index);
// sav12_xor_set
// sub_8053154
// sub_8053198

105
include/trainer_card.h Normal file
View File

@ -0,0 +1,105 @@
#ifndef GUARD_TRAINER_CARD_H
#define GUARD_TRAINER_CARD_H
struct TrainerCard {
/*0x00*/ u8 gender;
/*0x01*/ u8 var_1;
/*0x02*/ bool8 hasPokedex;
/*0x03*/ bool8 var_3;
/*0x04*/ bool8 var_4;
/*0x05*/ u8 var_5;
/*0x06*/ u16 firstHallOfFameA;
/*0x08*/ u16 firstHallOfFameB;
/*0x0A*/ u16 firstHallOfFameC;
/*0x0C*/ u16 pokedexSeen;
/*0x0E*/ u16 trainerId;
/*0x10*/ u16 playTimeHours;
/*0x12*/ u16 playTimeMinutes;
/*0x14*/ u16 linkBattleWins;
/*0x16*/ u16 linkBattleLosses;
/*0x18*/ u16 var_18;
/*0x1A*/ u16 var_1A;
/*0x1C*/ u16 contestsWithFriends;
/*0x1E*/ u16 pokeblocksWithFriends;
/*0x20*/ u16 pokemonTrades;
/*0x22*/ u16 var_22;
/*0x24*/ u32 money;
/*0x28*/ u16 var_28[4];
/*0x30*/ u8 playerName[8];
};
void sub_8093110(void (*)(void));
void sub_8093130(u8, void (*)(void));
void sub_8093324(void);
void sub_8093390(struct TrainerCard *);
u8 sub_80934C4(u8 id);
void sub_8093598(void);
void sub_80935EC(void);
void sub_8093610(void);
void sub_8093688(void);
// sub_80936D4
void sub_80937A4(void);
void sub_80937BC(void);
void sub_80937D8(void);
void sub_80937F0(void);
void nullsub_15(void);
void sub_8093800(void);
// sub_809380C
// sub_809382C
// sub_8093864
// sub_80938A8
// sub_80938CC
// sub_8093918
// sub_8093938
// sub_8093954
// sub_8093980
// sub_80939A4
// sub_80939C0
// sub_80939DC
// sub_8093A28
// sub_8093A48
// sub_8093A68
// sub_8093AA0
// sub_8093AF0
// sub_8093C0C
// sub_8093C38
// sub_8093D50
// sub_8093D7C
// sub_8093DAC
// sub_8093DC8
// sub_8093DEC
// sub_8093E04
// sub_8093E28
// sub_8093EA0
// sub_8093EF8
// sub_8093F14
// sub_8093F48
// sub_8093F64
// sub_8093F80
// sub_8093FD0
// sub_8094038
// sub_80940E4
// sub_8094110
// sub_8094140
// sub_8094188
// sub_80941D8
// sub_8094200
// sub_8094218
// sub_8094250
// sub_809429C
// sub_80942F8
// sub_8094334
// sub_8094354
// sub_80943C4
// sub_80943E4
// sub_8094428
// sub_8094448
// sub_8094498
// sub_80944B8
// sub_80944E8
// sub_8094508
// sub_8094538
// sub_8094558
// unref_sub_8094588
#endif // GUARD_TRAINER_CARD_H

View File

@ -109,6 +109,7 @@ SECTIONS {
src/option_menu.o(.text);
src/pokedex.o(.text);
asm/pokedex.o(.text);
src/trainer_card.o(.text);
asm/trainer_card.o(.text);
src/save_menu_util.o(.text);
asm/rom_8094928.o(.text);

View File

@ -67,7 +67,7 @@ void sub_8052DA8(void)
void sub_8052DE4(void)
{
CpuFill32(0, gSaveBlock2.filler_A8, sizeof(gSaveBlock2.filler_A8));
CpuFill32(0, &gSaveBlock2.filler_A8, sizeof(gSaveBlock2.filler_A8));
}
void sub_8052E04(void)

View File

@ -42,14 +42,6 @@ struct UnkTVStruct
u32 tv_field_4;
};
struct LinkPlayerMapObject
{
u8 active;
u8 linkPlayerId;
u8 mapObjId;
u8 mode;
};
struct UCoords32
{
u32 x, y;

View File

@ -11,6 +11,7 @@
#include "sprite.h"
#include "string_util.h"
#include "task.h"
#include "trainer_card.h"
#include "flag.h"
#include "rom4.h"
#include "safari_zone.h"

335
src/trainer_card.c Normal file
View File

@ -0,0 +1,335 @@
#include "global.h"
#include "trainer_card.h"
#include "asm.h"
#include "flag.h"
#include "flags.h"
#include "link.h"
#include "main.h"
#include "menu.h"
#include "palette.h"
#include "pokedex.h"
#include "rom4.h"
#include "save_menu_util.h"
#include "sprite.h"
#include "task.h"
typedef void (*Callback)(void);
struct Struct2000000
{
/*0x00*/ u8 filer0[1];
/*0x01*/ bool8 var_1;
/*0x02*/ u8 filer1[2];
/*0x04*/ u8 var_4;
/*0x05*/ u8 var_5;
/*0x06*/ u8 var_6;
/*0x07*/ u8 filler2[0x59];
/*0x60*/ Callback * var_60;
/*0x64*/ struct TrainerCard var_64;
/*0x9C*/ u8 language; // 0x9C
};
extern struct Struct2000000 unk_2000000;
extern struct LinkPlayerMapObject gLinkPlayerMapObjects[];
extern struct TrainerCard gTrainerCards[4];
enum {
TD_0,
TD_1,
TD_CALLBACK,
};
static void sub_8093174(void);
static void sub_809323C(void);
static void sub_8093254(void);
static void sub_80932AC(Callback callBack);
static void sub_80932E4(u8 arg1, Callback callBack);
static void nullsub_60(u8);
static u32 sav12_xor_get_clamped_above(u8 index, u32 maxVal);
static u8 sub_80934F4(struct TrainerCard *);
static void sub_8093534(void);
static void sub_8093550(void);
void sub_8093110(Callback arg1) {
sub_80932AC(arg1);
SetMainCallback2(sub_8093174);
unk_2000000.language = 2;
}
void sub_8093130(u8 playerIndex, Callback arg2) {
struct Struct2000000* r2;
struct LinkPlayer* r3;
struct LinkPlayerMapObject* r4;
u8 linkPlayerId;
sub_80932E4(playerIndex, arg2);
SetMainCallback2(sub_8093174);
r2 = &unk_2000000;
r3 = gLinkPlayers;
r4 = gLinkPlayerMapObjects;
linkPlayerId = r4[playerIndex].linkPlayerId;
r2->language = r3[linkPlayerId].language;
}
static void sub_8093174(void) {
switch (gMain.state) {
case 0:
sub_8093534();
sub_8093688();
gMain.state += 1;
break;
case 1:
sub_8093598();
gMain.state += 1;
break;
case 2:
sub_80935EC();
gMain.state += 1;
break;
case 3:
sub_8093610();
sub_80937A4();
gMain.state += 1;
break;
case 4:
sub_80937BC();
gMain.state += 1;
case 5:
if (MultistepInitMenuWindowContinue() == FALSE) {
return;
}
gMain.state += 1;
break;
case 6:
sub_80937F0();
gMain.state += 1;
break;
case 7:
sub_80937D8();
gMain.state += 1;
break;
case 8:
nullsub_15();
sub_8093800();
sub_8093550();
SetMainCallback2(sub_809323C);
break;
}
}
static void sub_809323C(void) {
RunTasks();
AnimateSprites();
BuildOamBuffer();
UpdatePaletteFade();
}
__attribute__((naked))
static void sub_8093254(void)
{
asm(".syntax unified\n\
push {lr}\n\
bl LoadOam\n\
bl ProcessSpriteCopyRequests\n\
bl TransferPlttBuffer\n\
ldr r2, _0809329C @ =0x02000000\n\
ldrb r0, [r2, 0x6]\n\
adds r0, 0x1\n\
strb r0, [r2, 0x6]\n\
lsls r0, 24\n\
lsrs r0, 24\n\
cmp r0, 0x3B\n\
bls _0809327E\n\
movs r0, 0\n\
strb r0, [r2, 0x6]\n\
ldrb r0, [r2, 0x5]\n\
movs r1, 0x1\n\
eors r0, r1\n\
strb r0, [r2, 0x5]\n\
_0809327E:\n\
ldrb r0, [r2, 0x4]\n\
cmp r0, 0\n\
beq _08093298\n\
ldr r1, _080932A0 @ =0x040000d4\n\
ldr r0, _080932A4 @ =gUnknown_03004DE0\n\
str r0, [r1]\n\
movs r2, 0xF0\n\
lsls r2, 3\n\
adds r0, r2\n\
str r0, [r1, 0x4]\n\
ldr r0, _080932A8 @ =0x800000a0\n\
str r0, [r1, 0x8]\n\
ldr r0, [r1, 0x8]\n\
_08093298:\n\
pop {r0}\n\
bx r0\n\
.align 2, 0\n\
_0809329C: .4byte 0x02000000\n\
_080932A0: .4byte 0x040000d4\n\
_080932A4: .4byte gUnknown_03004DE0\n\
_080932A8: .4byte 0x800000a0\n\
.syntax divided\n");
}
static void sub_80932AC(Callback callBack) {
u8 taskId = CreateTask(nullsub_60, 0xFF);
struct Task *task = &gTasks[taskId];
task->data[TD_0] = FALSE;
StoreWordInTwoHalfwords(&task->data[TD_CALLBACK], (u32) callBack);
}
static void sub_80932E4(u8 arg1, Callback callBack) {
u8 taskId = CreateTask(nullsub_60, 0xFF);
struct Task *task = &gTasks[taskId];
task->data[TD_0] = TRUE;
task->data[TD_1] = arg1;
StoreWordInTwoHalfwords(&task->data[TD_CALLBACK], (u32) callBack);
}
void sub_8093324(void) {
u8 taskId = FindTaskIdByFunc(nullsub_60);
struct Task *task = &gTasks[taskId];
unk_2000000.var_1 = task->data[TD_0];
LoadWordFromTwoHalfwords((u16 *) &task->data[TD_CALLBACK], (u32 *) &unk_2000000.var_60);
if (unk_2000000.var_1) {
struct TrainerCard (*trainerCards)[4] = &gTrainerCards;
s16 var = task->data[TD_1];
struct TrainerCard *dest = &(*trainerCards)[var];
memcpy(&unk_2000000.var_64, dest, sizeof(struct TrainerCard));
} else {
sub_8093390(&unk_2000000.var_64);
}
}
static void nullsub_60(u8 taskid) {
}
void sub_8093390(struct TrainerCard *arg1) {
u32 playTime;
bool32 enteredHallOfFame;
bool8 r4;
u8 i;
arg1->gender = gSaveBlock2.playerGender;
arg1->playTimeHours = gSaveBlock2.playTimeHours;
arg1->playTimeMinutes = gSaveBlock2.playTimeMinutes;
playTime = sub_8053108(GAME_STAT_FIRST_HOF_PLAY_TIME);
enteredHallOfFame = sub_8053108(GAME_STAT_ENTERED_HOF);
if (!enteredHallOfFame) {
playTime = 0;
}
arg1->firstHallOfFameA = playTime >> 16;
arg1->firstHallOfFameB = (playTime >> 8) & 0xFF;
arg1->firstHallOfFameC = playTime & 0xFF;
arg1->hasPokedex = FlagGet(SYS_POKEDEX_GET);
arg1->var_3 = sub_8090FC0();
arg1->pokedexSeen = GetPokedexSeenCount();
arg1->trainerId = (gSaveBlock2.playerTrainerId[1] << 8) | gSaveBlock2.playerTrainerId[0];
// Link Cable Battles
arg1->linkBattleWins = sav12_xor_get_clamped_above(GAME_STAT_LINK_BATTLE_WINS, 9999);
arg1->linkBattleLosses = sav12_xor_get_clamped_above(GAME_STAT_LINK_BATTLE_LOSSES, 9999);
// Contests w/ Friends
arg1->contestsWithFriends = sav12_xor_get_clamped_above(GAME_STAT_WON_LINK_CONTEST, 999);
// Pokéblocks w/ Friends
arg1->pokeblocksWithFriends = sav12_xor_get_clamped_above(GAME_STAT_POKEBLOCKS_WITH_FRIENDS, 0xFFFF);
// Pokémon Trades
arg1->pokemonTrades = sav12_xor_get_clamped_above(GAME_STAT_POKEMON_TRADES, 0xFFFF);
// Battle tower?
arg1->var_18 = gSaveBlock2.filler_A8.var_4C8;
arg1->var_1A = gSaveBlock2.filler_A8.var_4CA;
if (arg1->var_18 > 9999) {
arg1->var_18 = 9999;
}
if (arg1->var_1A > 9999) {
arg1->var_1A = 9999;
}
r4 = FALSE;
if (sub_80C4D50() > 4) {
r4 = TRUE;
}
arg1->var_4 = r4;
arg1->money = gSaveBlock1.money;
for (i = 0; i < 4; i++) {
arg1->var_28[i] = gSaveBlock1.unk2B1C[i];
}
for (i = 0; i < 8; i++) {
arg1->playerName[i] = gSaveBlock2.playerName[i];
}
arg1->var_1 = sub_80934F4(arg1);
}
u8 sub_80934C4(u8 id) {
return gTrainerCards[id].var_1;
}
static u32 sav12_xor_get_clamped_above(u8 index, u32 maxVal) {
u32 value = sub_8053108(index);
if (value > maxVal) {
value = maxVal;
}
return value;
}
static u8 sub_80934F4(struct TrainerCard *trainerCard) {
u8 value = 0;
if (trainerCard->firstHallOfFameA != 0 || trainerCard->firstHallOfFameB != 0 || trainerCard->firstHallOfFameC != 0) {
value += 1;
}
if (trainerCard->var_3) {
value += 1;
}
if (trainerCard->var_1A > 49) {
value += 1;
}
if (trainerCard->var_4) {
value += 1;
}
return value;
}
static void sub_8093534(void) {
SetVBlankCallback(NULL);
SetHBlankCallback(NULL);
REG_DISPCNT = 0;
}
static void sub_8093550(void) {
u16 backup;
SetVBlankCallback(sub_8093254);
backup = REG_IME;
REG_IME = 0;
REG_IE |= INTR_FLAG_VBLANK| INTR_FLAG_HBLANK;
REG_IME = backup;
REG_DISPSTAT |= DISPSTAT_VBLANK_INTR | DISPSTAT_HBLANK_INTR;
REG_DISPCNT = 0x1f40;
}

View File

@ -610,17 +610,8 @@ gUnknown_0202FFBA: @ 202FFBA
gUnknown_0202FFBC: @ 202FFBC
.space 0x4
gUnknown_0202FFC0: @ 202FFC0
.space 0x14
gUnknown_0202FFD4: @ 202FFD4
.space 0x2
gUnknown_0202FFD6: @ 202FFD6
.space 0x1A
gUnknown_0202FFF0: @ 202FFF0
.space 0xB0
gTrainerCards: @ 202FFC0
.space 0xE0
gPokemonStorage: @ 20300A0
.space 0x4