sub_81215EC

This commit is contained in:
PikalaxALT 2017-10-12 22:59:01 -04:00
parent 8d31a46c6f
commit 52af334b89
5 changed files with 159 additions and 430 deletions

View File

@ -5,434 +5,6 @@
.text
thumb_func_start sub_81215EC
sub_81215EC: @ 81215EC
push {r4-r6,lr}
sub sp, 0xC
ldr r0, =gMain
movs r1, 0x87
lsls r1, 3
adds r0, r1
ldrb r0, [r0]
cmp r0, 0x12
bls _08121600
b _081219E2
_08121600:
lsls r0, 2
ldr r1, =_08121614
adds r0, r1
ldr r0, [r0]
mov pc, r0
.pool
.align 2, 0
_08121614:
.4byte _08121660
.4byte _0812166E
.4byte _08121688
.4byte _0812168E
.4byte _08121694
.4byte _0812169A
.4byte _081216F4
.4byte _08121730
.4byte _08121740
.4byte _08121774
.4byte _08121782
.4byte _081217D8
.4byte _081217EC
.4byte _081218B0
.4byte _081218CC
.4byte _081218EC
.4byte _081218F6
.4byte _08121910
.4byte _08121980
_08121660:
movs r0, 0
bl SetVBlankCallback
bl remove_some_task
movs r0, 0
b _081216EC
_0812166E:
add r1, sp, 0x8
movs r0, 0
strh r0, [r1]
movs r1, 0xE0
lsls r1, 19
ldr r2, =0x01000200
add r0, sp, 0x8
bl CpuSet
b _081219D4
.pool
_08121688:
bl ResetPaletteFade
b _081219D4
_0812168E:
bl ResetTasks
b _081219D4
_08121694:
bl ResetSpriteData
b _081219D4
_0812169A:
bl FreeAllSpritePalettes
bl reset_temp_tile_data_buffers
movs r0, 0x10
movs r1, 0
bl SetGpuReg
movs r0, 0x12
movs r1, 0
bl SetGpuReg
movs r0, 0x14
movs r1, 0
bl SetGpuReg
movs r0, 0x16
movs r1, 0
bl SetGpuReg
movs r0, 0x1A
movs r1, 0
bl SetGpuReg
movs r0, 0x18
movs r1, 0
bl SetGpuReg
movs r0, 0x1C
movs r1, 0
bl SetGpuReg
movs r0, 0x1E
movs r1, 0
bl SetGpuReg
movs r0, 0x50
movs r1, 0
bl SetGpuReg
movs r0, 0x52
_081216EC:
movs r1, 0
bl SetGpuReg
b _081219D4
_081216F4:
movs r0, 0
bl ResetBgsAndClearDma3BusyFlags
ldr r1, =gUnknown_0859F290
movs r0, 0
movs r2, 0x3
bl InitBgsFromTemplates
ldr r4, =gUnknown_0203A134
ldr r1, [r4]
movs r2, 0x8B
lsls r2, 2
adds r1, r2
movs r0, 0x1
bl SetBgTilemapBuffer
ldr r1, [r4]
ldr r0, =0x0000122c
adds r1, r0
movs r0, 0x2
bl SetBgTilemapBuffer
b _081219D4
.pool
_08121730:
ldr r0, =gUnknown_0859F29C
bl InitWindows
bl DeactivateAllTextPrinters
b _081219D4
.pool
_08121740:
ldr r2, =gUnknown_0859F2B8
ldr r0, =gUnknown_0203A134
ldr r0, [r0]
ldr r1, =0x0000021a
adds r0, r1
ldrb r1, [r0]
lsls r0, r1, 2
adds r0, r1
lsls r0, 2
adds r2, 0x4
adds r0, r2
ldr r1, [r0]
movs r0, 0
str r0, [sp]
movs r0, 0x1
movs r2, 0
movs r3, 0
bl decompress_and_copy_tile_data_to_vram
b _081219D4
.pool
_08121774:
bl free_temp_tile_data_buffers_if_possible
lsls r0, 24
cmp r0, 0
bne _08121780
b _081219D4
_08121780:
b _081219E2
_08121782:
movs r5, 0x1E
str r5, [sp]
movs r4, 0x14
str r4, [sp, 0x4]
movs r0, 0
movs r1, 0
movs r2, 0
movs r3, 0
bl FillBgTilemapBufferRect_Palette0
str r5, [sp]
str r4, [sp, 0x4]
movs r0, 0x2
movs r1, 0x1
movs r2, 0
movs r3, 0
bl FillBgTilemapBufferRect_Palette0
ldr r2, =gUnknown_0859F2B8
ldr r0, =gUnknown_0203A134
ldr r0, [r0]
ldr r1, =0x0000021a
adds r0, r1
ldrb r1, [r0]
lsls r0, r1, 2
adds r0, r1
lsls r0, 2
adds r2, 0x8
adds r0, r2
ldr r1, [r0]
movs r0, 0x1
movs r2, 0
movs r3, 0
bl CopyToBgTilemapBuffer
b _081219D4
.pool
_081217D8:
movs r0, 0
bl CopyBgTilemapBufferToVram
movs r0, 0x1
bl CopyBgTilemapBufferToVram
movs r0, 0x2
bl CopyBgTilemapBufferToVram
b _081219D4
_081217EC:
bl sub_8098C64
movs r1, 0xF0
movs r2, 0x20
bl LoadPalette
ldr r6, =gPlttBufferUnfaded
ldr r4, =gUnknown_0859F2B8
ldr r0, =gUnknown_0203A134
ldr r3, [r0]
ldr r2, =0x0000021a
adds r3, r2
ldrb r1, [r3]
lsls r0, r1, 2
adds r0, r1
lsls r0, 2
adds r0, r4
ldrh r1, [r0, 0x10]
subs r2, 0x26
adds r0, r6, r2
strh r1, [r0]
ldr r5, =gPlttBufferFaded
ldrb r1, [r3]
lsls r0, r1, 2
adds r0, r1
lsls r0, 2
adds r0, r4
ldrh r0, [r0, 0x10]
adds r2, r5, r2
strh r0, [r2]
ldrb r1, [r3]
lsls r0, r1, 2
adds r0, r1
lsls r0, 2
adds r0, r4
ldrh r1, [r0, 0x12]
movs r2, 0xFB
lsls r2, 1
adds r0, r6, r2
strh r1, [r0]
ldrb r1, [r3]
lsls r0, r1, 2
adds r0, r1
lsls r0, 2
adds r0, r4
ldrh r0, [r0, 0x12]
adds r2, r5, r2
strh r0, [r2]
ldrb r1, [r3]
lsls r0, r1, 2
adds r0, r1
lsls r0, 2
adds r0, r4
ldr r0, [r0]
movs r1, 0
movs r2, 0x20
bl LoadPalette
ldr r1, =gUnknown_0859F2B0
ldr r0, =gSaveBlock2Ptr
ldr r2, [r0]
ldrb r0, [r2, 0x8]
lsls r0, 2
adds r0, r1
ldrh r0, [r0]
strh r0, [r6, 0x14]
ldrb r0, [r2, 0x8]
lsls r0, 2
adds r0, r1
ldrh r0, [r0]
strh r0, [r5, 0x14]
ldrb r0, [r2, 0x8]
lsls r0, 2
adds r1, 0x2
adds r0, r1
ldrh r0, [r0]
strh r0, [r6, 0x16]
ldrb r0, [r2, 0x8]
lsls r0, 2
adds r0, r1
ldrh r0, [r0]
strh r0, [r5, 0x16]
b _081219D4
.pool
_081218B0:
ldr r0, =gUnknown_0203A134
ldr r0, [r0]
movs r1, 0x86
lsls r1, 2
adds r0, r1
ldrb r0, [r0]
cmp r0, 0
bne _081218C2
b _081219D4
_081218C2:
bl sub_8121A1C
b _081219D4
.pool
_081218CC:
ldr r0, =gUnknown_0203A134
ldr r0, [r0]
movs r2, 0x86
lsls r2, 2
adds r0, r2
ldrb r0, [r0]
cmp r0, 0
bne _081218DE
b _081219D4
_081218DE:
bl sub_8121B1C
bl RunTextPrinters
b _081219D4
.pool
_081218EC:
bl sub_8087598
cmp r0, 0x1
bne _081219D4
b _081219E2
_081218F6:
ldr r0, =sub_8121C50
bl SetVBlankCallback
ldr r2, =gPaletteFade
ldrb r0, [r2, 0x8]
movs r1, 0x80
orrs r0, r1
strb r0, [r2, 0x8]
b _081219D4
.pool
_08121910:
ldr r5, =gUnknown_0203A134
ldr r0, [r5]
movs r1, 0x85
lsls r1, 2
adds r0, r1
ldr r0, [r0]
ldrh r0, [r0, 0x1E]
bl sub_80D2E84
lsls r0, 16
lsrs r4, r0, 16
ldr r0, [r5]
ldr r2, =0x0000021b
adds r0, r2
ldrb r0, [r0]
cmp r0, 0x1
beq _08121940
cmp r0, 0x2
beq _08121958
b _081219D4
.pool
_08121940:
adds r0, r4, 0
bl sub_80D2F68
ldr r1, =SpriteCallbackDummy
movs r0, 0
str r0, [sp]
str r0, [sp, 0x4]
adds r0, r4, 0
movs r2, 0x60
b _0812196A
.pool
_08121958:
adds r0, r4, 0
bl sub_80D2F68
ldr r1, =SpriteCallbackDummy
movs r0, 0
str r0, [sp]
str r0, [sp, 0x4]
adds r0, r4, 0
movs r2, 0x28
_0812196A:
movs r3, 0x80
bl sub_80D2D78
ldr r1, [r5]
movs r2, 0x87
lsls r2, 2
adds r1, r2
strb r0, [r1]
b _081219D4
.pool
_08121980:
movs r1, 0x82
lsls r1, 5
movs r0, 0
bl SetGpuReg
movs r0, 0
bl ShowBg
movs r0, 0x1
bl ShowBg
movs r0, 0x2
bl ShowBg
movs r0, 0x1
negs r0, r0
movs r1, 0
str r1, [sp]
movs r2, 0x10
movs r3, 0
bl BeginNormalPaletteFade
ldr r2, =gPaletteFade
ldrb r1, [r2, 0x8]
movs r0, 0x7F
ands r0, r1
strb r0, [r2, 0x8]
ldr r0, =gUnknown_0203A134
ldr r0, [r0]
movs r1, 0x84
lsls r1, 2
adds r0, r1
ldr r1, =sub_8121C98
str r1, [r0]
movs r0, 0x1
b _081219E4
.pool
_081219D4:
ldr r1, =gMain
movs r2, 0x87
lsls r2, 3
adds r1, r2
ldrb r0, [r1]
adds r0, 0x1
strb r0, [r1]
_081219E2:
movs r0, 0
_081219E4:
add sp, 0xC
pop {r4-r6}
pop {r1}
bx r1
.pool
thumb_func_end sub_81215EC
thumb_func_start sub_81219F0
sub_81219F0: @ 81219F0
push {lr}

