Begin menu.s decomp

This commit is contained in:
Diegoisawesome 2018-01-26 23:41:52 -06:00
parent 7d8a2ae7f0
commit 2da7bdbb11
9 changed files with 912 additions and 2804 deletions

View File

@ -16009,6 +16009,44 @@ _0819715C:
pop {r0}
bx r0
.pool
thumb_func_end sub_8197080
thumb_func_start sub_8197184
sub_8197184: @ 8197184
push {r4,r5,lr}
adds r4, r1, 0
adds r5, r2, 0
lsls r0, 24
lsrs r0, 24
movs r1, 0
bl GetWindowAttribute
lsls r0, 24
lsrs r0, 24
ldr r1, =gUnknown_0860EA6C
movs r2, 0x80
lsls r2, 1
lsls r4, 16
lsrs r4, 16
adds r3, r4, 0
bl LoadBgTiles
ldr r0, =gUnknown_0860EA4C
lsls r5, 20
lsrs r5, 16
adds r1, r5, 0
movs r2, 0x20
bl LoadPalette
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_8197184
thumb_func_start sub_81971C4
sub_81971C4: @ 81971C4
push {lr}
bl sub_819645C
pop {r0}
bx r0
thumb_func_end sub_81971C4
.align 2, 0 @ Don't pad with nop.

2720
asm/menu.s

File diff suppressed because it is too large Load Diff

View File

@ -1,53 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
gUnknown_0860F074:: @ 860F074
.incbin "graphics/interface/860F074.gbapal"
gUnknown_0860F094:: @ 860F094
.byte 8, 4, 1, 0
gUnknown_0860F098:: @ 860F098
window_template 0, 2, 15, 27, 4, 15, 0x194
null_window_template
gUnknown_0860F0A8:: @ 860F0A8
window_template 0, 21, 9, 5, 4, 15, 0x125
@ These are not referenced in src/new_menu_helpers.c; rather, they are in src/menu.c. Regardless, they were plopped here.
gUnknown_0860F0B0:: @ 860F0B0
.incbin "graphics/interface/860F0B0.gbapal"
gUnknown_0860F0D0:: @ 860F0D0
.byte 15, 1, 2, 0
gUnknown_0860F0D4:: @ 860F0D4
.2byte 0xC0C, 0
.2byte 0xC20, 32
.2byte 0xC20, 100
.2byte 0xC20, 0x60
.2byte 0xC20, 0x80
.2byte 0xC20, 0x48
.2byte 0xC20, 0x44
.2byte 0xC20, 0x6C
.2byte 0xC20, 0x68
.2byte 0xC20, 0x88
.2byte 0xC20, 0xA4
.2byte 0xC20, 0x24
.2byte 0xC20, 0x28
.2byte 0xC20, 0x2C
.2byte 0xC20, 0x40
.2byte 0xC20, 0x84
.2byte 0xC20, 0x4C
.2byte 0xC20, 0xA0
.2byte 0xC20, 0x8C
.2byte 0xC2A, 0xA8
.2byte 0xC2A, 0xC0
.2byte 0xC2A, 0xC8
.2byte 0xC2A, 0xE0
.2byte 0xC2A, 0xE8
.2byte 0x808, 0xAE
.2byte 0x808, 0xAF

View File

@ -39,8 +39,8 @@
#define BG_CHAR_ADDR(n) (BG_VRAM + (BG_CHAR_SIZE * (n)))
#define BG_SCREEN_ADDR(n) (BG_VRAM + (BG_SCREEN_SIZE * (n)))
#define BG_TILE_H_FLIP(n) (0x400 | (n))
#define BG_TILE_V_FLIP(n) (0x800 | (n))
#define BG_TILE_H_FLIP(n) (0x400 + (n))
#define BG_TILE_V_FLIP(n) (0x800 + (n))
// text-mode BG
#define OBJ_VRAM0 (VRAM + 0x10000)

View File

