Start decompiling mystery gift

This commit is contained in:
PikalaxALT 2019-03-30 13:14:00 -04:00
parent ccac4694cd
commit ed53220be2
5 changed files with 261 additions and 286 deletions

View File

@ -5,236 +5,6 @@
.text .text
thumb_func_start sub_8018424
sub_8018424: @ 8018424
push {lr}
bl ProcessSpriteCopyRequests
bl LoadOam
bl TransferPlttBuffer
pop {r0}
bx r0
thumb_func_end sub_8018424
thumb_func_start sub_8018438
sub_8018438: @ 8018438
push {lr}
bl RunTasks
bl RunTextPrinters
bl AnimateSprites
bl BuildOamBuffer
pop {r0}
bx r0
thumb_func_end sub_8018438
thumb_func_start sub_8018450
sub_8018450: @ 8018450
push {r4-r7,lr}
sub sp, 0xC
adds r7, r0, 0
ldr r0, =gMain
movs r1, 0x87
lsls r1, 3
adds r6, r0, r1
ldrb r0, [r6]
cmp r0, 0x1
bne _08018466
b _08018574
_08018466:
cmp r0, 0x1
bgt _08018474
cmp r0, 0
beq _08018482
b _08018644
.pool
_08018474:
cmp r0, 0x2
bne _0801847A
b _080185F8
_0801847A:
cmp r0, 0x3
bne _08018480
b _08018618
_08018480:
b _08018644
_08018482:
movs r0, 0
bl SetVBlankCallback
bl ResetPaletteFade
bl ResetSpriteData
bl FreeAllSpritePalettes
bl ResetTasks
bl ScanlineEffect_Stop
movs r0, 0
bl ResetBgsAndClearDma3BusyFlags
ldr r1, =gUnknown_082F0598
movs r0, 0
movs r2, 0x4
bl InitBgsFromTemplates
movs r0, 0
movs r1, 0
movs r2, 0
bl ChangeBgX
movs r0, 0
movs r1, 0
movs r2, 0
bl ChangeBgY
movs r0, 0x1
movs r1, 0
movs r2, 0
bl ChangeBgX
movs r0, 0x1
movs r1, 0
movs r2, 0
bl ChangeBgY
movs r0, 0x2
movs r1, 0
movs r2, 0
bl ChangeBgX
movs r0, 0x2
movs r1, 0
movs r2, 0
bl ChangeBgY
movs r0, 0x3
movs r1, 0
movs r2, 0
bl ChangeBgX
movs r0, 0x3
movs r1, 0
movs r2, 0
bl ChangeBgY
movs r4, 0x80
lsls r4, 4
adds r0, r4, 0
bl Alloc
adds r1, r0, 0
movs r0, 0x3
bl SetBgTilemapBuffer
adds r0, r4, 0
bl Alloc
adds r1, r0, 0
movs r0, 0x2
bl SetBgTilemapBuffer
adds r0, r4, 0
bl Alloc
adds r1, r0, 0
movs r0, 0x1
bl SetBgTilemapBuffer
adds r0, r4, 0
bl Alloc
adds r1, r0, 0
movs r0, 0
bl SetBgTilemapBuffer
movs r0, 0x3
bl bgid_upload_textbox_1
ldr r0, =gUnknown_082F05A8
bl InitWindows
bl DeactivateAllTextPrinters
movs r1, 0xC0
lsls r1, 7
movs r0, 0
bl ClearGpuRegBits
movs r0, 0x50
movs r1, 0
bl SetGpuReg
movs r0, 0x52
movs r1, 0
bl SetGpuReg
movs r0, 0x54
movs r1, 0
bl SetGpuReg
b _08018610
.pool
_08018574:
ldr r0, =gUnkTextboxBorderPal
movs r1, 0
movs r2, 0x20
bl LoadPalette
movs r0, 0x2
bl stdpal_get
movs r1, 0xD0
movs r2, 0x20
bl LoadPalette
movs r0, 0xC0
bl sub_81978B0
movs r0, 0
movs r1, 0xA
movs r2, 0xE0
bl LoadUserWindowBorderGfx
movs r0, 0
movs r1, 0x1
movs r2, 0xF0
bl LoadUserWindowBorderGfx_
movs r4, 0x20
str r4, [sp]
str r4, [sp, 0x4]
movs r5, 0x11
str r5, [sp, 0x8]
movs r0, 0
movs r1, 0
movs r2, 0
movs r3, 0
bl FillBgTilemapBufferRect
str r4, [sp]
str r4, [sp, 0x4]
str r5, [sp, 0x8]
movs r0, 0x1
movs r1, 0
movs r2, 0
movs r3, 0
bl FillBgTilemapBufferRect
str r4, [sp]
str r4, [sp, 0x4]
str r5, [sp, 0x8]
movs r0, 0x2
movs r1, 0
movs r2, 0
movs r3, 0
bl FillBgTilemapBufferRect
movs r0, 0x3
bl sub_8018798
lsls r0, r7, 24
lsrs r0, 24
movs r1, 0
bl sub_80186EC
b _08018610
.pool
_080185F8:
movs r0, 0x3
bl CopyBgTilemapBufferToVram
movs r0, 0x2
bl CopyBgTilemapBufferToVram
movs r0, 0x1
bl CopyBgTilemapBufferToVram
movs r0, 0
bl CopyBgTilemapBufferToVram
_08018610:
ldrb r0, [r6]
adds r0, 0x1
strb r0, [r6]
b _08018644
_08018618:
movs r0, 0
bl ShowBg
movs r0, 0x3
bl ShowBg
ldr r0, =0x0000021d
bl PlayBGM
ldr r0, =sub_8018424
bl SetVBlankCallback
movs r0, 0xC5
bl EnableInterrupts
movs r0, 0x1
b _08018646
.pool
_08018644:
movs r0, 0
_08018646:
add sp, 0xC
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_8018450
thumb_func_start c2_mystery_gift thumb_func_start c2_mystery_gift
c2_mystery_gift: @ 8018650 c2_mystery_gift: @ 8018650
push {lr} push {lr}