View File

@ -19,5 +19,8 @@ void box_print(u8, u8, u8, u8, const void *, s8, const u8 *);
void sub_8198070(u8 windowId, bool8 copyToVram);
void SetWindowTemplateFields(struct WindowTemplate* template, u8 priority, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 palNum, u16 baseBlock);
void SetWindowBorderStyle(u8 windowId, bool8 copyToVram, u16 tileStart, u8 palette);
void reset_temp_tile_data_buffers(void);
int decompress_and_copy_tile_data_to_vram(u8 bg_id, void *src, int size, u16 offset, u8 mode);
bool8 free_temp_tile_data_buffers_if_possible(void);
#endif // GUARD_MENU_H

View File

@ -3,5 +3,8 @@
const u8 *GetMonIconPtr(u16 speciesId, u32 personality, u32 frameNo);
const u16 *GetValidMonIconPalettePtr(u16 speciesId);
u16 sub_80D2E84(u16 speciesId);
void sub_80D2F68(u16 iconId);
u8 sub_80D2D78(u16 iconId, void callback(struct Sprite *), u16 x, u16 y, u16 a4, u8 a5);
#endif // GUARD_POKEMON_ICON_H

View File

@ -29,5 +29,6 @@ const struct MapHeader *get_mapheader_by_bank_and_number(u8, u8);
void FieldObjectMoveDestCoords(struct MapObject *, u32, s16 *, s16 *);
void sub_8086230(void);
void c2_exit_to_overworld_2_switch(void);
bool32 sub_8087598(void);
#endif //GUARD_ROM4_H

