decompile option menu

This commit is contained in:
DizzyEggg 2018-01-16 18:59:06 +01:00
parent 11cb3275cc
commit a6072ae293
45 changed files with 728 additions and 1757 deletions

View File

@ -18852,7 +18852,7 @@ _0810800C:
negs r0, r0
cmp r1, r0
bne _08108022
bl remove_some_task
bl ScanlineEffect_Stop
adds r0, r7, 0
bl DestroyTask
_08108022:

View File

@ -9449,7 +9449,7 @@ _08193AA8:
b _08193BC2
_08193ABA:
bl FreeAllWindowBuffers
bl remove_some_task
bl ScanlineEffect_Stop
ldr r4, =gUnknown_0203CD7C
ldr r0, [r4]
bl Free
@ -9494,7 +9494,7 @@ _08193B20:
cmp r6, 0
bne _08193BC2
bl FreeAllWindowBuffers
bl remove_some_task
bl ScanlineEffect_Stop
ldr r4, =gUnknown_0203CD7C
ldr r0, [r4]
bl Free
@ -9534,7 +9534,7 @@ _08193B84:
cmp r6, 0
bne _08193BC2
bl FreeAllWindowBuffers
bl remove_some_task
bl ScanlineEffect_Stop
ldr r4, =gUnknown_0203CD7C
ldr r0, [r4]
bl Free

View File

@ -1034,7 +1034,7 @@ _0813C6FA:
thumb_func_start sub_813C80C
sub_813C80C: @ 813C80C
push {lr}
bl remove_some_task
bl ScanlineEffect_Stop
bl ResetTasks
bl ResetSpriteData
bl ResetPaletteFade

View File

@ -119,7 +119,7 @@ _08177D18:
bl clear_scheduled_bg_copies_to_vram
b _08177DDC
_08177D26:
bl remove_some_task
bl ScanlineEffect_Stop
b _08177DDC
_08177D2C:
bl ResetPaletteFade

View File

@ -88,7 +88,7 @@ _0814FD20:
bl SetVBlankCallback
movs r0, 0
bl sub_8150B6C
bl remove_some_task
bl ScanlineEffect_Stop
movs r3, 0xC0
lsls r3, 19
movs r4, 0xC0

View File

@ -107,7 +107,7 @@ _0812FE80:
.4byte _0812FF2A
.4byte _0812FF54
_0812FE94:
bl remove_some_task
bl ScanlineEffect_Stop
movs r0, 0
bl SetVBlankCallback
bl AllocateMonSpritesGfx

View File

@ -9621,7 +9621,7 @@ _080AFE64:
ldrsh r0, [r4, r3]
cmp r0, 0x1
bne _080AFEB4
bl remove_some_task
bl ScanlineEffect_Stop
movs r0, 0x2
strh r0, [r4]
b _080AFEC6
@ -9714,7 +9714,7 @@ _080AFF28:
ldrsh r0, [r4, r3]
cmp r0, 0x1
bne _080AFF78
bl remove_some_task
bl ScanlineEffect_Stop
movs r0, 0x2
strh r0, [r4]
b _080AFF8A

View File

@ -184,7 +184,7 @@ _0816CCF4:
movs r0, 0
movs r2, 0
bl load_copyright_graphics
bl remove_some_task
bl ScanlineEffect_Stop
bl ResetTasks
bl ResetSpriteData
bl FreeAllSpritePalettes

View File

@ -343,7 +343,7 @@ _081AAE34:
bl clear_scheduled_bg_copies_to_vram
b _081AB012
_081AAE3E:
bl remove_some_task
bl ScanlineEffect_Stop
ldr r1, =gMain
movs r2, 0x87
lsls r2, 3

View File

@ -3360,7 +3360,7 @@ c2_800ACD4: @ 800AF30
movs r2, 0x2
bl FillPalette
bl ResetTasks
bl remove_some_task
bl ScanlineEffect_Stop
ldr r1, =gLinkVSyncDisabled
ldrb r0, [r1]
cmp r0, 0
@ -28637,7 +28637,7 @@ _08018482:
bl ResetSpriteData
bl FreeAllSpritePalettes
bl ResetTasks
bl remove_some_task
bl ScanlineEffect_Stop
movs r0, 0
bl ResetBgsAndClearDma3BusyFlags
ldr r1, =gUnknown_082F0598
@ -32620,7 +32620,7 @@ sub_801A43C: @ 801A43C
bl ResetPaletteFade
bl ResetSpriteData
bl ResetTasks
bl remove_some_task
bl ScanlineEffect_Stop
bl m4aSoundVSyncOn
ldr r0, =sub_801A418
bl SetVBlankCallback
@ -45999,7 +45999,7 @@ _080210A0:
movs r0, 0
movs r1, 0
bl SetGpuReg
bl remove_some_task
bl ScanlineEffect_Stop
bl reset_temp_tile_data_buffers
b _080212FC
_080210BE:
@ -61951,7 +61951,7 @@ sub_8028FF8: @ 8028FF8
lsls r4, 24
lsrs r4, 24
adds r0, r4, 0
bl sub_8098758
bl GetWindowFrameTilesPal
ldr r1, [r0]
movs r2, 0x90
lsls r2, 1
@ -61959,7 +61959,7 @@ sub_8028FF8: @ 8028FF8
movs r3, 0x1
bl LoadBgTiles
adds r0, r4, 0
bl sub_8098758
bl GetWindowFrameTilesPal
ldr r0, [r0, 0x4]
movs r1, 0xA0
movs r2, 0x20

View File