@ -30,15 +30,15 @@ void blit_move_info_icon(u8 winId, u8 a2, u16 x, u16 y);
void reset_temp_tile_data_buffers(void);
int decompress_and_copy_tile_data_to_vram(u8 bg_id, const void *src, int size, u16 offset, u8 mode);
bool8 free_temp_tile_data_buffers_if_possible(void);
u64 sub_8198A50(struct WindowTemplate*, u8, u8, u8, u8, u8, u8, u16); // returns something but it isn't used, fix when menu.s is decomp'd
struct WindowTemplate sub_8198A50(u8, u8, u8, u8, u8, u8, u16);
void CreateYesNoMenu(const struct WindowTemplate *windowTemplate, u16 borderFirstTileNum, u8 borderPalette, u8 initialCursorPos);
s8 ProcessMenuInputNoWrap_(void);
void do_scheduled_bg_tilemap_copies_to_vram(void);
void clear_scheduled_bg_copies_to_vram(void);
void AddTextPrinterParameterized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, const struct TextColor *color, s8 speed, const u8 *str);
void sub_8197B1C(u8 windowId, bool8 copyToVram, u16 a2, u16 a3);
void sub_8197B1C(u8 windowId, bool8 copyToVram, u16 a2, u8 a3);
void sub_81995E4(u8 windowId, u8 optionsNo, const struct MenuAction *actions, const u8 *actionIds);
void sub_8197DF8(u8 windowId, bool8 copyToVram);
u8 sub_8198AA4(u8, u8, u8, u8, u8, u8, u16);
u16 sub_8198AA4(u8, u8, u8, u8, u8, u8, u16);
#endif // GUARD_MENU_H

View File