View File

@ -2,6 +2,16 @@
// Includes
#include "global.h"
#include "main.h"
#include "rom4.h"
#include "task.h"
#include "unknown_task.h"
#include "palette.h"
#include "menu.h"
#include "text.h"
#include "text_window.h"
#include "gpu_regs.h"
#include "bg.h"
#include "pokemon_icon.h"
#include "species.h"
#include "malloc.h"
#include "easy_chat.h"
@ -32,7 +42,7 @@ struct Unk203A134
{
/*0x0000*/ u8 filler_0000[0x20c];
/*0x020C*/ MainCallback callback;
/*0x0210*/ u8 filler_0210[4];
/*0x0210*/ MainCallback callback2;
/*0x0214*/ struct MailStruct *mail;
/*0x0218*/ bool8 flag;
/*0x0219*/ u8 filler_0219[1];
@ -44,7 +54,8 @@ struct Unk203A134
/*0x0220*/ void (*parserSingle)(u8 *dest, u16 word);
/*0x0224*/ void (*parserMultiple)(u8 *dest, const u16 *src, u16 length1, u16 length2);
/*0x0228*/ const struct MailLayout *layout;
/*0x022c*/ u8 filler_022C[0x2000];
/*0x022c*/ u8 bg1TilemapBuffer[0x1000];
/*0x122c*/ u8 bg2TilemapBuffer[0x1000];
};
struct MailGraphics
@ -65,9 +76,17 @@ EWRAM_DATA struct Unk203A134 *gUnknown_0203A134;
// Static ROM declarations
void sub_81219F0(void);
void sub_8121A1C(void);
void sub_8121B1C(void);
void sub_8121C50(void);
void sub_8121C98(void);
// .rodata
extern const struct BgTemplate gUnknown_0859F290[];
extern const struct WindowTemplate gUnknown_0859F29C;
extern const u16 gUnknown_0859F2B0[][2];
extern const struct MailGraphics gUnknown_0859F2B8[];
extern const struct MailLayout gUnknown_0859F3B4[];
extern const struct MailLayout gUnknown_0859F458[];
@ -125,3 +144,134 @@ void sub_8121478(struct MailStruct *mail, MainCallback callback, bool8 flag) {
gUnknown_0203A134->flag = flag;
SetMainCallback2(sub_81219F0);
}
bool8 sub_81215EC(void)
{
u16 icon;
switch (gMain.state)
{
case 0:
SetVBlankCallback(NULL);
remove_some_task();
SetGpuReg(REG_OFFSET_DISPCNT, 0x0000);
break;
case 1:
CpuFill16(0, (void *)OAM, OAM_SIZE);
break;
case 2:
ResetPaletteFade();
break;
case 3:
ResetTasks();
break;
case 4:
ResetSpriteData();
break;
case 5:
FreeAllSpritePalettes();
reset_temp_tile_data_buffers();
SetGpuReg(REG_OFFSET_BG0HOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG0VOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG1HOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG1VOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG2VOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG2HOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG3HOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG3VOFS, 0x0000);
SetGpuReg(REG_OFFSET_BLDCNT, 0x0000);
SetGpuReg(REG_OFFSET_BLDALPHA, 0x0000);
break;
case 6:
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, gUnknown_0859F290, 3);
SetBgTilemapBuffer(1, gUnknown_0203A134->bg1TilemapBuffer);
SetBgTilemapBuffer(2, gUnknown_0203A134->bg2TilemapBuffer);
break;
case 7:
InitWindows(&gUnknown_0859F29C);
DeactivateAllTextPrinters();
break;
case 8:
decompress_and_copy_tile_data_to_vram(1, gUnknown_0859F2B8[gUnknown_0203A134->mailType].tiles, 0, 0, 0);
break;
case 9:
if (free_temp_tile_data_buffers_if_possible())
{
return FALSE;
}
break;
case 10:
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 30, 20);
FillBgTilemapBufferRect_Palette0(2, 1, 0, 0, 30, 20);
CopyToBgTilemapBuffer(1, gUnknown_0859F2B8[gUnknown_0203A134->mailType].tileMap, 0, 0);
break;
case 11:
CopyBgTilemapBufferToVram(0);
CopyBgTilemapBufferToVram(1);
CopyBgTilemapBufferToVram(2);
break;
case 12:
LoadPalette(sub_8098C64(), 240, 32);
gPlttBufferUnfaded[250] = gUnknown_0859F2B8[gUnknown_0203A134->mailType].color10;
gPlttBufferFaded[250] = gUnknown_0859F2B8[gUnknown_0203A134->mailType].color10;
gPlttBufferUnfaded[251] = gUnknown_0859F2B8[gUnknown_0203A134->mailType].color12;
gPlttBufferFaded[251] = gUnknown_0859F2B8[gUnknown_0203A134->mailType].color12;
LoadPalette(gUnknown_0859F2B8[gUnknown_0203A134->mailType].palette, 0, 32);
gPlttBufferUnfaded[10] = gUnknown_0859F2B0[gSaveBlock2Ptr->playerGender][0];
gPlttBufferFaded[10] = gUnknown_0859F2B0[gSaveBlock2Ptr->playerGender][0];
gPlttBufferUnfaded[11] = gUnknown_0859F2B0[gSaveBlock2Ptr->playerGender][1];
gPlttBufferFaded[11] = gUnknown_0859F2B0[gSaveBlock2Ptr->playerGender][1];
break;
case 13:
if (gUnknown_0203A134->flag)
{
sub_8121A1C();
}
break;
case 14:
if (gUnknown_0203A134->flag)
{
sub_8121B1C();
RunTextPrinters();
}
break;
case 15:
if (sub_8087598() == TRUE)
{
return FALSE;
}
break;
case 16:
SetVBlankCallback(sub_8121C50);
gPaletteFade.bufferTransferDisabled = TRUE;
break;
case 17:
icon = sub_80D2E84(gUnknown_0203A134->mail->species);
switch (gUnknown_0203A134->unk_021b)
{
case 1:
sub_80D2F68(icon);
gUnknown_0203A134->unk_021c = sub_80D2D78(icon, SpriteCallbackDummy, 0x60, 0x80, 0, 0);
break;
case 2:
sub_80D2F68(icon);
gUnknown_0203A134->unk_021c = sub_80D2D78(icon, SpriteCallbackDummy, 0x28, 0x80, 0, 0);
break;
}
break;
case 18:
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
ShowBg(0);
ShowBg(1);
ShowBg(2);
BeginNormalPaletteFade(-1, 0, 16, 0, 0);
gPaletteFade.bufferTransferDisabled = FALSE;
gUnknown_0203A134->callback2 = sub_8121C98;
return TRUE;
default:
return FALSE;
}
gMain.state ++;
return FALSE;
}