View File

@ -3,60 +3,6 @@
.section .rodata .section .rodata
.align 2
gUnkTextboxBorderPal:: @ 82F0548
.incbin "graphics/interface/unk_textbox_border.gbapal"
.align 2
gUnkTextboxBorderGfx:: @ 82F0568
.incbin "graphics/interface/unk_textbox_border.4bpp.lz"
.align 2
gUnknown_082F0598:: @ 82F0598 struct BgTemplate
.4byte 0x000000f8
.4byte 0x000010e1
.4byte 0x000020d2
.4byte 0x000030c3
.align 2
gUnknown_082F05A8:: @ 82F05A8
window_template 0x00, 0x00, 0x00, 0x1e, 0x02, 0x0c, 0x0013
window_template 0x00, 0x01, 0x0f, 0x1c, 0x04, 0x0c, 0x004f
window_template 0x00, 0x00, 0x0f, 0x1e, 0x05, 0x0d, 0x004f
null_window_template
.align 2
gUnknown_082F05C8:: @ 82F05C8
window_template 0x00, 0x01, 0x0f, 0x1c, 0x04, 0x0c, 0x00e5
.align 2
gUnknown_082F05D0:: @ 82F05D0
window_template 0x00, 0x01, 0x0f, 0x14, 0x04, 0x0c, 0x00e5
.align 2
gUnknown_082F05D8:: @ 82F05D8
window_template 0x00, 0x01, 0x0f, 0x13, 0x04, 0x0c, 0x00e5
.align 2
gUnknown_082F05E0:: @ 82F05E0
window_template 0x00, 0x08, 0x06, 0x0e, 0x06, 0x0c, 0x0155
.align 2
gUnknown_082F05E8:: @ 82F05E8
window_template 0x00, 0x17, 0x0f, 0x06, 0x04, 0x0c, 0x0155
.align 2
gUnknown_082F05F0:: @ 82F05F0
window_template 0x00, 0x16, 0x0b, 0x07, 0x08, 0x0c, 0x0155
.align 2
gUnknown_082F05F8:: @ 82F05F8
window_template 0x00, 0x16, 0x0d, 0x07, 0x06, 0x0c, 0x0155
.align 2
gUnknown_082F0600:: @ 82F0600
window_template 0x00, 0x16, 0x0f, 0x07, 0x04, 0x0c, 0x0155
.align 2 .align 2
gUnknown_082F0608:: @ 82F0608 gUnknown_082F0608:: @ 82F0608
.4byte gText_WonderCards, 0x00000000 .4byte gText_WonderCards, 0x00000000

4
include/mystery_gift.h Normal file
View File