@ -127,7 +127,7 @@ InitMainMenu: @ 802F6F4
movs r1, 0xF0
movs r2, 0x20
bl LoadPalette
bl remove_some_task
bl ScanlineEffect_Stop
bl ResetTasks
bl ResetSpriteData
bl FreeAllSpritePalettes
@ -1487,7 +1487,7 @@ _08030460:
ldr r0, =gMain
ldr r1, =CB2_ReinitMainMenu
str r1, [r0, 0x8]
ldr r0, =CB2_OptionsMenu
ldr r0, =CB2_InitOptionMenu
b _0803048A
.pool
_08030478:
@ -1929,7 +1929,7 @@ task_new_game_prof_birch_speech_1: @ 80307B0
movs r1, 0x1
movs r2, 0x10
bl LoadPalette
bl remove_some_task
bl ScanlineEffect_Stop
bl ResetSpriteData
bl FreeAllSpritePalettes
bl dp13_810BB8C
@ -3708,7 +3708,7 @@ new_game_prof_birch_speech_part2_start: @ 8031678
strh r0, [r4, 0x16]
ldr r0, =0x0000ffc4
strh r0, [r4, 0x10]
bl remove_some_task
bl ScanlineEffect_Stop
bl ResetSpriteData
bl FreeAllSpritePalettes
bl dp13_810BB8C
@ -4783,7 +4783,7 @@ LoadMainMenuWindowFrameTiles: @ 80320A4
ldr r0, [r6]
ldrb r0, [r0, 0x14]
lsrs r0, 3
bl sub_8098758
bl GetWindowFrameTilesPal
ldr r1, [r0]
movs r2, 0x90
lsls r2, 1
@ -4793,7 +4793,7 @@ LoadMainMenuWindowFrameTiles: @ 80320A4
ldr r0, [r6]
ldrb r0, [r0, 0x14]
lsrs r0, 3
bl sub_8098758
bl GetWindowFrameTilesPal
ldr r0, [r0, 0x4]
movs r1, 0x20
movs r2, 0x20

View File

@ -21,7 +21,7 @@ sub_811F918: @ 811F918
ldr r0, [r0]
ldrb r0, [r0, 0x14]
lsrs r0, 3
bl sub_8098758
bl GetWindowFrameTilesPal
ldr r3, =gUnknown_0203A124
ldr r2, [r3]
ldr r1, [r0]

File diff suppressed because it is too large Load Diff

View File

@ -4122,7 +4122,7 @@ sub_80867D8: @ 80867D8
movs r0, 0
movs r1, 0
bl SetGpuReg
bl remove_some_task
bl ScanlineEffect_Stop
ldr r2, =0x05000002
mov r1, sp
movs r0, 0

View File

@ -107,7 +107,7 @@ _081B0290:
b _081B048C
.pool
_081B02AC:
bl remove_some_task
bl ScanlineEffect_Stop
b _081B0484
_081B02B2:
bl ResetPaletteFade

View File

@ -379,7 +379,7 @@ _080BB582:
b _080BB74C
.pool
_080BB5FC:
bl remove_some_task
bl ScanlineEffect_Stop
bl ResetTasks
bl ResetSpriteData
bl ResetPaletteFade

View File

@ -2239,7 +2239,7 @@ _081C50E4:
bl clear_scheduled_bg_copies_to_vram
b _081C51A2
_081C50EE:
bl remove_some_task
bl ScanlineEffect_Stop
b _081C51A2
_081C50F4:
bl FreeAllSpritePalettes

View File

@ -7095,7 +7095,7 @@ titlescreen_0: @ 81CA92C
movs r0, 0x44
movs r1, 0xA0
bl SetGpuRegBits
bl remove_some_task
bl ScanlineEffect_Stop
bl sub_81CAA3C
ldr r2, =gUnknown_08620384
ldr r0, [r2]
@ -7122,7 +7122,7 @@ sub_81CA994: @ 81CA994
lsls r1, 6
movs r0, 0
bl ClearGpuRegBits
bl remove_some_task
bl ScanlineEffect_Stop
ldr r0, =sub_81CA9EC
bl FindTaskIdByFunc
lsls r0, 24

View File

@ -45,7 +45,7 @@ sub_81D6774: @ 81D6774
push {lr}
bl SetVBlankHBlankCallbacksToNull
bl clear_scheduled_bg_copies_to_vram
bl remove_some_task
bl ScanlineEffect_Stop
bl FreeAllSpritePalettes
bl ResetPaletteFade
bl ResetSpriteData
@ -1522,7 +1522,7 @@ _081D73D8:
adds r0, r2
ldrh r1, [r4, 0x6]
strh r1, [r0, 0xE]
bl remove_some_task
bl ScanlineEffect_Stop
_081D7428:
ldrh r0, [r4]
adds r0, 0x1
@ -1774,7 +1774,7 @@ sub_81D7600: @ 81D7600
bl ChangeBgY
movs r0, 0
bl SetVBlankCallback
bl remove_some_task
bl ScanlineEffect_Stop
bl ResetSpriteData
bl FreeAllSpritePalettes
strh r4, [r5]

View File

@ -887,7 +887,7 @@ _0809EFCA:
movs r1, 0x80
bl ResetOamRange
bl LoadOam
bl remove_some_task
bl ScanlineEffect_Stop
bl dp12_8087EA4
bl ResetSpriteData
bl ResetTasks

View File

@ -423,7 +423,7 @@ _081405F4:
_08140618:
movs r0, 0
bl SetVBlankCallback
bl remove_some_task
bl ScanlineEffect_Stop
bl SetVBlankHBlankCallbacksToNull
bl ResetVramOamAndBgCntRegs
bl ResetAllBgsCoordinates

View File

@ -448,7 +448,7 @@ _080DFE20:
ldr r2, =0x01000100
add r0, sp, 0x8
bl CpuFastSet
bl remove_some_task
bl ScanlineEffect_Stop
bl reset_temp_tile_data_buffers
bl FreeAllSpritePalettes
bl ResetPaletteFade

View File