@ -248,6 +248,7 @@ SECTIONS {
src/lilycove_lady.o(.text);
asm/battle_frontier_1.o(.text);
src/new_menu_helpers.o(.text);
src/menu.o(.text);
asm/menu.o(.text);
asm/battle_frontier_2.o(.text);
asm/item_menu.o(.text);
@ -520,7 +521,8 @@ SECTIONS {
src/battle_dome_cards.o(.rodata);
src/lilycove_lady.o(.rodata);
data/battle_frontier_1.o(.rodata);
data/new_menu_helpers.o(.rodata);
src/new_menu_helpers.o(.rodata);
src/menu.o(.rodata);
data/battle_frontier_2.o(.rodata);
data/item_menu.o(.rodata);
data/menu_indicators.o(.rodata);

849
src/menu.c Normal file
View File

@ -0,0 +1,849 @@
#include "global.h"
#include "new_menu_helpers.h"
#include "bg.h"
#include "window.h"
#include "palette.h"
#include "menu.h"
#include "constants/songs.h"
#include "main.h"
#include "sound.h"
struct SomeUnkStruct
{
u8 unk1;
u8 unk2;
u16 unk3;
};
struct Menu
{
u8 left;
u8 top;
s8 cursorPos;
s8 minCursorPos;
s8 maxCursorPos;
u8 windowId;
u8 fontId;
u8 menu_field_7;
u8 cursorHeight;
u8 menu_field_9;
u8 menu_field_A;
u8 menu_field_B;
};
extern EWRAM_DATA struct Menu gUnknown_0203CD90;
extern EWRAM_DATA u16 gUnknown_0203CD9C;
extern EWRAM_DATA u8 gUnknown_0203CD9E;
extern EWRAM_DATA u8 gUnknown_0203CD9F;
extern EWRAM_DATA u8 gUnknown_0203CDA0;
const u16 gUnknown_0860F0B0[] = INCBIN_U16("graphics/interface/860F0B0.gbapal");
const u8 gUnknown_0860F0D0[] = { 15, 1, 2 };
const struct SomeUnkStruct gUnknown_0860F0D4[] =
{
{ 12, 12, 0x00 },
{ 32, 12, 0x20 },
{ 32, 12, 0x64 },
{ 32, 12, 0x60 },
{ 32, 12, 0x80 },
{ 32, 12, 0x48 },
{ 32, 12, 0x44 },
{ 32, 12, 0x6C },
{ 32, 12, 0x68 },
{ 32, 12, 0x88 },
{ 32, 12, 0xA4 },
{ 32, 12, 0x24 },
{ 32, 12, 0x28 },
{ 32, 12, 0x2C },
{ 32, 12, 0x40 },
{ 32, 12, 0x84 },
{ 32, 12, 0x4C },
{ 32, 12, 0xA0 },
{ 32, 12, 0x8C },
{ 42, 12, 0xA8 },
{ 42, 12, 0xC0 },
{ 42, 12, 0xC8 },
{ 42, 12, 0xE0 },
{ 42, 12, 0xE8 },
{ 8, 8, 0xAE },
{ 8, 8, 0xAF },
};
extern const u8 gText_SelectorArrow3[];
extern const u8 gText_YesNo[];
extern void sub_8197BB4(u8, u8, u8, u8, u8, u8);
extern void sub_8197E30(u8, u8, u8, u8, u8, u8);
extern void DrawWindowBorder(u8, u8, u8, u8, u8, u8);
extern void sub_81980A8(u8, u8, u8, u8, u8, u8);
extern u8 MoveMenuCursor(s8);
extern u8 sub_8199134(s8, s8);
extern void sub_8199F74(u8, u8, const u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextSubPrinter *, u16), u8, u8);
extern void sub_8198C78(void);
void AddTextPrinterWithCallbackForMessage(bool8 a1, void (*callback)(struct TextSubPrinter *, u16))
{
gTextFlags.flag_0 = a1;
AddTextPrinterParameterized(0, 1, gStringVar4, GetPlayerTextSpeed(), callback, 2, 1, 3);
}
void sub_8197AE8(bool8 copyToVram)
{
FillBgTilemapBufferRect(0, 0, 0, 0, 32, 32, 0x11);
if (copyToVram == TRUE)
CopyBgTilemapBufferToVram(0);
}
void sub_8197B1C(u8 windowId, bool8 copyToVram, u16 a3, u8 a4)
{
gUnknown_0203CD9C = a3;
gUnknown_0203CD9E = a4;
CallWindowFunction(windowId, sub_8197BB4);
FillWindowPixelBuffer(windowId, 0x11);
PutWindowTilemap(windowId);
if (copyToVram == TRUE)
CopyWindowToVram(windowId, 3);
}
void sub_8197B64(u8 windowId, bool8 copyToVram, u16 a3)
{
gUnknown_0203CD9C = a3;
gUnknown_0203CD9E = GetWindowAttribute(windowId, WINDOW_PALETTE_NUM);
CallWindowFunction(windowId, sub_8197BB4);
FillWindowPixelBuffer(windowId, 0x11);
PutWindowTilemap(windowId);
if (copyToVram == TRUE)
CopyWindowToVram(windowId, 3);
}
void sub_8197BB4(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
{
FillBgTilemapBufferRect(bg,
gUnknown_0203CD9C + 1,
tilemapLeft - 2,
tilemapTop - 1,
1,
1,
gUnknown_0203CD9E);
FillBgTilemapBufferRect(bg,
gUnknown_0203CD9C + 3,
tilemapLeft - 1,
tilemapTop - 1,
1,
1,
gUnknown_0203CD9E);
FillBgTilemapBufferRect(bg,
gUnknown_0203CD9C + 4,
tilemapLeft,
tilemapTop - 1,
width - 1,
1,
gUnknown_0203CD9E);
FillBgTilemapBufferRect(bg,
gUnknown_0203CD9C + 5,
tilemapLeft + width - 1,
tilemapTop - 1,
1,
1,
gUnknown_0203CD9E);
FillBgTilemapBufferRect(bg,
gUnknown_0203CD9C + 6,
tilemapLeft + width,
tilemapTop - 1,
1,
1,
gUnknown_0203CD9E);
FillBgTilemapBufferRect(bg,
gUnknown_0203CD9C + 7,
tilemapLeft - 2,
tilemapTop,
1,
5,
gUnknown_0203CD9E);
FillBgTilemapBufferRect(bg,
gUnknown_0203CD9C + 9,
tilemapLeft - 1,
tilemapTop,
width + 1,
5,
gUnknown_0203CD9E);
FillBgTilemapBufferRect(bg,
gUnknown_0203CD9C + 10,
tilemapLeft + width,
tilemapTop,
1,
5,
gUnknown_0203CD9E);
FillBgTilemapBufferRect(bg,
BG_TILE_V_FLIP(gUnknown_0203CD9C + 1),
tilemapLeft - 2,
tilemapTop + height,
1,
1,
gUnknown_0203CD9E);
FillBgTilemapBufferRect(bg,
BG_TILE_V_FLIP(gUnknown_0203CD9C + 3),
tilemapLeft - 1,
tilemapTop + height,
1,
1,
gUnknown_0203CD9E);
FillBgTilemapBufferRect(bg,
BG_TILE_V_FLIP(gUnknown_0203CD9C + 4),
tilemapLeft,
tilemapTop + height,
width - 1,
1,
gUnknown_0203CD9E);
FillBgTilemapBufferRect(bg,
BG_TILE_V_FLIP(gUnknown_0203CD9C + 5),
tilemapLeft + width - 1,
tilemapTop + height,
1,
1,
gUnknown_0203CD9E);
FillBgTilemapBufferRect(bg,
BG_TILE_V_FLIP(gUnknown_0203CD9C + 6),
tilemapLeft + width,
tilemapTop + height,
1,
1,
gUnknown_0203CD9E);
}
void sub_8197DF8(u8 windowId, bool8 copyToVram)
{
CallWindowFunction(windowId, sub_8197E30);
FillWindowPixelBuffer(windowId, 0);
ClearWindowTilemap(windowId);
if (copyToVram == TRUE)
CopyWindowToVram(windowId, 3);
}
void sub_8197E30(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
{
FillBgTilemapBufferRect(bg, 0, tilemapLeft - 3, tilemapTop - 1, width + 6, height + 2, 0);
}
void SetWindowBorderStyle(u8 windowId, bool8 copyToVram, u16 baseTileNum, u8 paletteNum)
{
gUnknown_0203CD9C = baseTileNum;
gUnknown_0203CD9E = paletteNum;
CallWindowFunction(windowId, DrawWindowBorder);
FillWindowPixelBuffer(windowId, 0x11);
PutWindowTilemap(windowId);
if (copyToVram == TRUE)
CopyWindowToVram(windowId, 3);
}
void sub_8197EC8(u8 windowId, bool8 copyToVram, u16 baseTileNum)
{
gUnknown_0203CD9C = baseTileNum;
gUnknown_0203CD9E = GetWindowAttribute(windowId, WINDOW_PALETTE_NUM);
CallWindowFunction(windowId, DrawWindowBorder);
FillWindowPixelBuffer(windowId, 0x11);
PutWindowTilemap(windowId);
if (copyToVram == TRUE)
CopyWindowToVram(windowId, 3);
}
void DrawWindowBorder(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
{
FillBgTilemapBufferRect(bg,
gUnknown_0203CD9C + 0,
tilemapLeft - 1,
tilemapTop - 1,
1,
1,
gUnknown_0203CD9E);
FillBgTilemapBufferRect(bg,
gUnknown_0203CD9C + 1,
tilemapLeft,
tilemapTop - 1,
width,
1,
gUnknown_0203CD9E);
FillBgTilemapBufferRect(bg,
gUnknown_0203CD9C + 2,
tilemapLeft + width,
tilemapTop - 1,
1,
1,
gUnknown_0203CD9E);
FillBgTilemapBufferRect(bg,
gUnknown_0203CD9C + 3,
tilemapLeft - 1,
tilemapTop,
1,
height,
gUnknown_0203CD9E);
FillBgTilemapBufferRect(bg,
gUnknown_0203CD9C + 5,
tilemapLeft + width,
tilemapTop,
1,
height,
gUnknown_0203CD9E);
FillBgTilemapBufferRect(bg,
gUnknown_0203CD9C + 6,
tilemapLeft - 1,
tilemapTop + height,
1,
1,
gUnknown_0203CD9E);
FillBgTilemapBufferRect(bg,
gUnknown_0203CD9C + 7,
tilemapLeft,
tilemapTop + height,
width,
1,
gUnknown_0203CD9E);
FillBgTilemapBufferRect(bg,
gUnknown_0203CD9C + 8,
tilemapLeft + width,
tilemapTop + height,
1,
1,
gUnknown_0203CD9E);
}
void sub_8198070(u8 windowId, bool8 copyToVram)
{
CallWindowFunction(windowId, sub_81980A8);
FillWindowPixelBuffer(windowId, 0);
ClearWindowTilemap(windowId);
if (copyToVram == TRUE)
CopyWindowToVram(windowId, 3);
}
void sub_81980A8(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
{
FillBgTilemapBufferRect(bg, 0, tilemapLeft - 1, tilemapTop - 1, width + 2, height + 2, 0);
}
u8 sub_81980F0(u8 bg, u8 xPos, u8 yPos, u8 palette, u16 baseTile)
{
struct WindowTemplate window;
memset(&window, 0, sizeof(window));
if (bg > 3)
window.priority = 0;
else
window.priority = bg;
window.tilemapTop = yPos;
window.height = 2;
window.tilemapLeft = 0x1E - xPos;
window.width = xPos;
window.paletteNum = palette;
window.baseBlock = baseTile;
gUnknown_0203CDA0 = AddWindow(&window);
if (palette > 15)
palette = 15 * 16;
else
palette *= 16;
LoadPalette(gUnknown_0860F0B0, palette, sizeof(gUnknown_0860F0B0));
return gUnknown_0203CDA0;
}
void sub_8198180(const u8 *string, u8 a2, bool8 copyToVram)
{
u16 width = 0;
if (gUnknown_0203CDA0 != 0xFF)
{
PutWindowTilemap(gUnknown_0203CDA0);
FillWindowPixelBuffer(gUnknown_0203CDA0, 0xFF);
width = GetStringWidth(0, string, 0);
box_print(gUnknown_0203CDA0,
0,
0xEC - (GetWindowAttribute(gUnknown_0203CDA0, WINDOW_TILEMAP_LEFT) * 8) - a2 - width,
1,
gUnknown_0860F0D0,
0,
string);
if (copyToVram)
CopyWindowToVram(gUnknown_0203CDA0, 3);
}
}
void sub_8198204(const u8 *string, const u8 *string2, u8 a3, u8 a4, bool8 copyToVram)
{
struct TextColor color;
u16 width = 0;
if (gUnknown_0203CDA0 != 0xFF)
{
if (a3 != 0)
{
color.fgColor = 0;
color.bgColor = 1;
color.shadowColor = 2;
}
else
{
color.fgColor = 15;
color.bgColor = 1;
color.shadowColor = 2;
}
PutWindowTilemap(gUnknown_0203CDA0);
FillWindowPixelBuffer(gUnknown_0203CDA0, 0xFF);
if (string2 != NULL)
{
width = GetStringWidth(0, string2, 0);
box_print(gUnknown_0203CDA0,
0,
0xEC - (GetWindowAttribute(gUnknown_0203CDA0, WINDOW_TILEMAP_LEFT) * 8) - a4 - width,
1,
&color,
0,
string2);
}
AddTextPrinterParameterized2(gUnknown_0203CDA0, 1, 4, 1, 0, 0, &color, 0, string);
if (copyToVram)
CopyWindowToVram(gUnknown_0203CDA0, 3);
}
}
void sub_81982D8(void)
{
if (gUnknown_0203CDA0 != 0xFF)
CopyWindowToVram(gUnknown_0203CDA0, 3);
}
void sub_81982F0(void)
{
if (gUnknown_0203CDA0 != 0xFF)
{
FillWindowPixelBuffer(gUnknown_0203CDA0, 0xFF);
CopyWindowToVram(gUnknown_0203CDA0, 3);
}
}
void sub_8198314(void)
{
if (gUnknown_0203CDA0 != 0xFF)
{
FillWindowPixelBuffer(gUnknown_0203CDA0, 0);
ClearWindowTilemap(gUnknown_0203CDA0);
CopyWindowToVram(gUnknown_0203CDA0, 3);
RemoveWindow(gUnknown_0203CDA0);
gUnknown_0203CDA0 = 0xFF;
}
}
u8 sub_8198348(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numChoices, u8 cursorPos, u8 a7)
{
s32 pos;
gUnknown_0203CD90.left = left;
gUnknown_0203CD90.top = top;
gUnknown_0203CD90.minCursorPos = 0;
gUnknown_0203CD90.maxCursorPos = numChoices - 1;
gUnknown_0203CD90.windowId = windowId;
gUnknown_0203CD90.fontId = fontId;
gUnknown_0203CD90.cursorHeight = cursorHeight;
gUnknown_0203CD90.menu_field_B = a7;
pos = cursorPos;
if (pos < 0 || pos > gUnknown_0203CD90.maxCursorPos)
gUnknown_0203CD90.cursorPos = 0;
else
gUnknown_0203CD90.cursorPos = pos;
MoveMenuCursor(0);
return gUnknown_0203CD90.cursorPos;
}
u8 sub_81983AC(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numChoices, u8 cursorPos)
{
return sub_8198348(windowId, fontId, left, top, cursorHeight, numChoices, cursorPos, 0);
}
u8 sub_81983EC(u8 windowId, u8 fontId, u8 left, u8 top, u8 numChoices, u8 cursorPos)
{
return sub_81983AC(windowId, fontId, left, top, GetMenuCursorDimensionByFont(fontId, 1), numChoices, cursorPos);
}
void RedrawMenuCursor(u8 oldPos, u8 newPos)
{
u8 width, height;
width = GetMenuCursorDimensionByFont(gUnknown_0203CD90.fontId, 0);
height = GetMenuCursorDimensionByFont(gUnknown_0203CD90.fontId, 1);
FillWindowPixelRect(gUnknown_0203CD90.windowId, 0x11, gUnknown_0203CD90.left, gUnknown_0203CD90.cursorHeight * oldPos + gUnknown_0203CD90.top, width, height);
PrintTextOnWindow(gUnknown_0203CD90.windowId, gUnknown_0203CD90.fontId, gText_SelectorArrow3, gUnknown_0203CD90.left, gUnknown_0203CD90.cursorHeight * newPos + gUnknown_0203CD90.top, 0, 0);
}
u8 MoveMenuCursor(s8 cursorDelta)
{
u8 oldPos = gUnknown_0203CD90.cursorPos;
int newPos = gUnknown_0203CD90.cursorPos + cursorDelta;
if (newPos < gUnknown_0203CD90.minCursorPos)
gUnknown_0203CD90.cursorPos = gUnknown_0203CD90.maxCursorPos;
else if (newPos > gUnknown_0203CD90.maxCursorPos)
gUnknown_0203CD90.cursorPos = gUnknown_0203CD90.minCursorPos;
else
gUnknown_0203CD90.cursorPos += cursorDelta;
RedrawMenuCursor(oldPos, gUnknown_0203CD90.cursorPos);
return gUnknown_0203CD90.cursorPos;
}
u8 MoveMenuCursorNoWrapAround(s8 cursorDelta)
{
u8 oldPos = gUnknown_0203CD90.cursorPos;
int newPos = gUnknown_0203CD90.cursorPos + cursorDelta;
if (newPos < gUnknown_0203CD90.minCursorPos)
gUnknown_0203CD90.cursorPos = gUnknown_0203CD90.minCursorPos;
else if (newPos > gUnknown_0203CD90.maxCursorPos)
gUnknown_0203CD90.cursorPos = gUnknown_0203CD90.maxCursorPos;
else
gUnknown_0203CD90.cursorPos += cursorDelta;
RedrawMenuCursor(oldPos, gUnknown_0203CD90.cursorPos);
return gUnknown_0203CD90.cursorPos;
}
u8 GetMenuCursorPos(void)
{
return gUnknown_0203CD90.cursorPos;
}
s8 ProcessMenuInput(void)
{
if (gMain.newKeys & A_BUTTON)
{
if (!gUnknown_0203CD90.menu_field_B)
PlaySE(SE_SELECT);
return gUnknown_0203CD90.cursorPos;
}
if (gMain.newKeys & B_BUTTON)
{
return -1;
}
if (gMain.newKeys & DPAD_UP)
{
PlaySE(SE_SELECT);
MoveMenuCursor(-1);
return -2;
}
else if (gMain.newKeys & DPAD_DOWN)
{
PlaySE(SE_SELECT);
MoveMenuCursor(1);
return -2;
}
return -2;
}
s8 ProcessMenuInputNoWrapAround(void)
{
u8 oldPos = gUnknown_0203CD90.cursorPos;
if (gMain.newKeys & A_BUTTON)
{
if (!gUnknown_0203CD90.menu_field_B)
PlaySE(SE_SELECT);
return gUnknown_0203CD90.cursorPos;
}
if (gMain.newKeys & B_BUTTON)
{
return -1;
}
if (gMain.newKeys & DPAD_UP)
{
if (oldPos != MoveMenuCursorNoWrapAround(-1))
PlaySE(SE_SELECT);
return -2;
}
else if (gMain.newKeys & DPAD_DOWN)
{
if (oldPos != MoveMenuCursorNoWrapAround(1))
PlaySE(SE_SELECT);
return -2;
}
return -2;
}
s8 ProcessMenuInput_other(void)
{
if (gMain.newKeys & A_BUTTON)
{
if (!gUnknown_0203CD90.menu_field_B)
PlaySE(SE_SELECT);
return gUnknown_0203CD90.cursorPos;
}
if (gMain.newKeys & B_BUTTON)
{
return -1;
}
if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP)
{
PlaySE(SE_SELECT);
MoveMenuCursor(-1);
return -2;
}
else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN)
{
PlaySE(SE_SELECT);
MoveMenuCursor(1);
return -2;
}
return -2;
}
s8 ProcessMenuInputNoWrapAround_other(void)
{
u8 oldPos = gUnknown_0203CD90.cursorPos;
if (gMain.newKeys & A_BUTTON)
{
if (!gUnknown_0203CD90.menu_field_B)
PlaySE(SE_SELECT);
return gUnknown_0203CD90.cursorPos;
}
if (gMain.newKeys & B_BUTTON)
{
return -1;
}
if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP)
{
if (oldPos != MoveMenuCursorNoWrapAround(-1))
PlaySE(SE_SELECT);
return -2;
}
else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN)
{
if (oldPos != MoveMenuCursorNoWrapAround(1))
PlaySE(SE_SELECT);
return -2;
}
return -2;
}
void PrintTextArray(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *strs)
{
u8 i;
for (i = 0; i < itemCount; i++)
{
PrintTextOnWindow(windowId, fontId, strs[i].text, left, (lineHeight * i) + top, 0xFF, NULL);
}
CopyWindowToVram(windowId, 2);
}
void sub_81987BC(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, u8 a6, u8 a7)
{
u8 i;
for (i = 0; i < itemCount; i++)
{
sub_8199F74(windowId, fontId, strs[i].text, left, (lineHeight * i) + top, 0xFF, NULL, a6, a7);
}
CopyWindowToVram(windowId, 2);
}
void sub_8198854(u8 windowId, u8 fontId, u8 lineHeight, u8 itemCount, const struct MenuAction *strs)
{
PrintTextArray(windowId, fontId, GetFontAttribute(fontId, 0), 1, lineHeight, itemCount, strs);
}
void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, const u8 *a8)
{
u8 i;
struct TextSubPrinter printer;
printer.windowId = windowId;
printer.fontId = fontId;
printer.fgColor = GetFontAttribute(fontId, 5);
printer.bgColor = GetFontAttribute(fontId, 6);
printer.shadowColor = GetFontAttribute(fontId, 7);
printer.fontColor_l = GetFontAttribute(fontId, 4);
printer.letterSpacing = letterSpacing;
printer.lineSpacing = GetFontAttribute(fontId, 3);
printer.x = left;
printer.currentX = left;
for (i = 0; i < itemCount; i++)
{
printer.current_text_offset = strs[a8[i]].text;
printer.y = (lineHeight * i) + top;
printer.currentY = printer.y;
AddTextPrinter(&printer, 0xFF, 0);
}
CopyWindowToVram(windowId, 2);
}
void sub_81989B8(u8 windowId, u8 fontId, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, const u8 *a5)
{
AddItemMenuActionTextPrinters(windowId, fontId, GetFontAttribute(fontId, 0), 1, GetFontAttribute(fontId, 2), lineHeight, itemCount, strs, a5);
}
void SetWindowTemplateFields(struct WindowTemplate *template, u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock)
{
template->priority = bg;
template->tilemapLeft = left;
template->tilemapTop = top;
template->width = width;
template->height = height;
template->paletteNum = paletteNum;
template->baseBlock = baseBlock;
}
struct WindowTemplate sub_8198A50(u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock)
{
struct WindowTemplate template;
SetWindowTemplateFields(&template, bg, left, top, width, height, paletteNum, baseBlock);
return template;
}
u16 sub_8198AA4(u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock)
{
struct WindowTemplate template;
SetWindowTemplateFields(&template, bg, left, top, width, height, paletteNum, baseBlock);
return AddWindow(&template);
}
void sub_8198AF8(struct WindowTemplate *window, u8 fontId, u8 left, u8 top, u16 baseTileNum, u8 paletteNum, u8 cursorPos)
{
struct TextSubPrinter printer;
gUnknown_0203CD9F = AddWindow(window);
SetWindowBorderStyle(gUnknown_0203CD9F, TRUE, baseTileNum, paletteNum);
printer.current_text_offset = gText_YesNo;
printer.windowId = gUnknown_0203CD9F;
printer.fontId = fontId;
printer.x = GetFontAttribute(fontId, 0) + left;
printer.y = top;
printer.currentX = printer.x;
printer.currentY = printer.y;
printer.fgColor = GetFontAttribute(fontId, 5);
printer.bgColor = GetFontAttribute(fontId, 6);
printer.shadowColor = GetFontAttribute(fontId, 7);
printer.fontColor_l = GetFontAttribute(fontId, 4);
printer.letterSpacing = GetFontAttribute(fontId, 2);
printer.lineSpacing = GetFontAttribute(fontId, 3);
AddTextPrinter(&printer, 0xFF, 0);
sub_81983AC(gUnknown_0203CD9F, fontId, left, top, GetFontAttribute(fontId, 1), 2, cursorPos);
}
void sub_8198C34(struct WindowTemplate *window, u8 fontId, u16 baseTileNum, u8 paletteNum)
{
sub_8198AF8(window, fontId, 0, 1, baseTileNum, paletteNum, 0);
}
s8 ProcessMenuInputNoWrap_(void)
{
s8 result = ProcessMenuInputNoWrapAround();
if (result != -2)
sub_8198C78();
return result;
}
void sub_8198C78(void)
{
sub_8198070(gUnknown_0203CD9F, TRUE);
RemoveWindow(gUnknown_0203CD9F);
}
void sub_8198C94(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 a5, u8 a6, u8 a7, const struct MenuAction *strs)
{
u8 i;
u8 j;
for (i = 0; i < a7; i++)
{
for (j = 0; j < a6; j++)
{
PrintTextOnWindow(windowId, fontId, strs[(i * a6) + j].text, (a4 * j) + left, (a5 * i) + top, 0xFF, NULL);
}
}
CopyWindowToVram(windowId, 2);
}
void sub_8198D54(u8 windowId, u8 fontId, u8 a2, u8 a3, u8 a4, u8 a5, const struct MenuAction *strs)
{
sub_8198C94(windowId, fontId, GetFontAttribute(fontId, 0), 0, a2, a3, a4, a5, strs);
}
void sub_8198DBC(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 itemCount, u8 itemCount2, const struct MenuAction *strs, const u8 *a8)
{
u8 i;
u8 j;
struct TextSubPrinter printer;
printer.windowId = windowId;
printer.fontId = fontId;
printer.fgColor = GetFontAttribute(fontId, 5);
printer.bgColor = GetFontAttribute(fontId, 6);
printer.shadowColor = GetFontAttribute(fontId, 7);
printer.fontColor_l = GetFontAttribute(fontId, 4);
printer.letterSpacing = GetFontAttribute(fontId, 2);
printer.lineSpacing = GetFontAttribute(fontId, 3);
for (i = 0; i < itemCount2; i++)
{
for (j = 0; j < itemCount; j++)
{
printer.current_text_offset = strs[a8[(itemCount * i) + j]].text;
printer.x = (a4 * j) + left;
printer.y = (GetFontAttribute(fontId, 1) * i) + top;
printer.currentX = printer.x;
printer.currentY = printer.y;
AddTextPrinter(&printer, 0xFF, 0);
}
}
CopyWindowToVram(windowId, 2);
}
void sub_8198EF8(u8 windowId, u8 fontId, u8 a2, u8 a3, u8 a4, u8 a5, const struct MenuAction *strs, const u8 *a8)
{
sub_8198DBC(windowId, fontId, GetFontAttribute(fontId, 0), 0, a2, a4, a5, strs, a8);
}
u8 sub_8198F58(u8 a0, u8 a1, s8 a2, s8 a3, u8 a4, u8 a5, u8 a6, u8 a7, u8 a8, u8 a9)
{
s32 pos;
gUnknown_0203CD90.left = a2;
gUnknown_0203CD90.top = a3;
gUnknown_0203CD90.minCursorPos = 0;
gUnknown_0203CD90.maxCursorPos = a8 - 1;
gUnknown_0203CD90.windowId = a0;
gUnknown_0203CD90.fontId = a1;
gUnknown_0203CD90.menu_field_7 = a4;
gUnknown_0203CD90.cursorHeight = a5;
gUnknown_0203CD90.menu_field_9 = a6;
gUnknown_0203CD90.menu_field_A = a7;
pos = a9;
if (pos < 0 || pos > gUnknown_0203CD90.maxCursorPos)
gUnknown_0203CD90.cursorPos = 0;
else
gUnknown_0203CD90.cursorPos = pos;
sub_8199134(0, 0);
return gUnknown_0203CD90.cursorPos;
}

