decompile clear_save_data_screen.

This commit is contained in:
ProjectRevoTPP 2017-10-21 00:44:17 -04:00
parent afd42c8e14
commit ae53458622
5 changed files with 215 additions and 419 deletions

View File

@ -1,399 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start c2_clear_save_data_screen_2
c2_clear_save_data_screen_2: @ 817ACC8
push {lr}
bl sub_817AE00
lsls r0, 24
cmp r0, 0
beq _0817ACDC
ldr r0, =sub_817ACE4
movs r1, 0
bl CreateTask
_0817ACDC:
pop {r0}
bx r0
.pool
thumb_func_end c2_clear_save_data_screen_2
thumb_func_start sub_817ACE4
sub_817ACE4: @ 817ACE4
push {r4,lr}
sub sp, 0xC
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
movs r0, 0
movs r1, 0
movs r2, 0x2
movs r3, 0xE
bl SetWindowBorderStyle
ldr r2, =gText_ClearAllSaveData
movs r0, 0x1
str r0, [sp]
movs r0, 0
str r0, [sp, 0x4]
str r0, [sp, 0x8]
movs r1, 0x1
movs r3, 0
bl PrintTextOnWindow
ldr r0, =gUnknown_085F06D8
movs r1, 0x2
movs r2, 0xE
movs r3, 0x1
bl CreateYesNoMenu
ldr r1, =gTasks
lsls r0, r4, 2
adds r0, r4
lsls r0, 3
adds r0, r1
ldr r1, =sub_817AD40
str r1, [r0]
add sp, 0xC
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_817ACE4
thumb_func_start sub_817AD40
sub_817AD40: @ 817AD40
push {r4,r5,lr}
sub sp, 0xC
lsls r0, 24
lsrs r5, r0, 24
bl sub_8198C58
lsls r0, 24
asrs r4, r0, 24
cmp r4, 0
beq _0817AD68
cmp r4, 0
bgt _0817AD62
movs r0, 0x1
negs r0, r0
cmp r4, r0
beq _0817ADA0
b _0817ADB2
_0817AD62:
cmp r4, 0x1
beq _0817ADA0
b _0817ADB2
_0817AD68:
movs r0, 0
movs r1, 0x11
bl FillWindowPixelBuffer
ldr r2, =gText_ClearingData
movs r0, 0x1
str r0, [sp]
str r4, [sp, 0x4]
str r4, [sp, 0x8]
movs r0, 0
movs r1, 0x1
movs r3, 0
bl PrintTextOnWindow
ldr r1, =gTasks
lsls r0, r5, 2
adds r0, r5
lsls r0, 3
adds r0, r1
ldr r1, =sub_817ADC0
str r1, [r0]
b _0817ADB2
.pool
_0817ADA0:
movs r0, 0x5
bl PlaySE
adds r0, r5, 0
bl DestroyTask
ldr r0, =sub_817AFD4
bl SetMainCallback2
_0817ADB2:
add sp, 0xC
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_817AD40
thumb_func_start sub_817ADC0
sub_817ADC0: @ 817ADC0
push {r4,lr}
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
bl ClearSaveData
adds r0, r4, 0
bl DestroyTask
ldr r0, =sub_817AFD4
bl SetMainCallback2
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_817ADC0
thumb_func_start sub_817ADE4
sub_817ADE4: @ 817ADE4
push {lr}
bl RunTasks
bl UpdatePaletteFade
pop {r0}
bx r0
thumb_func_end sub_817ADE4
thumb_func_start sub_817ADF4
sub_817ADF4: @ 817ADF4
push {lr}
bl TransferPlttBuffer
pop {r0}
bx r0
thumb_func_end sub_817ADF4
thumb_func_start sub_817AE00
sub_817AE00: @ 817AE00
push {r4,lr}
sub sp, 0xC
ldr r0, =gMain
movs r1, 0x87
lsls r1, 3
adds r0, r1
ldrb r0, [r0]
cmp r0, 0
beq _0817AE18
cmp r0, 0x1
bne _0817AE18
b _0817AFA4
_0817AE18:
movs r0, 0
bl SetVBlankCallback
movs r0, 0
movs r1, 0
bl SetGpuReg
movs r0, 0x10
movs r1, 0
bl SetGpuReg
movs r0, 0x12
movs r1, 0
bl SetGpuReg
movs r0, 0x1C
movs r1, 0
bl SetGpuReg
movs r0, 0x1E
movs r1, 0
bl SetGpuReg
movs r0, 0x40
movs r1, 0
bl SetGpuReg
movs r0, 0x44
movs r1, 0
bl SetGpuReg
movs r0, 0x48
movs r1, 0
bl SetGpuReg
movs r0, 0x4A
movs r1, 0
bl SetGpuReg
movs r0, 0x50
movs r1, 0
bl SetGpuReg
movs r0, 0x52
movs r1, 0
bl SetGpuReg
movs r0, 0x54
movs r1, 0
bl SetGpuReg
add r0, sp, 0x4
movs r4, 0
strh r4, [r0]
ldr r1, =0x040000d4
str r0, [r1]
movs r0, 0xC0
lsls r0, 19
str r0, [r1, 0x4]
ldr r0, =0x8100c000
str r0, [r1, 0x8]
ldr r0, [r1, 0x8]
movs r2, 0
str r2, [sp, 0x8]
add r0, sp, 0x8
str r0, [r1]
movs r0, 0xE0
lsls r0, 19
str r0, [r1, 0x4]
ldr r0, =0x85000100
str r0, [r1, 0x8]
ldr r0, [r1, 0x8]
add r0, sp, 0x4
strh r2, [r0]
str r0, [r1]
ldr r0, =0x05000002
str r0, [r1, 0x4]
ldr r0, =0x810001ff
str r0, [r1, 0x8]
ldr r0, [r1, 0x8]
bl ResetPaletteFade
ldr r2, =gPlttBufferUnfaded
ldr r0, =0x00007fff
strh r0, [r2]
ldr r1, =gPlttBufferFaded
strh r0, [r1]
ldr r0, =0x00003945
strh r0, [r2, 0x2]
strh r0, [r1, 0x2]
movs r1, 0
ldr r3, =0x06000020
ldr r0, =0x00001111
adds r2, r0, 0
_0817AED4:
lsls r0, r1, 1
adds r0, r3
strh r2, [r0]
adds r0, r1, 0x1
lsls r0, 16
lsrs r1, r0, 16
cmp r1, 0xF
bls _0817AED4
movs r1, 0
ldr r4, =0x0600f000
movs r3, 0x1
ldr r2, =0x000003ff
_0817AEEC:
lsls r0, r1, 1
adds r0, r4
strh r3, [r0]
adds r0, r1, 0x1
lsls r0, 16
lsrs r1, r0, 16
cmp r1, r2
bls _0817AEEC
bl ResetTasks
bl ResetSpriteData
movs r0, 0
bl ResetBgsAndClearDma3BusyFlags
ldr r1, =gUnknown_085F06C0
movs r0, 0
movs r2, 0x2
bl InitBgsFromTemplates
movs r1, 0x82
lsls r1, 5
movs r0, 0
bl SetGpuReg
movs r0, 0
bl ShowBg
movs r0, 0x3
bl ShowBg
movs r0, 0x50
movs r1, 0
bl SetGpuReg
bl sub_817B02C
ldr r0, =0x0000ffff
str r0, [sp]
movs r1, 0
movs r2, 0x10
movs r3, 0
bl BeginNormalPaletteFade
movs r0, 0x1
bl EnableInterrupts
ldr r0, =sub_817ADF4
bl SetVBlankCallback
ldr r0, =gMain
movs r1, 0x87
lsls r1, 3
adds r0, r1
movs r1, 0x1
strb r1, [r0]
b _0817AFC8
.pool
_0817AFA4:
bl UpdatePaletteFade
ldr r0, =gPaletteFade
ldrb r1, [r0, 0x7]
movs r0, 0x80
ands r0, r1
cmp r0, 0
bne _0817AFC8
ldr r0, =sub_817ADE4
bl SetMainCallback2
movs r0, 0x1
b _0817AFCA
.pool
_0817AFC8:
movs r0, 0
_0817AFCA:
add sp, 0xC
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_817AE00
thumb_func_start sub_817AFD4
sub_817AFD4: @ 817AFD4
push {r4,lr}
sub sp, 0x4
ldr r0, =gMain
movs r1, 0x87
lsls r1, 3
adds r4, r0, r1
ldrb r0, [r4]
cmp r0, 0
beq _0817AFEA
cmp r0, 0x1
beq _0817B008
_0817AFEA:
ldr r0, =0x0000ffff
str r0, [sp]
movs r1, 0
movs r2, 0
movs r3, 0x10
bl BeginNormalPaletteFade
movs r0, 0x1
strb r0, [r4]
b _0817B020
.pool
_0817B008:
bl UpdatePaletteFade
ldr r0, =gPaletteFade
ldrb r1, [r0, 0x7]
movs r0, 0x80
ands r0, r1
cmp r0, 0
bne _0817B020
bl FreeAllWindowBuffers
bl DoSoftReset
_0817B020:
add sp, 0x4
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_817AFD4
thumb_func_start sub_817B02C
sub_817B02C: @ 817B02C
push {lr}
ldr r0, =gUnknown_085F06C8
bl InitWindows
bl DeactivateAllTextPrinters
movs r0, 0
movs r1, 0
bl FillWindowPixelBuffer
movs r0, 0
movs r1, 0
movs r2, 0x2
movs r3, 0xE0
bl sub_80987D4
ldr r0, =gUnknown_0860F074
movs r1, 0xF0
movs r2, 0x20
bl LoadPalette
pop {r0}
bx r0
.pool
thumb_func_end sub_817B02C
.align 2, 0 @ Don't pad with nop.