@ -653,7 +653,7 @@ _0809FD38:
bl play_some_sound
bl RemoveExtraStartMenuWindows
bl overworld_free_bg_tilemaps
ldr r0, =CB2_OptionsMenu
ldr r0, =CB2_InitOptionMenu
bl SetMainCallback2
ldr r1, =gMain
ldr r0, =sub_8086194
@ -1510,7 +1510,7 @@ _080A0418:
bl SetGpuReg
movs r0, 0
bl SetVBlankCallback
bl remove_some_task
bl ScanlineEffect_Stop
movs r2, 0xA0
lsls r2, 19
mov r1, sp

View File

@ -614,7 +614,7 @@ _080AA8C4:
ldr r0, =gUnknown_08DDE458
ldr r1, =0x0600d800
bl LZ77UnCompVram
bl remove_some_task
bl ScanlineEffect_Stop
bl ResetTasks
bl ResetSpriteData
bl FreeAllSpritePalettes

View File

@ -1556,7 +1556,7 @@ sub_80C3404: @ 80C3404
sub_80C3414: @ 80C3414
push {lr}
bl ResetTasks
bl remove_some_task
bl ScanlineEffect_Stop
ldr r0, =sub_80C2760
movs r1, 0
bl CreateTask
@ -3976,7 +3976,7 @@ sub_80C4998: @ 80C4998
bl HideBg
movs r0, 0x3
bl HideBg
bl remove_some_task
bl ScanlineEffect_Stop
bl dp12_8087EA4
movs r1, 0
ldr r0, =gUnknown_02038C28
@ -5310,7 +5310,7 @@ _080C54AC:
_080C54D8:
movs r0, 0
bl SetVBlankCallback
bl remove_some_task
bl ScanlineEffect_Stop
bl SetVBlankHBlankCallbacksToNull
movs r0, 0x2
bl DisableInterrupts
@ -5594,7 +5594,7 @@ _080C577C:
bl HideBg
movs r0, 0
bl SetVBlankCallback
bl remove_some_task
bl ScanlineEffect_Stop
bl SetVBlankHBlankCallbacksToNull
b _080C57E4
_080C57A6:
@ -7189,7 +7189,7 @@ _080C64F0:
_080C6510:
movs r0, 0
bl SetVBlankCallback
bl remove_some_task
bl ScanlineEffect_Stop
bl SetVBlankHBlankCallbacksToNull
b _080C6694
_080C6520:
@ -7400,7 +7400,7 @@ _080C66FC:
_080C6722:
movs r0, 0
bl SetVBlankCallback
bl remove_some_task
bl ScanlineEffect_Stop
bl SetVBlankHBlankCallbacksToNull
b _080C67A4
_080C6732:

View File

@ -5,8 +5,8 @@
.text
thumb_func_start remove_some_task
remove_some_task: @ 80B9FB8
thumb_func_start ScanlineEffect_Stop
ScanlineEffect_Stop: @ 80B9FB8
push {r4,lr}
ldr r4, =gUnknown_02039B28
movs r0, 0
@ -32,7 +32,7 @@ _080B9FE2:
pop {r0}
bx r0
.pool
thumb_func_end remove_some_task
thumb_func_end ScanlineEffect_Stop
thumb_func_start dp12_8087EA4
dp12_8087EA4: @ 80B9FF8

6
include/option_menu.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef GUARD_OPTION_MENU_H
#define GUARD_OPTION_MENU_H
void CB2_InitOptionMenu(void);
#endif // GUARD_OPTION_MENU_H

View File

@ -170,4 +170,21 @@ extern const u8 gText_Peak[];
extern const u8 gText_SafariBallStock[];
extern const u8 gText_BattlePyramidFloor[];
// option menu texts
extern const u8 gText_TextSpeedSlow[];
extern const u8 gText_TextSpeedMid[];
extern const u8 gText_TextSpeedFast[];
extern const u8 gText_BattleSceneOn[];
extern const u8 gText_BattleSceneOff[];
extern const u8 gText_BattleStyleShift[];
extern const u8 gText_BattleStyleSet[];
extern const u8 gText_SoundMono[];
extern const u8 gText_SoundStereo[];
extern const u8 gText_FrameTypeNumber[];
extern const u8 gText_FrameType[];
extern const u8 gText_ButtonTypeNormal[];
extern const u8 gText_ButtonTypeLR[];
extern const u8 gText_ButtonTypeLEqualsA[];
extern const u8 gText_Option[];
#endif //GUARD_STRINGS_H

View File

@ -7,7 +7,7 @@ struct TilesPal
u16 *pal;
};
const struct TilesPal* sub_8098758(u8 id);
const struct TilesPal* GetWindowFrameTilesPal(u8 id);
void copy_textbox_border_tile_patterns_to_vram(u8 windowId, u16 destOffset, u8 palOffset);
void sub_809882C(u8 windowId, u16 destOffset, u8 palOffset);
void sub_80987D4(u8 windowId, u8 frameId, u16 destOffset, u8 palOffset);

View File

@ -15,7 +15,7 @@ extern struct UnknownTaskStruct gUnknown_0831AC70;
// Exported RAM declarations
// Exported ROM declarations
void remove_some_task(void);
void ScanlineEffect_Stop(void);
void sub_80BA038(struct UnknownTaskStruct arg0);
void sub_80BA0A8(void);

View File