View File

@ -13,17 +13,23 @@
#define DLG_WINDOW_PALETTE_NUM 15
#define DLG_WINDOW_BASE_TILE_NUM 0x200
extern EWRAM_DATA u8 gUnknown_0203CD8C;
extern EWRAM_DATA u8 gUnknown_0203CD8D;
static EWRAM_DATA u8 gUnknown_0203CD8C = 0;
static EWRAM_DATA u8 gUnknown_0203CD8D = 0;
extern const u8 gUnknown_0860EA6C[];
extern const u16 gUnknown_0860EA4C[];
extern const u16 gUnknown_0860F074[];
extern const u8 gUnknown_0860F094[];
extern const struct WindowTemplate gUnknown_0860F098[];
extern const struct WindowTemplate gUnknown_0860F0A8;
const u16 gUnknown_0860F074[] = INCBIN_U16("graphics/interface/860F074.gbapal");
static const u8 gUnknown_0860F094[] = { 8, 4, 1 };
static const struct WindowTemplate gUnknown_0860F098[] =
{
{ 0x00, 0x02, 0x0F, 0x1B, 0x04, 0x0F, 0x194 },
DUMMY_WIN_TEMPLATE
};
static const struct WindowTemplate gUnknown_0860F0A8 =
{
0x00, 0x15, 0x09, 0x05, 0x04, 0x0F, 0x125
};
extern void sub_819645C(void);
// Forward declarations
extern void sub_81973A4(void);
extern void DrawStandardFrame(u8, u8, u8, u8, u8, u8);
@ -31,17 +37,6 @@ extern void DrawDialogueFrame(u8, u8, u8, u8, u8, u8);
extern void sub_81977BC(u8, u8, u8, u8, u8, u8);
extern void sub_8197804(u8, u8, u8, u8, u8, u8);
void sub_8197184(u8 window, u32 destTile, u32 destPalette)
{
LoadBgTiles(GetWindowAttribute(window, WINDOW_PRIORITY), gUnknown_0860EA6C, 0x100, destTile);
LoadPalette(gUnknown_0860EA4C, destPalette * 16, 32);
}
void sub_81971C4(void)
{
sub_819645C();
}
void sub_81971D0(void)
{
InitWindows(gUnknown_0860F098);

View File

@ -1340,12 +1340,9 @@ gUnknown_0203CD80: @ 203CD80
gUnknown_0203CD88: @ 203CD88
.space 0x4
gUnknown_0203CD8C: @ 203CD8C
.space 0x1
gUnknown_0203CD8D: @ 203CD8D
.space 0x3
.include "src/new_menu_helpers.o"
.align 2
gUnknown_0203CD90: @ 203CD90
.space 0xC