View File

@ -1228,7 +1228,7 @@ c2_clear_save_data_screen_1: @ 80AAEF0
lsls r0, 24
cmp r0, 0
bne _080AAF02
ldr r0, =c2_clear_save_data_screen_2
ldr r0, =CB2_InitClearSaveDataScreen
bl SetMainCallback2
_080AAF02:
pop {r0}

View File

@ -1,17 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2
gUnknown_085F06C0:: @ 85F06C0
.4byte 0x000001f0, 0x000011e3
.align 2
gUnknown_085F06C8:: @ 85F06C8
window_template 0x00, 0x03, 0x0f, 0x1a, 0x04, 0x0f, 0x000b
window_template_terminator
.align 2
gUnknown_085F06D8:: @ 85F06D8
window_template 0x00, 0x03, 0x02, 0x05, 0x04, 0x0f, 0x0073

View File

@ -223,7 +223,7 @@ SECTIONS {
src/save_failed_screen.o(.text);
src/braille_puzzles.o(.text);
asm/pokeblock_feed.o(.text);
asm/clear_save_data_screen.o(.text);
src/clear_save_data_screen.o(.text);
asm/intro_credits_graphics.o(.text);
asm/evolution_graphics.o(.text);
asm/bard_music.o(.text);
@ -440,7 +440,7 @@ SECTIONS {
src/save_failed_screen.o(.rodata);
data/braille_puzzles.o(.rodata);
data/pokeblock_feed.o(.rodata);
data/clear_save_data_screen.o(.rodata);
src/clear_save_data_screen.o(.rodata);
data/intro_credits_graphics.o(.rodata);
data/evolution_graphics.o(.rodata);
data/bard_music.o(.rodata);

212
src/clear_save_data_screen.c Executable file
View File

@ -0,0 +1,212 @@
#include "global.h"
#include "task.h"
#include "menu.h"
#include "text.h"
#include "sound.h"
#include "main.h"
#include "save.h"
#include "palette.h"
#include "gpu_regs.h"
#include "bg.h"
#include "text_window.h"
#include "songs.h"
extern void CreateYesNoMenu(const struct WindowTemplate *windowTemplate, u16 borderFirstTileNum, u8 borderPalette, u8 initialCursorPos); // menu.s
extern s8 sub_8198C58(void); // menu.s
extern u8 gText_ClearAllSaveData[];
extern u8 gText_ClearingData[];
extern u16 gUnknown_0860F074[];
static void Task_DoClearSaveDataScreenYesNo(u8);
static void Task_ClearSaveDataScreenYesNoChoice(u8);
static void Task_ClearSaveData(u8);
static bool8 SetupClearSaveDataScreen(void);
static void CB2_FadeAndDoReset(void);
static void InitClearSaveDataScreenWindows(void);
static const struct BgTemplate sClearSaveBgTemplates[2] =
{
{
.bg = 0,
.charBaseIndex = 0,
.mapBaseIndex = 31,
.screenSize = 0,
.paletteMode = 0,
.priority = 0,
.baseTile = 0,
},
{
.bg = 3,
.charBaseIndex = 0,
.mapBaseIndex = 30,
.screenSize = 0,
.paletteMode = 0,
.priority = 1,
.baseTile = 0,
},
};
static const struct WindowTemplate sClearSaveTextWindow[] =
{
{
.priority = 0,
.tilemapLeft = 3,
.tilemapTop = 15,
.width = 26,
.height = 4,
.paletteNum = 15,
.baseBlock = 11,
},
DUMMY_WIN_TEMPLATE
};
static const struct WindowTemplate sClearSaveYesNo[] =
{
{
.priority = 0,
.tilemapLeft = 3,
.tilemapTop = 2,
.width = 5,
.height = 4,
.paletteNum = 15,
.baseBlock = 115,
}
};
void CB2_InitClearSaveDataScreen(void)
{
if(SetupClearSaveDataScreen())
CreateTask(Task_DoClearSaveDataScreenYesNo, 0);
}
static void Task_DoClearSaveDataScreenYesNo(u8 taskId)
{
SetWindowBorderStyle(0, 0, 2, 14);
PrintTextOnWindow(0, 1, gText_ClearAllSaveData, 0, 1, 0, 0);
CreateYesNoMenu(sClearSaveYesNo, 2, 14, 1);
gTasks[taskId].func = Task_ClearSaveDataScreenYesNoChoice;
}
static void Task_ClearSaveDataScreenYesNoChoice(u8 taskId)
{
switch(sub_8198C58())
{
case 0:
FillWindowPixelBuffer(0, 17);
PrintTextOnWindow(0, 1, gText_ClearingData, 0, 1, 0, 0);
gTasks[taskId].func = Task_ClearSaveData;
break;
case 1:
case -1:
PlaySE(SE_SELECT);
DestroyTask(taskId);
SetMainCallback2(CB2_FadeAndDoReset);
}
}
static void Task_ClearSaveData(u8 taskId)
{
ClearSaveData();
DestroyTask(taskId);
SetMainCallback2(CB2_FadeAndDoReset);
}
static void MainCB(void)
{
RunTasks();
UpdatePaletteFade();
}
static void VBlankCB(void)
{
TransferPlttBuffer();
}
static bool8 SetupClearSaveDataScreen(void)
{
u16 i;
switch(gMain.state)
{
case 0:
default:
SetVBlankCallback(NULL);
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0);
SetGpuReg(REG_OFFSET_BG0HOFS, DISPCNT_MODE_0);
SetGpuReg(REG_OFFSET_BG0VOFS, DISPCNT_MODE_0);
SetGpuReg(REG_OFFSET_BG3HOFS, DISPCNT_MODE_0);
SetGpuReg(REG_OFFSET_BG3VOFS, DISPCNT_MODE_0);
SetGpuReg(REG_OFFSET_WIN0H, DISPCNT_MODE_0);
SetGpuReg(REG_OFFSET_WIN0V, DISPCNT_MODE_0);
SetGpuReg(REG_OFFSET_WININ, DISPCNT_MODE_0);
SetGpuReg(REG_OFFSET_WINOUT, DISPCNT_MODE_0);
SetGpuReg(REG_OFFSET_BLDCNT, DISPCNT_MODE_0);
SetGpuReg(REG_OFFSET_BLDALPHA, DISPCNT_MODE_0);
SetGpuReg(REG_OFFSET_BLDY, DISPCNT_MODE_0);
DmaFill16(3, 0, (void *)VRAM, VRAM_SIZE);
DmaFill32(3, 0, (void *)OAM, OAM_SIZE);
DmaFill16(3, 0, (void *)(PLTT + 2), PLTT_SIZE - 2);
ResetPaletteFade();
gPlttBufferUnfaded[0] = 0x7fff;
gPlttBufferFaded[0] = 0x7fff;
gPlttBufferUnfaded[1] = 0x3945;
gPlttBufferFaded[1] = 0x3945;
for (i = 0; i < 0x10; i++)
((u16 *)(VRAM + 0x20))[i] = 0x1111;
for (i = 0; i < 0x400; i++)
((u16 *)(VRAM + 0xF000))[i] = 0x0001;
ResetTasks();
ResetSpriteData();
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, sClearSaveBgTemplates, ARRAY_COUNT(sClearSaveBgTemplates));
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
ShowBg(0);
ShowBg(3);
SetGpuReg(REG_OFFSET_BLDCNT, DISPCNT_MODE_0);
InitClearSaveDataScreenWindows();
BeginNormalPaletteFade(0x0000FFFF, 0, 0x10, 0, 0xFFFF);
EnableInterrupts(1);
SetVBlankCallback(VBlankCB);
gMain.state = 1;
break;
case 1:
UpdatePaletteFade();
if(!gPaletteFade.active)
{
SetMainCallback2(MainCB);
return TRUE;
}
}
return FALSE;
}
static void CB2_FadeAndDoReset(void)
{
switch(gMain.state)
{
case 0:
default:
BeginNormalPaletteFade(0x0000FFFF, 0, 0, 0x10, 0xFFFF);
gMain.state = 1;
break;
case 1:
UpdatePaletteFade();
if(!gPaletteFade.active)
{
FreeAllWindowBuffers();
DoSoftReset();
}
}
}
static void InitClearSaveDataScreenWindows(void)
{
InitWindows(sClearSaveTextWindow);
DeactivateAllTextPrinters();
FillWindowPixelBuffer(0, 0);
sub_80987D4(0, 0, 2, 224);
LoadPalette(gUnknown_0860F074, 0xF0, 0x20);
}