@ -127,7 +127,7 @@ SECTIONS {
src/wild_encounter.o(.text);
asm/field_effect.o(.text);
asm/unknown_task.o(.text);
asm/option_menu.o(.text);
src/option_menu.o(.text);
src/pokedex.o(.text);
asm/pokedex.o(.text);
asm/trainer_card.o(.text);
@ -428,6 +428,7 @@ SECTIONS {
src/trainer_see.o(.rodata);
data/wild_encounter.o(.rodata);
data/field_effect.o(.rodata);
src/option_menu.o(.rodata);
data/option_menu.o(.rodata);
src/pokedex.o(.rodata);
data/pokedex.o(.rodata);

View File

@ -141,7 +141,7 @@ void InitBerryFixProgram(void)
SetVBlankCallback(NULL);
ResetSpriteData();
ResetTasks();
remove_some_task();
ScanlineEffect_Stop();
SetGpuReg(REG_OFFSET_DISPCNT, 0x0000);
berry_fix_mb_manager = AllocZeroed(0x50);
berry_fix_mb_manager->state = 0;

View File

@ -72,7 +72,7 @@ void CB2_ShowDiploma(void)
DmaFill16(3, 0, VRAM, VRAM_SIZE);
DmaFill32(3, 0, OAM, OAM_SIZE);
DmaFill16(3, 0, PLTT, PLTT_SIZE);
remove_some_task();
ScanlineEffect_Stop();
ResetTasks();
ResetSpriteData();
ResetPaletteFade();

View File

@ -66,7 +66,7 @@ extern void overworld_free_bg_tilemaps(void);
extern void sub_80AF168(void);
extern void AllocateMonSpritesGfx(void);
extern void FreeMonSpritesGfx(void);
extern void remove_some_task(void);
extern void ScanlineEffect_Stop(void);
extern void reset_temp_tile_data_buffers(void);
extern void c2_exit_to_overworld_2_switch(void);
extern void play_some_sound(void);
@ -512,7 +512,7 @@ static void CB2_EggHatch_0(void)
FreeAllSpritePalettes();
ResetSpriteData();
ResetTasks();
remove_some_task();
ScanlineEffect_Stop();
m4aSoundVSyncOn();
gMain.state++;
break;

View File

@ -269,7 +269,7 @@ void EvolutionScene(struct Pokemon* mon, u16 speciesToEvolve, bool8 canStopEvo,
sub_80356D0();
LoadBattleTextboxAndBackground();
ResetSpriteData();
remove_some_task();
ScanlineEffect_Stop();
ResetTasks();
FreeAllSpritePalettes();

View File

@ -1302,7 +1302,7 @@ static void ClearVramOamPltt_LoadHofPal(void)
static void sub_8174F70(void)
{
remove_some_task();
ScanlineEffect_Stop();
ResetTasks();
ResetSpriteData();
reset_temp_tile_data_buffers();

View File

@ -329,7 +329,7 @@ static bool8 MailReadBuildGraphics(void)
{
case 0:
SetVBlankCallback(NULL);
remove_some_task();
ScanlineEffect_Stop();
SetGpuReg(REG_OFFSET_DISPCNT, 0x0000);
break;
case 1:

View File

@ -29,7 +29,7 @@ extern void MapMusicMain(void);
extern void EnableInterrupts(u16);
extern void sub_8033648(void);
extern u16 SetFlashTimerIntr(u8 timerNum, void (**intrFunc)(void));
extern void remove_some_task(void);
extern void ScanlineEffect_Stop(void);
extern struct SoundInfo gSoundInfo;
extern u32 gFlashMemoryPresent;
@ -425,7 +425,7 @@ void DoSoftReset(void)
{
REG_IME = 0;
m4aSoundVSyncOff();
remove_some_task();
ScanlineEffect_Stop();
DmaStop(1);
DmaStop(2);
DmaStop(3);

630
src/option_menu.c Normal file
View File

@ -0,0 +1,630 @@
#include "global.h"
#include "option_menu.h"
#include "main.h"
#include "menu.h"
#include "unknown_task.h"
#include "palette.h"
#include "sprite.h"
#include "task.h"
#include "bg.h"
#include "gpu_regs.h"
#include "window.h"
#include "text.h"
#include "text_window.h"
#include "international_string_util.h"
#include "strings.h"
extern void SetPokemonCryStereo(u32 val);
// Task data
enum
{
TD_MENUSELECTION,
TD_TEXTSPEED,
TD_BATTLESCENE,
TD_BATTLESTYLE,
TD_SOUND,
TD_BUTTONMODE,
TD_FRAMETYPE,
};
// Menu items
enum
{
MENUITEM_TEXTSPEED,
MENUITEM_BATTLESCENE,
MENUITEM_BATTLESTYLE,
MENUITEM_SOUND,
MENUITEM_BUTTONMODE,
MENUITEM_FRAMETYPE,
MENUITEM_CANCEL,
MENUITEM_COUNT,
};
// Window Ids
enum
{
WIN_TEXT_OPTION,
WIN_OPTIONS
};
// this file's functions
static void Task_OptionMenuFadeIn(u8 taskId);
static void Task_OptionMenuProcessInput(u8 taskId);
static void Task_OptionMenuSave(u8 taskId);
static void Task_OptionMenuFadeOut(u8 taskId);
static void HighlightOptionMenuItem(u8 selection);
static u8 TextSpeed_ProcessInput(u8 selection);
static void TextSpeed_DrawChoices(u8 selection);
static u8 BattleScene_ProcessInput(u8 selection);
static void BattleScene_DrawChoices(u8 selection);
static u8 BattleStyle_ProcessInput(u8 selection);
static void BattleStyle_DrawChoices(u8 selection);
static u8 Sound_ProcessInput(u8 selection);
static void Sound_DrawChoices(u8 selection);
static u8 FrameType_ProcessInput(u8 selection);
static void FrameType_DrawChoices(u8 selection);
static u8 ButtonMode_ProcessInput(u8 selection);
static void ButtonMode_DrawChoices(u8 selection);
static void DrawTextOption(void);
static void DrawOptionMenuTexts(void);
static void sub_80BB154(void);
// EWRAM vars
EWRAM_DATA static bool8 sArrowPressed = FALSE;
// const rom data
/*
const u16 gUnknown_0839F5FC[] = INCBIN_U16("graphics/misc/option_menu_text.gbapal");
// note: this is only used in the Japanese release
const static u8 gUnknown_0839F63C[] = INCBIN_U8("graphics/misc/option_menu_equals_sign.4bpp");
*/
extern const struct BgTemplate gUnknown_0855C698[2];
extern const struct WindowTemplate gUnknown_0855C680[];
extern const u16 gUnknown_0855C6A0[1];
extern const u16 gUnknown_0855C604[16];
extern const u8 *const gUnknown_0855C664[MENUITEM_COUNT];
// code
static void MainCB2(void)
{
RunTasks();
AnimateSprites();
BuildOamBuffer();
UpdatePaletteFade();
}
static void VBlankCB(void)
{
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
}
void CB2_InitOptionMenu(void)
{
switch (gMain.state)
{
default:
case 0:
SetVBlankCallback(NULL);
gMain.state++;
break;
case 1:
{
u8 *addr;
u32 size;
addr = (u8 *)VRAM;
size = 0x18000;
while (1)
{
DmaFill16(3, 0, addr, 0x1000);
addr += 0x1000;
size -= 0x1000;
if (size <= 0x1000)
{
DmaFill16(3, 0, addr, size);
break;
}
}
DmaClear32(3, OAM, OAM_SIZE);
DmaClear16(3, PLTT, PLTT_SIZE);
SetGpuReg(REG_OFFSET_DISPCNT, 0);
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, gUnknown_0855C698, ARRAY_COUNT(gUnknown_0855C698));
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);
InitWindows(gUnknown_0855C680);
DeactivateAllTextPrinters();
SetGpuReg(REG_OFFSET_WIN0H, 0);
SetGpuReg(REG_OFFSET_WIN0V, 0);
SetGpuReg(REG_OFFSET_WININ, 1);
SetGpuReg(REG_OFFSET_WINOUT, 35);
SetGpuReg(REG_OFFSET_BLDCNT, 193);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 4);
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
ShowBg(0);
ShowBg(1);
gMain.state++;
}
break;
case 2:
ResetPaletteFade();
ScanlineEffect_Stop();
ResetTasks();
ResetSpriteData();
gMain.state++;
break;
case 3:
LoadBgTiles(1, GetWindowFrameTilesPal(gSaveBlock2Ptr->optionsWindowFrameType)->tiles, 0x120, 0x1A2);
gMain.state++;
break;
case 4:
LoadPalette(gUnknown_0855C6A0, 0, sizeof(gUnknown_0855C6A0));
LoadPalette(GetWindowFrameTilesPal(gSaveBlock2Ptr->optionsWindowFrameType)->pal, 0x70, 0x20);
gMain.state++;
break;
case 5:
LoadPalette(gUnknown_0855C604, 0x10, sizeof(gUnknown_0855C604));
gMain.state++;
break;
case 6:
PutWindowTilemap(0);
DrawTextOption();
gMain.state++;
break;
case 7:
gMain.state++;
break;
case 8:
PutWindowTilemap(1);
DrawOptionMenuTexts();
gMain.state++;
case 9:
sub_80BB154();
gMain.state++;
break;
case 10:
{
u8 taskId = CreateTask(Task_OptionMenuFadeIn, 0);
gTasks[taskId].data[TD_MENUSELECTION] = 0;
gTasks[taskId].data[TD_TEXTSPEED] = gSaveBlock2Ptr->optionsTextSpeed;
gTasks[taskId].data[TD_BATTLESCENE] = gSaveBlock2Ptr->optionsBattleSceneOff;
gTasks[taskId].data[TD_BATTLESTYLE] = gSaveBlock2Ptr->optionsBattleStyle;
gTasks[taskId].data[TD_SOUND] = gSaveBlock2Ptr->optionsSound;
gTasks[taskId].data[TD_BUTTONMODE] = gSaveBlock2Ptr->optionsButtonMode;
gTasks[taskId].data[TD_FRAMETYPE] = gSaveBlock2Ptr->optionsWindowFrameType;
TextSpeed_DrawChoices(gTasks[taskId].data[TD_TEXTSPEED]);
BattleScene_DrawChoices(gTasks[taskId].data[TD_BATTLESCENE]);
BattleStyle_DrawChoices(gTasks[taskId].data[TD_BATTLESTYLE]);
Sound_DrawChoices(gTasks[taskId].data[TD_SOUND]);
ButtonMode_DrawChoices(gTasks[taskId].data[TD_BUTTONMODE]);
FrameType_DrawChoices(gTasks[taskId].data[TD_FRAMETYPE]);
HighlightOptionMenuItem(gTasks[taskId].data[TD_MENUSELECTION]);
CopyWindowToVram(WIN_OPTIONS, 3);
gMain.state++;
break;
}
case 11:
BeginNormalPaletteFade(-1, 0, 0x10, 0, 0);
SetVBlankCallback(VBlankCB);
SetMainCallback2(MainCB2);
return;
}
}
static void Task_OptionMenuFadeIn(u8 taskId)
{
if (!gPaletteFade.active)
{
gTasks[taskId].func = Task_OptionMenuProcessInput;
}
}
static void Task_OptionMenuProcessInput(u8 taskId)
{
if (gMain.newKeys & A_BUTTON)
{
if (gTasks[taskId].data[TD_MENUSELECTION] == MENUITEM_CANCEL)
gTasks[taskId].func = Task_OptionMenuSave;
}
else if (gMain.newKeys & B_BUTTON)
{
gTasks[taskId].func = Task_OptionMenuSave;
}
else if (gMain.newKeys & DPAD_UP)
{
if (gTasks[taskId].data[TD_MENUSELECTION] > 0)
gTasks[taskId].data[TD_MENUSELECTION]--;
else
gTasks[taskId].data[TD_MENUSELECTION] = 6;
HighlightOptionMenuItem(gTasks[taskId].data[TD_MENUSELECTION]);
}
else if (gMain.newKeys & DPAD_DOWN)
{
if (gTasks[taskId].data[TD_MENUSELECTION] <= 5)
gTasks[taskId].data[TD_MENUSELECTION]++;
else
gTasks[taskId].data[TD_MENUSELECTION] = 0;
HighlightOptionMenuItem(gTasks[taskId].data[TD_MENUSELECTION]);
}
else
{
u8 previousOption;
switch (gTasks[taskId].data[TD_MENUSELECTION])
{
case MENUITEM_TEXTSPEED:
previousOption = gTasks[taskId].data[TD_TEXTSPEED];
gTasks[taskId].data[TD_TEXTSPEED] = TextSpeed_ProcessInput(gTasks[taskId].data[TD_TEXTSPEED]);
if (previousOption != gTasks[taskId].data[TD_TEXTSPEED])
TextSpeed_DrawChoices(gTasks[taskId].data[TD_TEXTSPEED]);
break;
case MENUITEM_BATTLESCENE:
previousOption = gTasks[taskId].data[TD_BATTLESCENE];
gTasks[taskId].data[TD_BATTLESCENE] = BattleScene_ProcessInput(gTasks[taskId].data[TD_BATTLESCENE]);
if (previousOption != gTasks[taskId].data[TD_BATTLESCENE])
BattleScene_DrawChoices(gTasks[taskId].data[TD_BATTLESCENE]);
break;
case MENUITEM_BATTLESTYLE:
previousOption = gTasks[taskId].data[TD_BATTLESTYLE];
gTasks[taskId].data[TD_BATTLESTYLE] = BattleStyle_ProcessInput(gTasks[taskId].data[TD_BATTLESTYLE]);
if (previousOption != gTasks[taskId].data[TD_BATTLESTYLE])
BattleStyle_DrawChoices(gTasks[taskId].data[TD_BATTLESTYLE]);
break;
case MENUITEM_SOUND:
previousOption = gTasks[taskId].data[TD_SOUND];
gTasks[taskId].data[TD_SOUND] = Sound_ProcessInput(gTasks[taskId].data[TD_SOUND]);
if (previousOption != gTasks[taskId].data[TD_SOUND])
Sound_DrawChoices(gTasks[taskId].data[TD_SOUND]);
break;
case MENUITEM_BUTTONMODE:
previousOption = gTasks[taskId].data[TD_BUTTONMODE];
gTasks[taskId].data[TD_BUTTONMODE] = ButtonMode_ProcessInput(gTasks[taskId].data[TD_BUTTONMODE]);
if (previousOption != gTasks[taskId].data[TD_BUTTONMODE])
ButtonMode_DrawChoices(gTasks[taskId].data[TD_BUTTONMODE]);
break;
case MENUITEM_FRAMETYPE:
previousOption = gTasks[taskId].data[TD_FRAMETYPE];
gTasks[taskId].data[TD_FRAMETYPE] = FrameType_ProcessInput(gTasks[taskId].data[TD_FRAMETYPE]);
if (previousOption != gTasks[taskId].data[TD_FRAMETYPE])
FrameType_DrawChoices(gTasks[taskId].data[TD_FRAMETYPE]);
break;
default:
return;
}
if (sArrowPressed)
{
sArrowPressed = FALSE;
CopyWindowToVram(WIN_OPTIONS, 2);
}
}
}
static void Task_OptionMenuSave(u8 taskId)
{
gSaveBlock2Ptr->optionsTextSpeed = gTasks[taskId].data[TD_TEXTSPEED];
gSaveBlock2Ptr->optionsBattleSceneOff = gTasks[taskId].data[TD_BATTLESCENE];
gSaveBlock2Ptr->optionsBattleStyle = gTasks[taskId].data[TD_BATTLESTYLE];
gSaveBlock2Ptr->optionsSound = gTasks[taskId].data[TD_SOUND];
gSaveBlock2Ptr->optionsButtonMode = gTasks[taskId].data[TD_BUTTONMODE];
gSaveBlock2Ptr->optionsWindowFrameType = gTasks[taskId].data[TD_FRAMETYPE];
BeginNormalPaletteFade(-1, 0, 0, 0x10, 0);
gTasks[taskId].func = Task_OptionMenuFadeOut;
}
static void Task_OptionMenuFadeOut(u8 taskId)
{
if (!gPaletteFade.active)
{
DestroyTask(taskId);
FreeAllWindowBuffers();
SetMainCallback2(gMain.savedCallback);
}
}
static void HighlightOptionMenuItem(u8 index)
{
SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(16, 224));
SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(index * 16 + 40, index * 16 + 56));
}
static void DrawOptionMenuChoice(const u8 *text, u8 x, u8 y, u8 style)
{
u8 dst[16];
u16 i;
for (i = 0; *text != EOS && i <= 14; i++)
dst[i] = *(text++);
if (style != 0)
{
dst[2] = 4;
dst[5] = 5;
}
dst[i] = EOS;
PrintTextOnWindow(WIN_OPTIONS, 1, dst, x, y + 1, TEXT_SPEED_FF, NULL);
}
static u8 TextSpeed_ProcessInput(u8 selection)
{
if (gMain.newKeys & DPAD_RIGHT)
{
if (selection <= 1)
selection++;
else
selection = 0;
sArrowPressed = TRUE;
}
if (gMain.newKeys & DPAD_LEFT)
{
if (selection != 0)
selection--;
else
selection = 2;
sArrowPressed = TRUE;
}
return selection;
}
static void TextSpeed_DrawChoices(u8 selection)
{
u8 styles[3];
s32 widthSlow, widthMid, widthFast, xMid;
styles[0] = 0;
styles[1] = 0;
styles[2] = 0;
styles[selection] = 1;
DrawOptionMenuChoice(gText_TextSpeedSlow, 104, 0, styles[0]);
widthSlow = GetStringWidth(1, gText_TextSpeedSlow, 0);
widthMid = GetStringWidth(1, gText_TextSpeedMid, 0);
widthFast = GetStringWidth(1, gText_TextSpeedFast, 0);
widthMid -= 94;
xMid = (widthSlow - widthMid - widthFast) / 2 + 104;
DrawOptionMenuChoice(gText_TextSpeedMid, xMid, 0, styles[1]);
DrawOptionMenuChoice(gText_TextSpeedFast, GetStringRightAlignXOffset(1, gText_TextSpeedFast, 198), 0, styles[2]);
}
static u8 BattleScene_ProcessInput(u8 selection)
{
if (gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT))
{
selection ^= 1;
sArrowPressed = TRUE;
}
return selection;
}
static void BattleScene_DrawChoices(u8 selection)
{
u8 styles[2];
styles[0] = 0;
styles[1] = 0;
styles[selection] = 1;
DrawOptionMenuChoice(gText_BattleSceneOn, 104, 16, styles[0]);
DrawOptionMenuChoice(gText_BattleSceneOff, GetStringRightAlignXOffset(1, gText_BattleSceneOff, 198), 16, styles[1]);
}
static u8 BattleStyle_ProcessInput(u8 selection)
{
if (gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT))
{
selection ^= 1;
sArrowPressed = TRUE;
}
return selection;
}
static void BattleStyle_DrawChoices(u8 selection)
{
u8 styles[2];
styles[0] = 0;
styles[1] = 0;
styles[selection] = 1;
DrawOptionMenuChoice(gText_BattleStyleShift, 104, 32, styles[0]);
DrawOptionMenuChoice(gText_BattleStyleSet, GetStringRightAlignXOffset(1, gText_BattleStyleSet, 198), 32, styles[1]);
}
static u8 Sound_ProcessInput(u8 selection)
{
if (gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT))
{
selection ^= 1;
SetPokemonCryStereo(selection);
sArrowPressed = TRUE;
}
return selection;
}
static void Sound_DrawChoices(u8 selection)
{
u8 styles[2];
styles[0] = 0;
styles[1] = 0;
styles[selection] = 1;
DrawOptionMenuChoice(gText_SoundMono, 104, 48, styles[0]);
DrawOptionMenuChoice(gText_SoundStereo, GetStringRightAlignXOffset(1, gText_SoundStereo, 198), 48, styles[1]);
}
// TODO: 19 should be defined in text_window.h
static u8 FrameType_ProcessInput(u8 selection)
{
if (gMain.newKeys & DPAD_RIGHT)
{
if (selection < 19)
selection++;
else
selection = 0;
LoadBgTiles(1, GetWindowFrameTilesPal(selection)->tiles, 0x120, 0x1A2);
LoadPalette(GetWindowFrameTilesPal(selection)->pal, 0x70, 0x20);
sArrowPressed = TRUE;
}
if (gMain.newKeys & DPAD_LEFT)
{
if (selection != 0)
selection--;
else
selection = 19;
LoadBgTiles(1, GetWindowFrameTilesPal(selection)->tiles, 0x120, 0x1A2);
LoadPalette(GetWindowFrameTilesPal(selection)->pal, 0x70, 0x20);
sArrowPressed = TRUE;
}
return selection;
}
static void FrameType_DrawChoices(u8 selection)
{
u8 text[16];
u8 n = selection + 1;
u16 i;
for (i = 0; gText_FrameTypeNumber[i] != EOS && i <= 5; i++)
text[i] = gText_FrameTypeNumber[i];
// Convert a number to decimal string
if (n / 10 != 0)
{
text[i] = n / 10 + CHAR_0;
i++;
text[i] = n % 10 + CHAR_0;
i++;
}
else
{
text[i] = n % 10 + CHAR_0;
i++;
text[i] = 0x77;
i++;
}
text[i] = EOS;
DrawOptionMenuChoice(gText_FrameType, 104, 80, 0);
DrawOptionMenuChoice(text, 128, 80, 1);
}
static u8 ButtonMode_ProcessInput(u8 selection)
{
if (gMain.newKeys & DPAD_RIGHT)
{
if (selection <= 1)
selection++;
else
selection = 0;
sArrowPressed = TRUE;
}
if (gMain.newKeys & DPAD_LEFT)
{
if (selection != 0)
selection--;
else
selection = 2;
sArrowPressed = TRUE;
}
return selection;
}
static void ButtonMode_DrawChoices(u8 selection)
{
s32 widthNormal, widthLR, widthLA, yLR;
u8 styles[3];
styles[0] = 0;
styles[1] = 0;
styles[2] = 0;
styles[selection] = 1;
DrawOptionMenuChoice(gText_ButtonTypeNormal, 104, 64, styles[0]);
widthNormal = GetStringWidth(1, gText_ButtonTypeNormal, 0);
widthLR = GetStringWidth(1, gText_ButtonTypeLR, 0);
widthLA = GetStringWidth(1, gText_ButtonTypeLEqualsA, 0);
widthLR -= 94;
yLR = (widthNormal - widthLR - widthLA) / 2 + 104;
DrawOptionMenuChoice(gText_ButtonTypeLR, yLR, 64, styles[1]);
DrawOptionMenuChoice(gText_ButtonTypeLEqualsA, GetStringRightAlignXOffset(1, gText_ButtonTypeLEqualsA, 198), 64, styles[2]);
}
static void DrawTextOption(void)
{
FillWindowPixelBuffer(WIN_TEXT_OPTION, 0x11);
PrintTextOnWindow(WIN_TEXT_OPTION, 1, gText_Option, 8, 1, TEXT_SPEED_FF, NULL);
CopyWindowToVram(WIN_TEXT_OPTION, 3);
}
static void DrawOptionMenuTexts(void)
{
u8 i;
FillWindowPixelBuffer(WIN_OPTIONS, 0x11);
for (i = 0; i < MENUITEM_COUNT; i++)
{
PrintTextOnWindow(WIN_OPTIONS, 1, gUnknown_0855C664[i], 8, (i * 16) + 1, TEXT_SPEED_FF, NULL);
}
CopyWindowToVram(WIN_OPTIONS, 3);
}
static void sub_80BB154(void)
{
// bg, tileNum, x, y, width, height, pal
FillBgTilemapBufferRect(1, 0x1A2, 1, 0, 1, 1, 7);
FillBgTilemapBufferRect(1, 0x1A3, 2, 0, 0x1B, 1, 7);
FillBgTilemapBufferRect(1, 0x1A4, 28, 0, 1, 1, 7);
FillBgTilemapBufferRect(1, 0x1A5, 1, 1, 1, 2, 7);
FillBgTilemapBufferRect(1, 0x1A7, 28, 1, 1, 2, 7);
FillBgTilemapBufferRect(1, 0x1A8, 1, 3, 1, 1, 7);
FillBgTilemapBufferRect(1, 0x1A9, 2, 3, 0x1B, 1, 7);
FillBgTilemapBufferRect(1, 0x1AA, 28, 3, 1, 1, 7);
FillBgTilemapBufferRect(1, 0x1A2, 1, 4, 1, 1, 7);
FillBgTilemapBufferRect(1, 0x1A3, 2, 4, 0x1A, 1, 7);
FillBgTilemapBufferRect(1, 0x1A4, 28, 4, 1, 1, 7);
FillBgTilemapBufferRect(1, 0x1A5, 1, 5, 1, 0x12, 7);
FillBgTilemapBufferRect(1, 0x1A7, 28, 5, 1, 0x12, 7);
FillBgTilemapBufferRect(1, 0x1A8, 1, 19, 1, 1, 7);
FillBgTilemapBufferRect(1, 0x1A9, 2, 19, 0x1A, 1, 7);
FillBgTilemapBufferRect(1, 0x1AA, 28, 19, 1, 1, 7);
CopyBgTilemapBufferToVram(1);
}