@ -0,0 +1,4 @@
#ifndef GUARD_MYSTERY_GIFT_H
#define GUARD_MYSTERY_GIFT_H
#endif //GUARD_MYSTERY_GIFT_H

View File

@ -55,7 +55,8 @@ SECTIONS {
src/link.o(.text); src/link.o(.text);
src/link_rfu.o(.text); src/link_rfu.o(.text);
src/union_room.o(.text); src/union_room.o(.text);
asm/union_room.o(.text); src/mystery_gift.o(.text);
asm/mystery_gift.o(.text);
src/mevent2.o(.text); src/mevent2.o(.text);
src/mevent_801BAAC.o(.text); src/mevent_801BAAC.o(.text);
asm/mevent_server.o(.text); asm/mevent_server.o(.text);
@ -408,7 +409,8 @@ SECTIONS {
src/link.o(.rodata); src/link.o(.rodata);
src/link_rfu.o(.rodata); src/link_rfu.o(.rodata);
src/union_room.o(.rodata); src/union_room.o(.rodata);
data/union_room.o(.rodata); src/mystery_gift.o(.rodata);
data/mystery_gift.o(.rodata);
src/mevent2.o(.rodata); src/mevent2.o(.rodata);
src/mevent_801BAAC.o(.rodata); src/mevent_801BAAC.o(.rodata);
data/mevent_server.o(.rodata); data/mevent_server.o(.rodata);

253
src/mystery_gift.c Normal file
View File

@ -0,0 +1,253 @@
#include "global.h"
#include "main.h"
#include "text.h"
#include "task.h"
#include "alloc.h"
#include "gpu_regs.h"
#include "scanline_effect.h"
#include "text_window.h"
#include "bg.h"
#include "window.h"
#include "text_window.h"
#include "menu.h"
#include "palette.h"
#include "constants/songs.h"
#include "sound.h"
#include "mystery_gift.h"
void bgid_upload_textbox_1(u8 bgId);
void sub_8018798(u8);
void sub_80186EC(u8, u8);
const u16 gUnkTextboxBorderPal[] = INCBIN_U16("graphics/interface/unk_textbox_border.gbapal");
const u32 gUnkTextboxBorderGfx[] = INCBIN_U32("graphics/interface/unk_textbox_border.4bpp.lz");
const struct BgTemplate gUnknown_082F0598[] = {
{
.bg = 0,
.charBaseIndex = 2,
.mapBaseIndex = 15,
.screenSize = 0,
.paletteMode = 0,
.priority = 0,
.baseTile = 0x000
}, {
.bg = 1,
.charBaseIndex = 0,
.mapBaseIndex = 14,
.screenSize = 0,
.paletteMode = 0,
.priority = 1,
.baseTile = 0x000
}, {
.bg = 2,
.charBaseIndex = 0,
.mapBaseIndex = 13,
.screenSize = 0,
.paletteMode = 0,
.priority = 2,
.baseTile = 0x000
}, {
.bg = 3,
.charBaseIndex = 0,
.mapBaseIndex = 12,
.screenSize = 0,
.paletteMode = 0,
.priority = 3,
.baseTile = 0x000
}
};
const struct WindowTemplate gUnknown_082F05A8[] = {
{
.bg = 0x00,
.tilemapLeft = 0x00,
.tilemapTop = 0x00,
.width = 0x1e,
.height = 0x02,
.paletteNum = 0x0c,
.baseBlock = 0x0013
}, {
.bg = 0x00,
.tilemapLeft = 0x01,
.tilemapTop = 0x0f,
.width = 0x1c,
.height = 0x04,
.paletteNum = 0x0c,
.baseBlock = 0x004f
}, {
.bg = 0x00,
.tilemapLeft = 0x00,
.tilemapTop = 0x0f,
.width = 0x1e,
.height = 0x05,
.paletteNum = 0x0d,
.baseBlock = 0x004f
}, {
0xFF
}
};
const struct WindowTemplate gUnknown_082F05C8 = {
.bg = 0x00,
.tilemapLeft = 0x01,
.tilemapTop = 0x0f,
.width = 0x1c,
.height = 0x04,
.paletteNum = 0x0c,
.baseBlock = 0x00e5
};
const struct WindowTemplate gUnknown_082F05D0 = {
.bg = 0x00,
.tilemapLeft = 0x01,
.tilemapTop = 0x0f,
.width = 0x14,
.height = 0x04,
.paletteNum = 0x0c,
.baseBlock = 0x00e5
};
const struct WindowTemplate gUnknown_082F05D8 = {
.bg = 0x00,
.tilemapLeft = 0x01,
.tilemapTop = 0x0f,
.width = 0x13,
.height = 0x04,
.paletteNum = 0x0c,
.baseBlock = 0x00e5
};
const struct WindowTemplate gUnknown_082F05E0 = {
.bg = 0x00,
.tilemapLeft = 0x08,
.tilemapTop = 0x06,
.width = 0x0e,
.height = 0x06,
.paletteNum = 0x0c,
.baseBlock = 0x0155
};
const struct WindowTemplate gUnknown_082F05E8 = {
.bg = 0x00,
.tilemapLeft = 0x17,
.tilemapTop = 0x0f,
.width = 0x06,
.height = 0x04,
.paletteNum = 0x0c,
.baseBlock = 0x0155
};
const struct WindowTemplate gUnknown_082F05F0 = {
.bg = 0x00,
.tilemapLeft = 0x16,
.tilemapTop = 0x0b,
.width = 0x07,
.height = 0x08,
.paletteNum = 0x0c,
.baseBlock = 0x0155
};
const struct WindowTemplate gUnknown_082F05F8 = {
.bg = 0x00,
.tilemapLeft = 0x16,
.tilemapTop = 0x0d,
.width = 0x07,
.height = 0x06,
.paletteNum = 0x0c,
.baseBlock = 0x0155
};
const struct WindowTemplate gUnknown_082F0600 = {
.bg = 0x00,
.tilemapLeft = 0x16,
.tilemapTop = 0x0f,
.width = 0x07,
.height = 0x04,
.paletteNum = 0x0c,
.baseBlock = 0x0155
};
void sub_8018424(void)
{
ProcessSpriteCopyRequests();
LoadOam();
TransferPlttBuffer();
}
void sub_8018438(void)
{
RunTasks();
RunTextPrinters();
AnimateSprites();
BuildOamBuffer();
}
bool32 sub_8018450(s32 arg)
{
switch (gMain.state)
{
case 0:
SetVBlankCallback(NULL);
ResetPaletteFade();
ResetSpriteData();
FreeAllSpritePalettes();
ResetTasks();
ScanlineEffect_Stop();
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, gUnknown_082F0598, ARRAY_COUNT(gUnknown_082F0598));
ChangeBgX(0, 0, 0);
ChangeBgY(0, 0, 0);
ChangeBgX(1, 0, 0);
ChangeBgY(1, 0, 0);
ChangeBgX(2, 0, 0);
ChangeBgY(2, 0, 0);
ChangeBgX(3, 0, 0);
ChangeBgY(3, 0, 0);
SetBgTilemapBuffer(3, Alloc(0x800));
SetBgTilemapBuffer(2, Alloc(0x800));
SetBgTilemapBuffer(1, Alloc(0x800));
SetBgTilemapBuffer(0, Alloc(0x800));
bgid_upload_textbox_1(3);
InitWindows(gUnknown_082F05A8);
DeactivateAllTextPrinters();
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_WIN1_ON);
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 0);
gMain.state++;
break;
case 1:
LoadPalette(gUnkTextboxBorderPal, 0, 0x20);
LoadPalette(stdpal_get(2), 0xd0, 0x20);
sub_81978B0(0xC0);
LoadUserWindowBorderGfx(0, 0xA, 0xE0);
LoadUserWindowBorderGfx_(0, 0x1, 0xF0);
FillBgTilemapBufferRect(0, 0x000, 0, 0, 32, 32, 0x11);
FillBgTilemapBufferRect(1, 0x000, 0, 0, 32, 32, 0x11);
FillBgTilemapBufferRect(2, 0x000, 0, 0, 32, 32, 0x11);
sub_8018798(3);
sub_80186EC(arg, 0);
gMain.state++;
break;
case 2:
CopyBgTilemapBufferToVram(3);
CopyBgTilemapBufferToVram(2);
CopyBgTilemapBufferToVram(1);
CopyBgTilemapBufferToVram(0);
gMain.state++;
break;
case 3:
ShowBg(0);
ShowBg(3);
PlayBGM(MUS_RG_OKURIMONO);
SetVBlankCallback(sub_8018424);
EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_VCOUNT | INTR_FLAG_TIMER3 | INTR_FLAG_SERIAL);
return TRUE;
}
return FALSE;
}