Start decompilation of lilycove_lady

This commit is contained in:
scnorton 2017-09-19 16:17:23 -04:00
parent e23fb64dad
commit e7e1938094
5 changed files with 95 additions and 95 deletions

View File

@ -5,99 +5,6 @@
.text
thumb_func_start GetLilycoveLadyId
GetLilycoveLadyId: @ 818D9AC
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
ldr r1, =0x00003b58
adds r0, r1
ldrb r0, [r0]
bx lr
.pool
thumb_func_end GetLilycoveLadyId
thumb_func_start sub_818D9C0
sub_818D9C0: @ 818D9C0
push {r4,r5,lr}
ldr r5, =0x00004010
ldr r4, =gUnknown_0860B07E
bl GetLilycoveLadyId
lsls r0, 24
lsrs r0, 23
adds r0, r4
ldrh r1, [r0]
adds r0, r5, 0
bl VarSet
bl GetLilycoveLadyId
lsls r0, 24
lsrs r0, 24
cmp r0, 0x2
bne _0818DA20
ldr r0, =gSaveBlock1Ptr
ldr r1, [r0]
ldr r0, =0x00003b58
adds r1, r0
ldr r0, =0x00004011
ldr r2, =gUnknown_0860B074
ldrb r1, [r1, 0xD]
lsls r1, 1
adds r1, r2
ldrh r1, [r1]
bl VarSet
ldr r1, =gScriptResult
movs r0, 0x1
b _0818DA24
.pool
_0818DA20:
ldr r1, =gScriptResult
movs r0, 0
_0818DA24:
strh r0, [r1]
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_818D9C0
thumb_func_start SetLilycoveLady
SetLilycoveLady: @ 818DA30
push {lr}
ldr r0, =gSaveBlock2Ptr
ldr r0, [r0]
ldrb r1, [r0, 0xB]
lsls r1, 8
ldrb r0, [r0, 0xA]
orrs r0, r1
movs r1, 0x6
bl __umodsi3
lsls r0, 16
lsrs r0, 17
adds r1, r0, 0
cmp r0, 0x1
beq _0818DA68
cmp r0, 0x1
bgt _0818DA5C
cmp r0, 0
beq _0818DA62
b _0818DA72
.pool
_0818DA5C:
cmp r1, 0x2
beq _0818DA6E
b _0818DA72
_0818DA62:
bl SetLilycoveQuizLady
b _0818DA72
_0818DA68:
bl SetLilycoveFavourLady
b _0818DA72
_0818DA6E:
bl SetLilycoveContestLady
_0818DA72:
pop {r0}
bx r0
thumb_func_end SetLilycoveLady
thumb_func_start sub_818DA78
sub_818DA78: @ 818DA78
push {lr}

View File

@ -655,6 +655,39 @@ struct DaycareData
#define FLAGS_COUNT 300
#define VARS_COUNT 256
enum {
LILYCOVE_LADY_QUIZ,
LILYCOVE_LADY_FAVOUR,
LILYCOVE_LADY_CONTEST
};
typedef union // TODO
{
struct
{
/*0x000*/ u8 id;
/*0x001*/ u8 language;
} quiz;
struct
{
/*0x000*/ u8 id;
} flavor;
struct
{
/*0x000*/ u8 id;
/*0x001*/ u8 filler_001[12];
/*0x00d*/ u8 category; // maybe?
} contest;
struct
{
/*0x000*/ u8 id;
/*0x001*/ u8 filler_001[535];
} common;
} LilycoveLady;
struct SaveBlock1
{
/*0x00*/ struct Coords16 pos;
@ -738,7 +771,7 @@ struct SaveBlock1
/*0x3728*/ struct RamScript ramScript;
/*0x3B14*/ struct RecordMixingGift recordMixingGift;
/*0x3B24*/ u8 seen2[52];
/*0x3B58*/ u8 lilycoveLady[536]; // TODO: convert to a union
/*0x3B58*/ LilycoveLady lilycoveLady; // TODO: convert to a union
/*0x3D70*/ u8 babyPhrase[24]; // TODO: convert to a struct
// sizeof: 0x3D88
};

View File

@ -12,6 +12,8 @@
#define VAR_0x4008 0x4008
#define VAR_0x4009 0x4009
#define VAR_0x400A 0x400A
#define VAR_0x4010 0x4010
#define VAR_0x4011 0x4011
#define VAR_0x401F 0x401F
#define VAR_RECYCLE_GOODS 0x4020
#define VAR_REPEL_STEP_COUNT 0x4021

View File

@ -240,6 +240,7 @@ SECTIONS {
asm/battle_controller_recorded_opponent.o(.text);
asm/battle_controller_recorded_player.o(.text);
asm/battle_dome_cards.o(.text);
src/lilycove_lady.o(.text);
asm/lilycove_lady.o(.text);
asm/battle_frontier_1.o(.text);
asm/new_menu_helpers.o(.text);

57
src/lilycove_lady.c Normal file
View File

@ -0,0 +1,57 @@
//
// Created by Scott Norton on 9/19/17.
//
#include "global.h"
#include "event_data.h"
#include "lilycove_lady.h"
void SetLilycoveQuizLady(void);
void SetLilycoveFavourLady(void);
void SetLilycoveContestLady(void);
extern const u16 gUnknown_0860B074[];
extern const u16 gUnknown_0860B07E[];
u8 GetLilycoveLadyId(void)
{
return gSaveBlock1Ptr->lilycoveLady.common.id;
}
void sub_818D9C0(void)
{
LilycoveLady *lilycoveLady;
VarSet(VAR_0x4010, gUnknown_0860B07E[GetLilycoveLadyId()]);
if (GetLilycoveLadyId() == LILYCOVE_LADY_CONTEST)
{
lilycoveLady = &gSaveBlock1Ptr->lilycoveLady;
VarSet(VAR_0x4011, gUnknown_0860B074[lilycoveLady->contest.category]);
gScriptResult = TRUE;
}
else
{
gScriptResult = FALSE;
}
}
void SetLilycoveLady(void)
{
u16 id;
id = ((gSaveBlock2Ptr->playerTrainerId[1] << 8) | gSaveBlock2Ptr->playerTrainerId[0]);
id %= 6;
id >>= 1;
switch (id)
{
case LILYCOVE_LADY_QUIZ:
SetLilycoveQuizLady();
break;
case LILYCOVE_LADY_FAVOUR:
SetLilycoveFavourLady();
break;
case LILYCOVE_LADY_CONTEST:
SetLilycoveContestLady();
break;
}
}