View File

@ -419,7 +419,7 @@ static bool8 InitPokeblockMenu(void)
gMain.state++;
break;
case 1:
remove_some_task();
ScanlineEffect_Stop();
gMain.state++;
break;
case 2:

View File

@ -75,7 +75,7 @@ extern u8 sub_81221AC();
extern void SetVBlankHBlankCallbacksToNull();
extern void ResetVramOamAndBgCntRegs();
extern void clear_scheduled_bg_copies_to_vram();
extern void remove_some_task();
extern void ScanlineEffect_Stop();
extern void ResetBgsAndClearDma3BusyFlags(u32 leftoverFireRedLeafGreenVariable);
extern void ShowBg(u8 a);
extern void SetGpuReg(u8 regOffset, u16 value);
@ -455,7 +455,7 @@ bool8 sub_81BFB10(void)
gMain.state++;
break;
case 1:
remove_some_task();
ScanlineEffect_Stop();
gMain.state++;
break;
case 2:

View File

@ -53,7 +53,7 @@ extern const u8 gUnknown_085B1E0C[];
extern const u8 gUnknown_085B1E28[][2];
extern void sub_809882C(u8, u16, u8);
extern void remove_some_task(void);
extern void ScanlineEffect_Stop(void);
extern void clear_scheduled_bg_copies_to_vram(void);
extern void dp13_810BB8C(void);
extern void do_scheduled_bg_tilemap_copies_to_vram(void);
@ -134,7 +134,7 @@ void CB2_ChooseStarter(void)
DeactivateAllTextPrinters();
sub_809882C(0, 0x2A8, 0xD0);
clear_scheduled_bg_copies_to_vram();
remove_some_task();
ScanlineEffect_Stop();
ResetTasks();
ResetSpriteData();
ResetPaletteFade();

View File

@ -7,14 +7,14 @@
extern u8 LoadBgTiles(u8 bg, const void *src, u16 size, u16 destOffset);
extern void FillBgTilemapBufferRect(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height, u8 palette);
extern const struct TilesPal gUnknown_0851021C[];
extern const struct TilesPal gUnknown_0851021C[20];
extern const u32 gUnknown_08DDD748[];
extern const u16 gUnknown_0851017C[];
extern const u16 gUnknown_08DDD728[];
const struct TilesPal* sub_8098758(u8 id)
const struct TilesPal* GetWindowFrameTilesPal(u8 id)
{
if (id > 19)
if (id >= ARRAY_COUNT(gUnknown_0851021C))
return &gUnknown_0851021C[0];
else
return &gUnknown_0851021C[id];
@ -121,5 +121,5 @@ const u16* GetOverworldTextboxPalettePtr(void)
void sub_8098C6C(u8 bg, u16 destOffset, u8 palOffset)
{
LoadBgTiles(bg, gUnknown_0851021C[gSaveBlock2Ptr->optionsWindowFrameType].tiles, 0x120, destOffset);
LoadPalette(sub_8098758(gSaveBlock2Ptr->optionsWindowFrameType)->pal, palOffset, 0x20);
LoadPalette(GetWindowFrameTilesPal(gSaveBlock2Ptr->optionsWindowFrameType)->pal, palOffset, 0x20);
}

View File

@ -578,7 +578,7 @@ static void LoadWallClockGraphics(void)
DeactivateAllTextPrinters();
sub_809882C(0, 0x250, 0xd0);
clear_scheduled_bg_copies_to_vram();
remove_some_task();
ScanlineEffect_Stop();
ResetTasks();
ResetSpriteData();
ResetPaletteFade();

View File

@ -743,8 +743,9 @@ gUnknown_02039B28: @ 2039B28
gUnknown_02039B44: @ 2039B44
.space 0x4
gUnknown_02039B48: @ 2039B48
.space 0x4
.include "src/option_menu.o"
.align 2
gUnknown_02039B4C: @ 2039B4C
.space 0x4