WINTEMPLATE_FLAG

This commit is contained in:
Kermalis 2025-11-25 02:19:52 -05:00
parent 58b6d793e4
commit 9ee5b98e5a
35 changed files with 408 additions and 356 deletions

View File

@ -1,6 +1,6 @@
#ifndef GUARD_CLEARED_WINDOW_H
#define GUARD_CLEARED_WINDOW_H
void ShowDungeonClearedWindow(void);
void ShowDungeonClearedWindow_Async(void);
#endif // GUARD_CLEARED_WINDOW_H

View File

@ -98,33 +98,34 @@ typedef struct MenuHeaderWindow
/* R=0x9C | B=0x98 */ WindowHeader header;
} MenuHeaderWindow;
// I think the `+ 2`s below are actually `+ WINDOW_HEADER_HEIGHT`...
// These macros are used for updating menu windows, as the last page can have less entries than other pages, so the window's height needs to reflect that.
// Note: In order to get matching ASM, this macro had to be created.
// It's probable the code below is not exactly how it was originally written, but it generates the same asm.
#define UPDATE_MENU_WINDOW_HEIGHT_INTERNAL(ptr, _newHeight) \
{ \
UNUSED s32 newheightInTiles; \
UNUSED s32 newtotalHeight; \
s16 newHeight; \
s16 newHeightVal = (_newHeight); \
UNUSED s32 dummyMatch = newHeightVal; \
UNUSED s16 oldHeight = (ptr).windows.id[(ptr).menuWinId].height; \
dummyMatch = 0; \
newheightInTiles = newHeightVal + 2; \
newtotalHeight = newHeightVal + 2; \
newHeight = newHeightVal; \
\
(ptr).windows.id[(ptr).menuWinId].height = newHeight; \
(ptr).windows.id[(ptr).menuWinId].heightInTiles = newHeightVal + 2; \
(ptr).windows.id[(ptr).menuWinId].totalHeight = newHeightVal + 2; \
\
ResetUnusedInputStruct(); \
ShowWindows(&(ptr).windows, TRUE, TRUE); \
}
#define UPDATE_MENU_WINDOW_HEIGHT(ptr) \
{ \
#define UPDATE_MENU_WINDOW_HEIGHT(ptr) \
{ \
UPDATE_MENU_WINDOW_HEIGHT_INTERNAL(ptr, CalcEntriesTotalHeight((ptr).input.currPageEntries, DEFAULT_MENU_ENTRY_HEIGHT) + 2) \
}
// For Windows where height is the same as unk10.
#define UPDATE_MENU_WINDOW_HEIGHT_2(ptr) \
{ \
s32 newHeightVal = CalcEntriesTotalHeight((ptr).input.currPageEntries, DEFAULT_MENU_ENTRY_HEIGHT) + 2; \
@ -132,7 +133,7 @@ typedef struct MenuHeaderWindow
s16 newHeight = newHeightVal; \
\
(ptr).windows.id[(ptr).menuWinId].height = newHeight; \
(ptr).windows.id[(ptr).menuWinId].heightInTiles = newHeight; \
(ptr).windows.id[(ptr).menuWinId].totalHeight = newHeight; \
\
ResetUnusedInputStruct(); \
ShowWindows(&(ptr).windows, TRUE, TRUE); \

View File

@ -1,7 +1,7 @@
#ifndef GUARD_RGB_H
#define GUARD_RGB_H
// 0x4
// Size: 0x4
typedef struct RGB_Struct
{
u8 r;
@ -16,17 +16,25 @@ typedef struct RGB_Struct
#define RGB_UNK 3
#define RGB_FIELDS_COUNT 4
// Size: 0x4
typedef struct RGB_Array
{
u8 c[RGB_FIELDS_COUNT];
} RGB_Array;
// Size: 0x4
typedef union RGB_Union
{
RGB_Array asArr;
RGB_Struct separate;
} RGB_Union;
// Size: 0x40
typedef struct RGB_Palette
{
/* 0x0 */ RGB_Struct colors[16];
} RGB_Palette;
#define RGB_TO_GBA(r, g, b) RGB2(((u32)(r) & 0xF8) >> 3, ((g) & 0xF8) >> 3, ((b) & 0xF8) >> 3)
// Needed to match, functionally equivalent to the above.
#define RGB_TO_GBA2(r, g, b)(((u32)((b) & 0xF8) >> 2 << 9) | (((u32)(g) & 0xF8) >> 3 << 5) | (((u32)(r) & 0xF8) >> 3))

View File

@ -3,6 +3,16 @@
#include "structs/str_position.h"
#define WINDOW_HEADER_HEIGHT 2
enum WinTemplateFlag
{
WINTEMPLATE_FLAG_NONE = 0,
WINTEMPLATE_FLAG_x20 = (1 << 5),
WINTEMPLATE_FLAG_x40 = (1 << 6),
WINTEMPLATE_FLAG_x80 = (1 << 7), // Appears to skip the border and preparation in `AddWindow()`
};
// size: 0xC
typedef struct unkChar
{
@ -21,25 +31,25 @@ typedef struct Window
/* 0x0 */ s16 x;
/* 0x2 */ s16 y;
/* 0x4 */ s16 width;
/* 0x6 */ s16 height;
/* 0x8 */ s16 heightInTiles;
/* 0x6 */ s16 height; // Inner height
/* 0x8 */ s16 totalHeight; // Including header
/* 0xC */ s32 type;
/* 0x10 */ u32 unk10;
/* 0x14 */ u32 unk14;
/* 0x18 */ u32 *unk18; // Appears to be window graphics data
/* 0x1C */ u32 *unk1C;
/* 0x20 */ s32 unk20;
/* 0x24 */ s32 unk24;
/* 0x10 */ u32 unk10; // winGFX start tile?
/* 0x14 */ u32 unk14; // unk1C start tile?
/* 0x18 */ u32 *winGFX; // 8 packed pixels. Each pixel is 4 bits wide.
/* 0x1C */ u32 *unk1C; // Similar to winGFX
/* 0x20 */ s32 unk20; // Some width relation to winGFX (stride?)
/* 0x24 */ s32 unk24; // Set from winTemplate unk12
/* 0x28 */ u32 *unk28; // Somewhere in VRAM
/* 0x2C */ s32 unk2C;
/* 0x30 */ u32 *unk30; // Somewhere in VRAM?
/* 0x34 */ u32 *unk34;
/* 0x38 */ s32 unk38;
/* 0x3C */ u32 *unk3C;
/* 0x40 */ u32 *unk40;
/* 0x44 */ u8 unk44;
/* 0x45 */ bool8 unk45;
/* 0x46 */ u8 unk46;
/* 0x2C */ s32 unk2C; // Related to unk38
/* 0x30 */ u32 *unk30; // Somewhere in VRAM
/* 0x34 */ u32 *unk34; // Related to unk1C and unk3C
/* 0x38 */ s32 unk38; // Related to unk2C and unk44
/* 0x3C */ u32 *unk3C; // Somewhere in winGFX or unk1C
/* 0x40 */ u32 *unk40; // Somewhere in winGFX or unk1C
/* 0x44 */ bool8 unk44; // Related to unk38 not being 0
/* 0x45 */ bool8 isWinType0;
/* 0x46 */ bool8 unk46;
} Window;
// size: 0x4
@ -54,13 +64,13 @@ typedef struct WindowHeader
// size: 0x18
typedef struct WindowTemplate
{
/* 0x00 */ u8 unk0; // Appears to be some bit flags
/* 0x00 */ u8 flags; // See enum "WinTemplateFlag"
/* 0x04 */ s32 type;
/* 0x08 */ DungeonPos pos;
/* 0x0C */ s16 width;
/* 0x0E */ s16 height;
/* 0x10 */ s16 heightInTiles;
/* 0x12 */ s16 unk12;
/* 0x0E */ s16 height; // Inner height
/* 0x10 */ s16 totalHeight; // Including header
/* 0x12 */ s16 unk12; // Related to startTileNum and width
/* 0x14 */ const WindowHeader *header;
} WindowTemplate;
@ -76,7 +86,7 @@ typedef struct WindowTemplate
#define MAX_WINDOWS 4
// All fields are zeroed out except for type which is set to WINDOW_TYPE_NORMAL.
#define WIN_TEMPLATE_DUMMY (WindowTemplate) { .unk0 = 0, .type = WINDOW_TYPE_NORMAL, .pos = { .x = 0, .y = 0 }, .width = 0, .height = 0, .heightInTiles = 0, .unk12 = 0, .header = NULL }
#define WIN_TEMPLATE_DUMMY (WindowTemplate) { .flags = WINTEMPLATE_FLAG_NONE, .type = WINDOW_TYPE_NORMAL, .pos = { .x = 0, .y = 0 }, .width = 0, .height = 0, .totalHeight = 0, .unk12 = 0, .header = NULL }
// size: 0x60
typedef struct WindowTemplates

View File

@ -13,7 +13,8 @@ void PrepareTextbox_8008C6C(Window *windows, u32 windowId);
void ResetWindowBgData(void);
void sub_8007A78(u32 a0, s32 x, s32 y, s32 a3, u32 color);
void sub_8007B7C(u32 a0, s32 x, s32 y, s32 a3, u32 color);
void sub_8007E20(u32 winID, u32 x, u32 y, u32 w, u32 h, u32 src[8], u32 palNum);
// srcGFX: Each u32 is 8 packed pixels, 4 bits per pixel.
void WriteGFXToBG0Window(u32 winID, u32 x, u32 y, u32 w, u32 h, u32 *srcGFX, u32 palNum);
void sub_80087EC(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4);
void sub_80089AC(const WindowTemplate *r4, DungeonPos *r5_Str);
u32 DrawCharOnWindow(s32 x, s32 y, u32 chr, u32 color, u32 windowId);

View File

@ -32,10 +32,14 @@
#include "wonder_mail_802C4C8.h"
#include "wonder_mail_802C860.h"
#define RANK_ICON_W 16
#define RANK_ICON_H 16
#define RANK_ICON_4BPP_LEN (RANK_ICON_W * RANK_ICON_H / 8)
// size: 0x8
struct TeamBadgeData
{
/* 0x0 */ u32 *pics; // Array of (MAX_TEAM_RANKS * 32)
/* 0x0 */ u32 *gfx; // Array of (MAX_TEAM_RANKS * RANK_ICON_4BPP_LEN)
/* 0x4 */ RGB_Struct *palette; // Array of 16
};
@ -598,14 +602,14 @@ static void sub_801D894(void)
static void LoadTeamRankBadge(u32 winID, u32 x, u32 y)
{
OpenedFile *teamBadgeFile;
u32 *pic;
u32 *gfx;
RGB_Struct *pal;
s32 i;
teamBadgeFile = OpenFileAndGetFileDataPtr(sTeamRankBadgeFileName, &gTitleMenuFileArchive);
#define TMRKPAT_DATA ((struct TeamBadgeData *)teamBadgeFile->data)
pic = TMRKPAT_DATA->pics;
gfx = TMRKPAT_DATA->gfx;
pal = TMRKPAT_DATA->palette;
for (i = 0; i < 16; i++) {
@ -613,8 +617,8 @@ static void LoadTeamRankBadge(u32 winID, u32 x, u32 y)
pal++;
}
pic = &pic[GetRescueTeamRank() * 32];
sub_8007E20(winID, x, y, 16, 16, pic, 14);
gfx = &gfx[GetRescueTeamRank() * RANK_ICON_4BPP_LEN];
WriteGFXToBG0Window(winID, x, y, RANK_ICON_W, RANK_ICON_H, gfx, 14);
#undef TMRKPAT_DATA
CloseFile(teamBadgeFile);

View File

@ -21,12 +21,12 @@ EWRAM_INIT unkStruct_203B3FC *gUnknown_203B3FC = NULL; // arm9.bin::020EAF84
const WindowTemplate gUnknown_80E7F3C = WIN_TEMPLATE_DUMMY;
const WindowTemplate gUnknown_80E7F54 = {
.unk0 = 0,
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_WITH_HEADER,
.pos = { 2, 2 },
.width = 24,
.height = 17,
.heightInTiles = 17,
.totalHeight = 17,
.unk12 = 0,
.header = NULL
};

View File

@ -12,12 +12,12 @@ EWRAM_INIT static Credits1Work *sCredits1Work = {NULL};
static const WindowTemplate sDummyWinTemplate = WIN_TEMPLATE_DUMMY;
static const WindowTemplate gUnknown_80E4A28 = {
.unk0 = 0,
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_ONLY_TEXT,
.pos = { 2, 2 },
.width = 26,
.height = 16,
.heightInTiles = 16,
.totalHeight = 16,
.unk12 = 0,
.header = NULL,
};

View File

@ -1,28 +1,25 @@
static const WindowTemplate sUnknown_80DB6DC = {
0,
3,
0, 0,
0, 0,
0, 0,
NULL
};
static const WindowTemplate sUnknown_80DB6DC = WIN_TEMPLATE_DUMMY;
static const WindowTemplate sUnknown_80DB6F4 = {
0,
3,
2, 3,
26, 2,
2, 0,
NULL
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_NORMAL,
.pos = { 2, 3 },
.width = 26,
.height = 2,
.totalHeight = 2,
.unk12 = 0,
.header = NULL
};
static const WindowTemplate sUnknown_80DB70C = {
0,
3,
17, 8,
11, 4,
4, 0,
NULL
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_NORMAL,
.pos = { 17, 8 },
.width = 11,
.height = 4,
.totalHeight = 4,
.unk12 = 0,
.header = NULL
};
ALIGNED(4) static const u8 sDisplayMoney[] = _("Money: ");

View File

@ -18,12 +18,12 @@ EWRAM_INIT static struct MenuHeaderWindow *sDebugWindow = {NULL};
static const WindowTemplate sDummyWinTemplate = WIN_TEMPLATE_DUMMY;
static const WindowTemplate sDebugWindowTemplate = {
.unk0 = 0,
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_WITH_HEADER,
.pos = { 2, 2 },
.width = 24,
.height = 17,
.heightInTiles = 17,
.totalHeight = 17,
.unk12 = 0,
.header = NULL,
};

View File

@ -12,17 +12,18 @@
#include "game_options.h"
#include "constants/dungeon_exit.h"
void ShowDungeonClearedWindow(void)
void ShowDungeonClearedWindow_Async(void)
{
WindowHeader header;
WindowTemplates windows = {
.id = {
[0] = {
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_WITH_HEADER,
.pos = { 4, 3 },
.width = 22,
.height = 14,
.heightInTiles = 14,
.totalHeight = 14,
.unk12 = 0,
.header = &header,
},
@ -36,28 +37,35 @@ void ShowDungeonClearedWindow(void)
header.currId = 0;
header.width = 14;
header.f3 = 0;
windows.id[0].pos.y = 20;
DungeonShowWindows(&windows, TRUE);
if (gDungeon->exitSummary.exitReason >= DUNGEON_EXIT_REASON_SUCCESS) {
if (gDungeon->exitSummary.exitReason >= DUNGEON_EXIT_REASON_SUCCESS)
PlayDungeonCompleteBGM();
}
else {
else
PlayDungeonFailBGM();
}
PrintOnDungeonFinishedWindow(0, gText_TheLastOuting,&gDungeon->exitSummary);
while(TRUE) {
sub_803E668(0x36);
PrintOnDungeonFinishedWindow(0, gText_TheLastOuting, &gDungeon->exitSummary);
while (TRUE) {
sub_803E668(54);
UpdateDungeonMusic();
if (windows.id[0].pos.y >= 4){
if (windows.id[0].pos.y >= 4) {
windows.id[0].pos.y--;
windows.id[0].unk0 = 0xa0;
windows.id[0].flags = WINTEMPLATE_FLAG_x20 | WINTEMPLATE_FLAG_x80;
DungeonShowWindows(&windows, TRUE);
continue;
}
if (sub_8094D14())
break;
if (gRealInputs.pressed & A_BUTTON)
break;
}
PlayDungeonConfirmationSE();
}

View File

@ -29,23 +29,23 @@ static const WindowTemplate sWinTemplateDummy = WIN_TEMPLATE_DUMMY;
// Never used in-game. It's slightly narrower as it doesn't have space for go/envelope icons.
static const WindowTemplate sWinTemplateNarrow = {
.unk0 = 0,
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_WITH_HEADER,
.pos = { 2, 2 },
.width = 14,
.height = 14,
.heightInTiles = 14,
.totalHeight = 14,
.unk12 = 0,
.header = NULL,
};
static const WindowTemplate sWinTemplateWide = {
.unk0 = 0,
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_WITH_HEADER,
.pos = { 2, 2 },
.width = 16,
.height = 16,
.heightInTiles = 16,
.totalHeight = 16,
.unk12 = 0,
.header = NULL,
};

View File

@ -88,7 +88,7 @@ bool8 ShowDungeonItemsMenu(Entity * a0, struct UnkMenuBitsStruct *a1)
.pos = { 2, 2 },
.width = 18,
.height = 16,
.heightInTiles = 16,
.totalHeight = 16,
.header = &header,
},
[1] = WIN_TEMPLATE_DUMMY,
@ -351,7 +351,7 @@ static void PrintOnDungeonItemsMenu(s32 a0, Entity *a1, bool8 showWhichWindow, b
.pos = { 2, 4 },
.width = 6,
.height = 2,
.heightInTiles = 2,
.totalHeight = 2,
.unk12 = 0,
.header = NULL,
};
@ -373,7 +373,7 @@ static void PrintOnDungeonItemsMenu(s32 a0, Entity *a1, bool8 showWhichWindow, b
switch (sUnknown_202F248[a0]) {
case 0:
case 1: {
windows->id[0].heightInTiles = 16;
windows->id[0].totalHeight = 16;
windows->id[0].height = 16;
header->width = 12;
gDungeonMenu.firstEntryY = 16;
@ -382,7 +382,7 @@ static void PrintOnDungeonItemsMenu(s32 a0, Entity *a1, bool8 showWhichWindow, b
break;
}
case 2: {
windows->id[0].heightInTiles = 4;
windows->id[0].totalHeight = 4;
windows->id[0].height = 4;
header->width = 6;
gDungeonMenu.firstEntryY = 18;
@ -391,7 +391,7 @@ static void PrintOnDungeonItemsMenu(s32 a0, Entity *a1, bool8 showWhichWindow, b
}
case 3:
default: {
windows->id[0].heightInTiles = 4;
windows->id[0].totalHeight = 4;
windows->id[0].height = 4;
header->width = 12;
gDungeonMenu.firstEntryY = 18;

View File

@ -171,7 +171,7 @@ bool8 ShowDungeonMovesMenu(Entity * entity, bool8 addLinkOptions, bool8 addUseMo
.pos = { 2, 2 },
.width = 18,
.height = 16,
.heightInTiles = 16,
.totalHeight = 16,
.unk12 = 0,
.header = &header,
},
@ -404,7 +404,7 @@ static void ShowMovesMenuWindows(Entity *entity, EntityInfo *entInfo, bool8 redC
.pos = { 2, 14 },
.width = 26,
.height = 3,
.heightInTiles = 3,
.totalHeight = 3,
.unk12 = 0,
.header = NULL,
};
@ -432,7 +432,7 @@ static void ShowMovesMenuWindows(Entity *entity, EntityInfo *entInfo, bool8 redC
gDungeonMenu.windowId = 0;
ResetTouchScreenMenuInput(&gDungeonMenu.touchScreen);
windows->id[0].height = windows->id[0].heightInTiles = CalcEntriesTotalHeight(4, DEFAULT_MENU_ENTRY_HEIGHT) + 2;
windows->id[0].height = windows->id[0].totalHeight = CalcEntriesTotalHeight(4, DEFAULT_MENU_ENTRY_HEIGHT) + 2;
header->width = 13;
windows->id[0].pos.x = 2;
windows->id[1] = windows->id[3];
@ -904,7 +904,7 @@ bool8 sub_8063E70(Entity *entity, Move *moves, bool8 showYesNoBox, bool8 allowBP
.pos = { 2, 2 },
.width = 18,
.height = 16,
.heightInTiles = 16,
.totalHeight = 16,
.unk12 = 0,
.header = &header,
},
@ -1108,7 +1108,7 @@ static void sub_8064228(Entity *entity, Move *moves, WindowTemplates *windows, W
gDungeonMenu.unk14.x = 0;
gDungeonMenu.windowId = 0;
ResetTouchScreenMenuInput(&gDungeonMenu.touchScreen);
windows->id[0].height = windows->id[0].heightInTiles = CalcEntriesTotalHeight(count, DEFAULT_MENU_ENTRY_HEIGHT) + 2;
windows->id[0].height = windows->id[0].totalHeight = CalcEntriesTotalHeight(count, DEFAULT_MENU_ENTRY_HEIGHT) + 2;
header->width = 14;
windows->id[0].pos.x = 2;
windows->id[1] = windows->id[3];

View File

@ -455,7 +455,7 @@ static void PrintOthersMenuOptions(void)
.pos = { 2, 2 },
.width = 18,
.height = 16,
.heightInTiles = 16,
.totalHeight = 16,
.unk12 = 0,
.header = &header,
},
@ -482,7 +482,7 @@ static void PrintOthersMenuOptions(void)
gDungeonMenu.windowId = 0;
ResetTouchScreenMenuInput(&gDungeonMenu.touchScreen);
windows.id[0].width = 18;
windows.id[0].height = windows.id[0].heightInTiles = CalcEntriesTotalHeight(optionsCount, DEFAULT_MENU_ENTRY_HEIGHT) + 2;
windows.id[0].height = windows.id[0].totalHeight = CalcEntriesTotalHeight(optionsCount, DEFAULT_MENU_ENTRY_HEIGHT) + 2;
header.width = 10;
windows.id[0].pos.x = 2;
DungeonShowWindows(&windows, TRUE);
@ -518,7 +518,7 @@ static void PrintQuickSaveMenuOptions(void)
.pos = { 2, 2 },
.width = 18,
.height = 16,
.heightInTiles = 16,
.totalHeight = 16,
.unk12 = 0,
.header = &header,
},
@ -545,7 +545,7 @@ static void PrintQuickSaveMenuOptions(void)
gDungeonMenu.windowId = 0;
ResetTouchScreenMenuInput(&gDungeonMenu.touchScreen);
windows.id[0].width = 18;
windows.id[0].height = windows.id[0].heightInTiles = CalcEntriesTotalHeight(optionsCount, DEFAULT_MENU_ENTRY_HEIGHT) + 2;
windows.id[0].height = windows.id[0].totalHeight = CalcEntriesTotalHeight(optionsCount, DEFAULT_MENU_ENTRY_HEIGHT) + 2;
header.width = 10;
windows.id[0].pos.x = 2;
DungeonShowWindows(&windows, TRUE);
@ -571,7 +571,7 @@ static void PrintGameOptions(void)
.pos = { 2, 2 },
.width = 12,
.height = 16,
.heightInTiles = 16,
.totalHeight = 16,
.unk12 = 0,
.header = &header,
},
@ -598,7 +598,7 @@ static void PrintGameOptions(void)
gDungeonMenu.windowId = 0;
ResetTouchScreenMenuInput(&gDungeonMenu.touchScreen);
windows.id[0].width = 12;
windows.id[0].height = windows.id[0].heightInTiles = CalcEntriesTotalHeight(optionsCount, DEFAULT_MENU_ENTRY_HEIGHT) + 2;
windows.id[0].height = windows.id[0].totalHeight = CalcEntriesTotalHeight(optionsCount, DEFAULT_MENU_ENTRY_HEIGHT) + 2;
header.width = 10;
windows.id[0].pos.x = 2;
DungeonShowWindows(&windows, TRUE);
@ -626,7 +626,7 @@ static void PrintDungeonOptions(void)
.pos = { 2, 2 },
.width = 18,
.height = 16,
.heightInTiles = 16,
.totalHeight = 16,
.unk12 = 0,
.header = &header,
},
@ -653,7 +653,7 @@ static void PrintDungeonOptions(void)
gDungeonMenu.windowId = 0;
ResetTouchScreenMenuInput(&gDungeonMenu.touchScreen);
windows.id[0].width = 24;
windows.id[0].height = windows.id[0].heightInTiles = CalcEntriesTotalHeight(DUNGEON_OPTIONS_COUNT, DEFAULT_MENU_ENTRY_HEIGHT) + 2;
windows.id[0].height = windows.id[0].totalHeight = CalcEntriesTotalHeight(DUNGEON_OPTIONS_COUNT, DEFAULT_MENU_ENTRY_HEIGHT) + 2;
header.width = 10;
windows.id[0].pos.x = 2;
DungeonShowWindows(&windows, TRUE);
@ -717,7 +717,7 @@ static void PrintOthersOptions(void)
.pos = { 2, 2 },
.width = 18,
.height = 16,
.heightInTiles = 16,
.totalHeight = 16,
.unk12 = 0,
.header = &header,
},
@ -744,7 +744,7 @@ static void PrintOthersOptions(void)
gDungeonMenu.windowId = 0;
ResetTouchScreenMenuInput(&gDungeonMenu.touchScreen);
windows.id[0].width = 24;
windows.id[0].height = windows.id[0].heightInTiles = CalcEntriesTotalHeight(OTHERS_OPTIONS_COUNT, DEFAULT_MENU_ENTRY_HEIGHT) + 2;
windows.id[0].height = windows.id[0].totalHeight = CalcEntriesTotalHeight(OTHERS_OPTIONS_COUNT, DEFAULT_MENU_ENTRY_HEIGHT) + 2;
header.width = 10;
windows.id[0].pos.x = 2;
DungeonShowWindows(&windows, TRUE);
@ -890,7 +890,7 @@ static void PrintHintsMenu(void)
.pos = { 2, 2 },
.width = 12,
.height = 16,
.heightInTiles = 16,
.totalHeight = 16,
.unk12 = 0,
.header = &header,
},
@ -916,7 +916,7 @@ static void PrintHintsMenu(void)
gDungeonMenu.windowId = 0;
ResetTouchScreenMenuInput(&gDungeonMenu.touchScreen);
windows.id[0].width = 12;
windows.id[0].height = windows.id[0].heightInTiles = CalcEntriesTotalHeight(HINTS_COUNT_RED_VERSION, DEFAULT_MENU_ENTRY_HEIGHT) + 2;
windows.id[0].height = windows.id[0].totalHeight = CalcEntriesTotalHeight(HINTS_COUNT_RED_VERSION, DEFAULT_MENU_ENTRY_HEIGHT) + 2;
header.width = 10;
windows.id[0].pos.x = 2;
DungeonShowWindows(&windows, TRUE);
@ -943,7 +943,7 @@ static void ShowChosenHintWindow(s32 hintId)
.pos = { 2, 2 },
.width = 12,
.height = 16,
.heightInTiles = 16,
.totalHeight = 16,
.unk12 = 0,
.header = &header,
},
@ -967,7 +967,7 @@ static void ShowChosenHintWindow(s32 hintId)
gDungeonMenu.windowId = 0;
ResetTouchScreenMenuInput(&gDungeonMenu.touchScreen);
windows.id[0].width = 24;
windows.id[0].height = windows.id[0].heightInTiles = CalcEntriesTotalHeight(HINTS_COUNT, DEFAULT_MENU_ENTRY_HEIGHT) + 2;
windows.id[0].height = windows.id[0].totalHeight = CalcEntriesTotalHeight(HINTS_COUNT, DEFAULT_MENU_ENTRY_HEIGHT) + 2;
header.width = 10;
windows.id[0].pos.x = 2;
DungeonShowWindows(&windows, TRUE);

View File

@ -54,7 +54,7 @@ static const WindowTemplates sRecruitmentSearchWindows = {
.pos = { 2, 2 },
.width = 18,
.height = 14,
.heightInTiles = 18,
.totalHeight = 18,
.unk12 = 2,
.header = &sRecruitmentWindowHeader,
},

View File

@ -39,7 +39,7 @@ void ShowDungeonStairsMenu(Entity *mon)
.pos = { 2, 2 },
.width = 18,
.height = 4,
.heightInTiles = 16,
.totalHeight = 16,
.unk12 = 0,
.header = &header,
},
@ -159,7 +159,7 @@ static void ShowStairsDescription(DungeonPos *pos)
.pos = { 2, 2 },
.width = 26,
.height = 12,
.heightInTiles = 12,
.totalHeight = 12,
.unk12 = 0,
.header = &header,
},

View File

@ -86,7 +86,7 @@ bool8 ShowDungeonTeamMenu(Entity *a0)
.pos = { 2, 2 },
.width = 14,
.height = 16,
.heightInTiles = 16,
.totalHeight = 16,
.unk12 = 0,
.header = &sTeamWindowHeader,
},
@ -278,7 +278,7 @@ static void PrintOnDungeonTeamMenu(struct UnkFieldTeamMenuStruct *a0, WindowTemp
if (withHeader) {
height += 2;
}
windows->id[0].heightInTiles = height;
windows->id[0].totalHeight = height;
windows->id[0].height = height;
sTeamWindowHeader.width = 8;
if (a2) {
@ -418,7 +418,7 @@ void ShowDungeonTacticsMenu(ActionContainer *a0)
.pos = { 2, 2 },
.width = 18,
.height = 14,
.heightInTiles = 18,
.totalHeight = 18,
.unk12 = 2,
.header = &sTeamWindowHeader,
},
@ -643,7 +643,7 @@ void ShowDungeonSummaryOrIQMenu(ActionContainer *a0, bool8 showIq)
.pos = { 2, 2 },
.width = 18,
.height = 14,
.heightInTiles = 18,
.totalHeight = 18,
.unk12 = 2,
.header = &sTeamWindowHeader,
},
@ -1298,7 +1298,7 @@ static void ShowStatusInfoWindow(s32 statusId)
.pos = { 2, 2 },
.width = 26,
.height = 12,
.heightInTiles = 12,
.totalHeight = 12,
.unk12 = 0,
.header = &header,
},
@ -1343,7 +1343,7 @@ static const WindowTemplate sMovesSubMenu = {
.pos = { 2, 10 },
.width = 18,
.height = 8,
.heightInTiles = 8,
.totalHeight = 8,
.unk12 = 0,
.header = &sBottomWindowHeader,
};
@ -1352,7 +1352,7 @@ static const WindowTemplate sItemSubMenu = {
.pos = { 2, 10 },
.width = 18,
.height = 4,
.heightInTiles = 4,
.totalHeight = 4,
.unk12 = 0,
.header = &sBottomWindowHeader,
};
@ -1367,7 +1367,7 @@ Entity *ShowDungeonToWhichMonMenu(s32 *teamId, s32 caseId)
.pos = { 14, 2 },
.width = 14,
.height = 16,
.heightInTiles = 16,
.totalHeight = 16,
.unk12 = 0,
.header = &sTeamWindowHeader,
},
@ -1376,7 +1376,7 @@ Entity *ShowDungeonToWhichMonMenu(s32 *teamId, s32 caseId)
.pos = { 2, 2 },
.width = 10,
.height = 2,
.heightInTiles = 2,
.totalHeight = 2,
.unk12 = 0,
.header = NULL,
},

View File

@ -37,7 +37,7 @@ void ShowDungeonTileMenu(Entity *mon)
.pos = { 2, 2 },
.width = 18,
.height = 4,
.heightInTiles = 16,
.totalHeight = 16,
.unk12 = 0,
.header = &header,
},
@ -152,7 +152,7 @@ static void ShowTileDescription(DungeonPos *pos)
.pos = { 2, 2 },
.width = 26,
.height = 12,
.heightInTiles = 12,
.totalHeight = 12,
.unk12 = 0,
.header = &header,
},

View File

@ -55,23 +55,23 @@ static const WindowTemplates sReleaseMenuWindowTemplates = {
.id = {
[0] =
{
.unk0 = 0,
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_WITH_HEADER,
.pos = { 2, 2 },
.width = 17,
.height = 14,
.heightInTiles = 18,
.totalHeight = 18,
.unk12 = 2,
.header = &sReleaseMenuWinHeader
},
[1] =
{
.unk0 = 0,
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_NORMAL,
.pos = { 21, 4 },
.width = 7,
.height = 4,
.heightInTiles = 4,
.totalHeight = 4,
.unk12 = 0,
.header = NULL
},
@ -385,7 +385,7 @@ static void ShowPokemonSummary(Pokemon *a0)
winTemplates.id[0].pos.y = 2;
winTemplates.id[0].width = 18;
winTemplates.id[0].height = 14;
winTemplates.id[0].heightInTiles = 18;
winTemplates.id[0].totalHeight = 18;
winTemplates.id[0].unk12 = 2;
winTemplates.id[0].header = &sReleaseMenuWinHeader;

View File

@ -19,12 +19,12 @@ void CreateDungeonMenuSubWindow(WindowTemplate *mainWindow, s32 subWindowX)
.id = {
[0] = WIN_TEMPLATE_DUMMY,
[1] = {
.unk0 = 0,
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_NORMAL,
.pos = { 22, 4 },
.width = 6,
.height = 4,
.heightInTiles = 4,
.totalHeight = 4,
.unk12 = 0,
.header = NULL,
},
@ -34,7 +34,7 @@ void CreateDungeonMenuSubWindow(WindowTemplate *mainWindow, s32 subWindowX)
};
windows.id[0] = *mainWindow;
windows.id[0].unk0 = 0x80;
windows.id[0].flags = WINTEMPLATE_FLAG_x80;
gDungeonMenu.menuIndex = 0;
gDungeonMenu.entriesPerPage = gDungeonSubMenuItemsCount;
@ -52,7 +52,7 @@ void CreateDungeonMenuSubWindow(WindowTemplate *mainWindow, s32 subWindowX)
windows.id[1].pos.x = subWindowX;
windows.id[1].width = 28 - subWindowX;
windows.id[1].height = windows.id[1].heightInTiles = CalcEntriesTotalHeight(gDungeonMenu.entriesPerPage, 0);
windows.id[1].height = windows.id[1].totalHeight = CalcEntriesTotalHeight(gDungeonMenu.entriesPerPage, 0);
DungeonShowWindows(&windows, FALSE);
sub_80137B0(&gDungeonMenu, windows.id[1].height * 8);
sub_80073B8(1);

View File

@ -464,7 +464,7 @@ static const WindowTemplates gUnknown_80F62B0 =
.pos = { 2, 15 },
.width = 26,
.height = 5,
.heightInTiles = 7,
.totalHeight = 7,
.unk12 = 0,
.header = NULL,
},
@ -482,7 +482,7 @@ static const WindowTemplates gUnknown_80F6310 =
.pos = { 2, 3 },
.width = 6,
.height = 7,
.heightInTiles = 7,
.totalHeight = 7,
.unk12 = 0,
.header = NULL,
},
@ -500,7 +500,7 @@ static const WindowTemplates gUnknown_80F6370 =
.pos = { 2, 3 },
.width = 6,
.height = 7,
.heightInTiles = 7,
.totalHeight = 7,
.unk12 = 0,
.header = NULL,
},
@ -509,7 +509,7 @@ static const WindowTemplates gUnknown_80F6370 =
.pos = { 10, 4 },
.width = 17,
.height = 2,
.heightInTiles = 2,
.totalHeight = 2,
.unk12 = 0,
.header = NULL,
},
@ -518,7 +518,7 @@ static const WindowTemplates gUnknown_80F6370 =
.pos = { 2, 13 },
.width = 26,
.height = 6,
.heightInTiles = 6,
.totalHeight = 6,
.unk12 = 0,
.header = NULL,
},
@ -534,7 +534,7 @@ static const WindowTemplates gUnknown_80F63D0 =
.pos = { 2, 3 },
.width = 26,
.height = 14,
.heightInTiles = 18,
.totalHeight = 18,
.unk12 = 2,
.header = NULL,
},

View File

@ -135,17 +135,17 @@ static void sub_801645C(void)
switch (sFelicityBankWork->currState) {
case 2:
sFelicityBankWork->unkA8.id[0].unk0 = 0x80;
sFelicityBankWork->unkA8.id[1].unk0 = 0x80;
sFelicityBankWork->unkA8.id[2].unk0 = 0x80;
sFelicityBankWork->unkA8.id[0].flags = WINTEMPLATE_FLAG_x80;
sFelicityBankWork->unkA8.id[1].flags = WINTEMPLATE_FLAG_x80;
sFelicityBankWork->unkA8.id[2].flags = WINTEMPLATE_FLAG_x80;
sFelicityBankWork->unkA8.id[3] = sUnknown_80DB6F4;
ResetUnusedInputStruct();
ShowWindows(&sFelicityBankWork->unkA8, TRUE, FALSE);
break;
case FELICITY_BANK_STORE_HOW_MUCH:
case FELICITY_BANK_TAKE_HOW_MUCH:
sFelicityBankWork->unkA8.id[0].unk0 = 0x80;
sFelicityBankWork->unkA8.id[1].unk0 = 0x80;
sFelicityBankWork->unkA8.id[0].flags = WINTEMPLATE_FLAG_x80;
sFelicityBankWork->unkA8.id[1].flags = WINTEMPLATE_FLAG_x80;
sFelicityBankWork->unkA8.id[3] = sUnknown_80DB6F4;
sFelicityBankWork->unkA8.id[2] = sUnknown_80DB70C;
ResetUnusedInputStruct();

View File

@ -259,7 +259,7 @@ void FriendAreasMap_PrintCurrAreaName(void)
windows.id[0].pos.y = 2;
windows.id[0].width = 21;
windows.id[0].height = 2;
windows.id[0].heightInTiles = 2;
windows.id[0].totalHeight = 2;
windows.id[1].type = WINDOW_TYPE_NORMAL;
@ -297,7 +297,7 @@ void FriendAreasMap_PrintAvailableSubAreas(void)
.pos = {7, 2},
.width = 21,
.height = 2,
.heightInTiles = 2,
.totalHeight = 2,
.header = &header,
},
[1] = WIN_TEMPLATE_DUMMY,
@ -335,7 +335,7 @@ void FriendAreasMap_PrintAvailableSubAreas(void)
menuInput->cursorArrowPos.y = 8;
ResetTouchScreenMenuInput(&menuInput->touchScreen);
var = CalcEntriesTotalHeight(menuInput->entriesPerPage, 0);
windows.id[0].heightInTiles = windows.id[0].height = var + 2;
windows.id[0].totalHeight = windows.id[0].height = var + 2;
sub_80137B0(menuInput, var * 8);
ShowWindows(&windows, TRUE, TRUE);

View File

@ -36,12 +36,12 @@ static EWRAM_INIT u16 gUnknown_203B2AA = 0;
static const WindowTemplate sDummyWinTemplate = WIN_TEMPLATE_DUMMY;
static const WindowTemplate sUnknown_80DC968 = {
.unk0 = 0,
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_WITH_HEADER,
.pos = { 2, 2 },
.width = 15,
.height = 14,
.heightInTiles = 14,
.totalHeight = 14,
.unk12 = 0,
.header = NULL
};

View File

@ -197,9 +197,9 @@ static void sub_801FDC0(void)
switch (gUnknown_203B27C->state) {
case 0x2:
gUnknown_203B27C->unk180.id[0].unk0 = 0x80;
gUnknown_203B27C->unk180.id[1].unk0 = 0x80;
gUnknown_203B27C->unk180.id[2].unk0 = 0x80;
gUnknown_203B27C->unk180.id[0].flags = WINTEMPLATE_FLAG_x80;
gUnknown_203B27C->unk180.id[1].flags = WINTEMPLATE_FLAG_x80;
gUnknown_203B27C->unk180.id[2].flags = WINTEMPLATE_FLAG_x80;
gUnknown_203B27C->unk180.id[3] = gUnknown_80DC37C;
ResetUnusedInputStruct();
ShowWindows(&gUnknown_203B27C->unk180, TRUE, FALSE);

View File

@ -26,11 +26,15 @@
#include "text_3.h"
#include "text_util.h"
#define LEGEND_ICON_W 16
#define LEGEND_ICON_H 16
#define LEGEND_ICON_4BPP_LEN (LEGEND_ICON_W * LEGEND_ICON_H / 8)
// Size: 0x8
typedef struct ClmkFileData
{
/* 0x0 */ /*const */u32 (*pics)[8 * 4];
/* 0x4 */ /*const */RGB_Struct (*palette)[16 * 4];
/* 0x0 */ /*const */u32 (*packedGFX)[LEGEND_ICON_4BPP_LEN];
/* 0x4 */ /*const */RGB_Struct (*palette)[16 * 4]; // Contains 4 palettes
} ClmkFileData;
enum
@ -71,12 +75,12 @@ extern unkStruct_203B484 *gUnknown_203B484;
const WindowTemplate gUnknown_80E75F8 = WIN_TEMPLATE_DUMMY;
const WindowTemplate gUnknown_80E7610 = {
.unk0 = 0,
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_NORMAL,
.pos = { 2, 2 },
.width = 26,
.height = 11,
.heightInTiles = 11,
.totalHeight = 11,
.unk12 = 0,
.header = NULL
};
@ -117,12 +121,12 @@ static EWRAM_INIT u32 sLegendaryQuestIDs[NUM_LEGEND_ICONS] = {
};
const WindowTemplate gUnknown_80E762C = {
.unk0 = 0,
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_NORMAL,
.pos = { 2, 15 },
.width = 19,
.height = 3,
.heightInTiles = 3,
.totalHeight = 3,
.unk12 = 0,
.header = NULL
};
@ -158,12 +162,12 @@ const MenuItem gDeleteSaveConfirmMenuItems[] = {
};
const WindowTemplate gUnknown_80E7784 = {
.unk0 = 0,
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_NORMAL,
.pos = { 23, 15 },
.width = 5,
.height = 3,
.heightInTiles = 3,
.totalHeight = 3,
.unk12 = 0,
.header = NULL
};
@ -413,9 +417,8 @@ static void DrawQuestIcons(void)
#define CLMKPAT_DATA ((ClmkFileData *)clmkFile->data)
// Load all 4 palettes
for (i = 0; i < 16 * 4; i++) {
for (i = 0; i < 16 * 4; i++)
SetBGPaletteBufferColorArray(i + 0xB0, &(*CLMKPAT_DATA->palette)[i]);
}
x = 8;
y = 73; // Shouldn't this be 72?
@ -423,7 +426,7 @@ static void DrawQuestIcons(void)
// Draw the legendary icons
for (i = 0; i < NUM_LEGEND_ICONS; i++) {
if (CheckQuest(sLegendaryQuestIDs[i])) {
sub_8007E20(0, x, y, 16, 16, CLMKPAT_DATA->pics[i], sLegendaryQuestIconPalNums[i]);
WriteGFXToBG0Window(0, x, y, LEGEND_ICON_W, LEGEND_ICON_H, CLMKPAT_DATA->packedGFX[i], sLegendaryQuestIconPalNums[i]);
x += 16;
}
}

View File

@ -237,7 +237,7 @@ void sub_8012D08(WindowTemplate *winTemplate, s32 entriesCount)
sVar3 = sVar2;
winTemplate->height = sVar3;
winTemplate->heightInTiles = sVar3;
winTemplate->totalHeight = sVar3;
}
void sub_8012D34(WindowTemplate *winTemplate, s32 entriesCount)
@ -251,7 +251,7 @@ void sub_8012D34(WindowTemplate *winTemplate, s32 entriesCount)
sVar3 = sVar2;
winTemplate->height = sVar3;
winTemplate->heightInTiles = sVar3;
winTemplate->totalHeight = sVar3;
}
// arm9.bin::0201C26C

View File

@ -283,34 +283,34 @@ static const u8 *const sSpecialLetters[] =
static const WindowTemplate sWindowTemplateDummy = WIN_TEMPLATE_DUMMY;
static const WindowTemplate sInputWindowTemplate = {
.unk0 = 0,
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_WITHOUT_BORDER,
.pos = { 1, 10 },
.width = 28,
.height = 9,
.heightInTiles = 9,
.totalHeight = 9,
.unk12 = 0,
.header = NULL,
};
static const WindowTemplate sNameWindowTemplate = {
.unk0 = 0,
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_WITHOUT_BORDER,
.pos = { 4, 3 },
.width = 22,
.height = 5,
.heightInTiles = 5,
.totalHeight = 5,
.unk12 = 0,
.header = NULL,
};
static const WindowTemplate sPasswordNameWindowTemplate = {
.unk0 = 0,
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_WITHOUT_BORDER,
.pos = { 1, 2 },
.width = 28,
.height = 7,
.heightInTiles = 7,
.totalHeight = 7,
.unk12 = 0,
.header = NULL,
};

View File

@ -611,7 +611,7 @@ void RunDungeon_Async(DungeonSetupStruct *setupPtr)
sub_803E13C();
sub_800CDA8(4);
if (gDungeon->unk6 == 0 && sub_8083C88(gDungeon->unk644.missionKind)) {
ShowDungeonClearedWindow();
ShowDungeonClearedWindow_Async();
}
if (IsUnsuccessfulDungeonExit()) {

View File

@ -32,23 +32,23 @@ static const u32 gUnknown_80D48A0[3] = { 0x7, 0x2, 0x2 };
static const WindowTemplate sWinTemplateDummy = WIN_TEMPLATE_DUMMY;
static const WindowTemplate sDialogueBoxWindowTemplate = {
.unk0 = 0,
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_0,
.pos = { 2, 15 },
.width = 26,
.height = 5,
.heightInTiles = 7,
.totalHeight = 7,
.unk12 = 0,
.header = NULL,
};
static const WindowTemplate sOnlyTextDialogueBoxWindowTemplate = {
.unk0 = 0,
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_ONLY_TEXT,
.pos = { 2, 8 },
.width = 26,
.height = 5,
.heightInTiles = 7,
.totalHeight = 7,
.unk12 = 0,
.header = NULL,
};
@ -113,22 +113,22 @@ static EWRAM_DATA TouchScreenMenuInput sDialogueMenuTouchScreenInput = {0};
static EWRAM_INIT WindowTemplates sDialogueBoxWinTemplates = {
.id = {
[0] = {
.unk0 = 0,
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_0,
.pos = { 2, 15 },
.width = 26,
.height = 5,
.heightInTiles = 7,
.totalHeight = 7,
.unk12 = 0,
.header = NULL,
},
[1] = {
.unk0 = 0x40,
.flags = WINTEMPLATE_FLAG_x40,
.type = WINDOW_TYPE_7,
.pos = { 0, 0 },
.width = 0,
.height = 0,
.heightInTiles = 0,
.totalHeight = 0,
.unk12 = 0,
.header = NULL,
},
@ -214,8 +214,8 @@ void CreateMenuDialogueBoxAndPortrait(const u8 *text, void *a1, u32 r9, const Me
sDialogueBoxWinTemplates.id[1].width = 0;
sDialogueBoxWinTemplates.id[1].height = 0;
sDialogueBoxWinTemplates.id[1].heightInTiles = 0;
sDialogueBoxWinTemplates.id[1].unk0 = 0x40;
sDialogueBoxWinTemplates.id[1].totalHeight = 0;
sDialogueBoxWinTemplates.id[1].flags = WINTEMPLATE_FLAG_x40;
if (monPortraitPtr != NULL && monPortraitPtr->faceData != NULL && monPortraitPtr->faceData->sprites[monPortraitPtr->spriteId].gfx != 0) {
s32 i;
@ -224,7 +224,7 @@ void CreateMenuDialogueBoxAndPortrait(const u8 *text, void *a1, u32 r9, const Me
sDialogueBoxWinTemplates.id[1].pos.y = monPortraitPtr->pos.y;
sDialogueBoxWinTemplates.id[1].width = 5;
sDialogueBoxWinTemplates.id[1].height = 5;
sDialogueBoxWinTemplates.id[1].heightInTiles = 5;
sDialogueBoxWinTemplates.id[1].totalHeight = 5;
for (i = 0; i < 16; i++) {
SetBGPaletteBufferColorArray(224 + i, &monPortraitPtr->faceData->sprites[monPortraitPtr->spriteId].pal[i]);
@ -244,7 +244,7 @@ void CreateMenuDialogueBoxAndPortrait(const u8 *text, void *a1, u32 r9, const Me
ShowWindows(&sDialogueBoxWinTemplates, TRUE, TRUE);
sTextPrintStruct.x = 4;
sTextPrintStruct.y = 4;
sTextPrintStruct.arrowSpritePosX = 0x70;
sTextPrintStruct.arrowSpritePosX = 112;
sTextPrintStruct.arrowSpritePosY = (gWindows[0].y * 8) + TEXTBOX_HEIGHT;
sTextPrintStruct.unk10 = 7;
sTextPrintStruct.unk1C = 0;
@ -604,12 +604,12 @@ static void sub_8014A88(void)
r1 = r7 / 8;
r1 += 2;
sDialogueBoxWinTemplates.id[2].width = r1;
sDialogueBoxWinTemplates.id[2].heightInTiles = r2;
sDialogueBoxWinTemplates.id[2].totalHeight = r2;
sDialogueBoxWinTemplates.id[2].height = r2;
sDialogueBoxWinTemplates.id[2].pos.x = 28 - r1;
sDialogueBoxWinTemplates.id[2].pos.y = 14 - r2;
sDialogueBoxWinTemplates.id[0].unk0 = 0x80;
sDialogueBoxWinTemplates.id[1].unk0 = 0xC0;
sDialogueBoxWinTemplates.id[0].flags = WINTEMPLATE_FLAG_x80;
sDialogueBoxWinTemplates.id[1].flags = WINTEMPLATE_FLAG_x40 | WINTEMPLATE_FLAG_x80;
if (sNeverWrittenToUnknownStructPtr != NULL) {
sDialogueBoxWinTemplates.id[3] = sNeverWrittenToUnknownStructPtr->unk0;
}

View File

@ -116,13 +116,13 @@ static const u32 sFadeInDungeon[8] = {0x88888888, 0x88888888, 0x88888888, 0x8888
static const u32 sUnknown_80B8804[4] = {0, 1, 2, 3};
static const u32 sUnknown_80B8814[4] = {1, 2, 3, 0};
static void AddWindow(Window *windows, u32 *vram, u32 *, u16 tilemaps[4][32][32], u32 windowId, const WindowTemplate *winTemplate, bool8, s32 firstBlockId, DungeonPos *positionModifier, u8);
static void AddWindow(Window *windows, u32 *vram, u32 *gfxPool, u16 tilemaps[4][32][32], u32 windowId, const WindowTemplate *winTemplate, bool8, s32 firstBlockId, DungeonPos *positionModifier, u8);
static void ShowWindowsInternal(const WindowTemplates *winTemplates, bool8, bool8, DungeonPos *positionModifier);
static void PutWindowTopBorderTilemap(Window *window, s32 y, u16 tilemaps[4][32][32], u8 a3);
static void PutWindowTopBorderTilemap(Window *window, s32 y, u16 tilemaps[4][32][32], bool8 a3);
static void PutWindowLeftBorderTilemap(Window *window, s32 x, s32 y, s32 a3, u16 tilemaps[4][32][32]);
static void PutWindowFillTilemap(Window *window, s32 x, s32 y, s32 a3, u16 tilemaps[4][32][32]);
static void PutWindowRightBorderTilemap(Window *window, s32 x, s32 y, s32 a3, u16 tilemaps[4][32][32]);
static void PutWindowBottomBorderTilemap(Window *window, s32, u16 tilemaps[4][32][32], u8);
static void PutWindowBottomBorderTilemap(Window *window, s32 y, u16 tilemaps[4][32][32], bool8 a3);
static void PutHeaderWindowTopBorderTilemap(Window *window, s32 y, u32 a2, const WindowHeader *winHeader, u16 tilemaps[4][32][32]);
// arm9.bin::02005448
@ -142,8 +142,8 @@ void LoadCharmaps(void)
for (k = 0; k < MAX_WINDOWS; k++) {
gWindows[k].width = 0;
gWindows[k].heightInTiles = 0;
gWindows[k].unk46 = 0;
gWindows[k].totalHeight = 0;
gWindows[k].unk46 = FALSE;
}
gCharacterSpacing = 0;
@ -252,7 +252,7 @@ void ShowWindows(const WindowTemplates *winTemplates, bool8 a1, bool8 a2)
static void ShowWindowsInternal(const WindowTemplates *winTemplates, bool8 a1, bool8 a2, DungeonPos *positionModifier)
{
s32 i;
s32 area = 2;
s32 startTileNum = 2;
if (winTemplates == NULL)
winTemplates = &sDummyWindows;
@ -265,9 +265,10 @@ static void ShowWindowsInternal(const WindowTemplates *winTemplates, bool8 a1, b
sSavedWindows.id[i] = winTemplates->id[i];
if (winTemplates->id[i].width != 0) {
AddWindow(gWindows, (u32 *)VRAM, sUnknown_20274B4, gBgTilemaps, sUnknown_80B8804[i], &winTemplates->id[i], a1, area, positionModifier, 0);
AddWindow(gWindows, (u32 *)VRAM, sWindowGFXPool, gBgTilemaps, sUnknown_80B8804[i], &winTemplates->id[i], a1, startTileNum, positionModifier, FALSE);
sub_80089AC(&winTemplates->id[i], positionModifier);
area += winTemplates->id[i].width * winTemplates->id[i].heightInTiles;
startTileNum += winTemplates->id[i].width * winTemplates->id[i].totalHeight;
}
}
@ -308,10 +309,11 @@ u32 sub_8006544(u32 index)
}
// arm9.bin::02004D54
static void AddWindow(Window *windows, u32 *vram, u32 *a2, u16 tilemaps[4][32][32], u32 windowId, const WindowTemplate *winTemplate, bool8 a6, s32 firstBlockId, DungeonPos *positionModifier, u8 a9)
static void AddWindow(Window *windows, u32 *vram, u32 *gfxPool, u16 tilemaps[4][32][32], u32 windowId, const WindowTemplate *winTemplate, bool8 a6, s32 startTileNum, DungeonPos *positionModifier, bool8 a9)
{
Window *newWindow;
s32 x, y;
s32 x;
s32 y;
s32 numI;
u32 uVar1;
@ -321,18 +323,18 @@ static void AddWindow(Window *windows, u32 *vram, u32 *a2, u16 tilemaps[4][32][3
newWindow->x = x;
newWindow->y = y;
newWindow->width = winTemplate->width;
newWindow->heightInTiles = winTemplate->heightInTiles;
newWindow->totalHeight = winTemplate->totalHeight;
newWindow->height = winTemplate->height;
newWindow->type = winTemplate->type;
newWindow->unk10 = firstBlockId;
newWindow->unk10 = startTileNum;
if (newWindow->type == WINDOW_TYPE_WITH_HEADER)
newWindow->unk14 = firstBlockId;
newWindow->unk14 = startTileNum;
else
newWindow->unk14 = firstBlockId + winTemplate->unk12 * newWindow->width;
newWindow->unk14 = startTileNum + (winTemplate->unk12 * newWindow->width);
newWindow->unk18 = &a2[newWindow->unk10 * 8];
newWindow->unk1C = &a2[newWindow->unk14 * 8];
newWindow->winGFX = &gfxPool[newWindow->unk10 * 8];
newWindow->unk1C = &gfxPool[newWindow->unk14 * 8];
newWindow->unk24 = winTemplate->unk12;
newWindow->unk28 = &vram[newWindow->unk14 * 8];
@ -341,16 +343,16 @@ static void AddWindow(Window *windows, u32 *vram, u32 *a2, u16 tilemaps[4][32][3
else
newWindow->unk2C = newWindow->width * newWindow->height * 32;
newWindow->unk30 = 0;
newWindow->unk34 = 0;
newWindow->unk30 = NULL;
newWindow->unk34 = NULL;
newWindow->unk38 = 0;
newWindow->unk20 = (newWindow->width * 8) - 8;
newWindow->unk45 = newWindow->type == WINDOW_TYPE_0;
newWindow->isWinType0 = newWindow->type == WINDOW_TYPE_0;
if (newWindow->heightInTiles == 0)
if (newWindow->totalHeight == 0)
return;
if ((winTemplate->unk0 & 0xA0) != 0x80) {
if ((winTemplate->flags & (WINTEMPLATE_FLAG_x20 | WINTEMPLATE_FLAG_x80)) != WINTEMPLATE_FLAG_x80) {
s32 workingY = y - 1;
s32 i, j;
@ -359,9 +361,9 @@ static void AddWindow(Window *windows, u32 *vram, u32 *a2, u16 tilemaps[4][32][3
PutHeaderWindowTopBorderTilemap(newWindow, workingY, uVar1, winTemplate->header, tilemaps);
workingY = y + 2;
workingY = y + WINDOW_HEADER_HEIGHT;
uVar1 = a6 ? newWindow->unk14 + newWindow->width * (winTemplate->unk12 + 2) : 0;
numI = newWindow->height - 2;
numI = newWindow->height - WINDOW_HEADER_HEIGHT;
}
else {
PutWindowTopBorderTilemap(newWindow, workingY, tilemaps, a9);
@ -390,14 +392,14 @@ static void AddWindow(Window *windows, u32 *vram, u32 *a2, u16 tilemaps[4][32][3
PutWindowBottomBorderTilemap(newWindow, workingY, tilemaps, a9);
}
if ((winTemplate->unk0 & 0x80) == 0)
if (!(winTemplate->flags & WINTEMPLATE_FLAG_x80))
PrepareTextbox_8008C6C(windows, windowId);
newWindow->unk46 = 0;
newWindow->unk46 = FALSE;
}
// arm9.bin::02004B0C
static void PutWindowTopBorderTilemap(Window *window, s32 y, u16 tilemaps[4][32][32], u8 a3)
static void PutWindowTopBorderTilemap(Window *window, s32 y, u16 tilemaps[4][32][32], bool8 a3)
{
s32 x;
s32 i;
@ -413,11 +415,12 @@ static void PutWindowTopBorderTilemap(Window *window, s32 y, u16 tilemaps[4][32]
case WINDOW_TYPE_0:
case WINDOW_TYPE_WITHOUT_BORDER:
case WINDOW_TYPE_ONLY_TEXT:
case WINDOW_TYPE_WITH_HEADER:
case WINDOW_TYPE_WITH_HEADER: {
break;
case WINDOW_TYPE_NORMAL:
}
case WINDOW_TYPE_NORMAL: {
tilemaps[0][y][x] = TILEMAP_TILE_NUM(0x2D8) | TILEMAP_PAL(15);
if (a3 != 0)
if (a3)
tilemaps[1][y][x] = TILEMAP_TILE_NUM(0x293) | TILEMAP_PAL(15);
else
tilemaps[1][y][x] = TILEMAP_TILE_NUM(0x2DB) | TILEMAP_PAL(15);
@ -429,12 +432,13 @@ static void PutWindowTopBorderTilemap(Window *window, s32 y, u16 tilemaps[4][32]
}
tilemaps[0][y][x] = TILEMAP_TILE_NUM(0x2D8) | TILEMAP_PAL(15) | TILEMAP_FLIP_HORIZONTAL(1);
if (a3 != 0)
if (a3)
tilemaps[1][y][x] = TILEMAP_TILE_NUM(0x293) | TILEMAP_PAL(15) | TILEMAP_FLIP_HORIZONTAL(1);
else
tilemaps[1][y][x] = TILEMAP_TILE_NUM(0x2DB) | TILEMAP_PAL(15);
break;
case WINDOW_TYPE_4:
}
case WINDOW_TYPE_4: {
tilemaps[0][y][x] = TILEMAP_TILE_NUM(0x2E8) | TILEMAP_PAL(15);
tilemaps[1][y][x] = TILEMAP_TILE_NUM(0x2DB) | TILEMAP_PAL(15);
x++;
@ -447,7 +451,8 @@ static void PutWindowTopBorderTilemap(Window *window, s32 y, u16 tilemaps[4][32]
tilemaps[0][y][x] = TILEMAP_TILE_NUM(0x2E8) | TILEMAP_PAL(15) | TILEMAP_FLIP_HORIZONTAL(1);
tilemaps[1][y][x] = TILEMAP_TILE_NUM(0x2DB) | TILEMAP_PAL(15);
break;
case WINDOW_TYPE_FILL_TRANSPARENT:
}
case WINDOW_TYPE_FILL_TRANSPARENT: {
tilemaps[0][y][x] = TILEMAP_TILE_NUM(0x2DC) | TILEMAP_PAL(15);
x++;
for (i = 0; i < window->width; i++) {
@ -457,7 +462,8 @@ static void PutWindowTopBorderTilemap(Window *window, s32 y, u16 tilemaps[4][32]
tilemaps[0][y][x] = TILEMAP_TILE_NUM(0x2DC) | TILEMAP_PAL(15) | TILEMAP_FLIP_HORIZONTAL(1);
break;
case WINDOW_TYPE_7:
}
case WINDOW_TYPE_7: {
tilemaps[0][y][x] = TILEMAP_TILE_NUM(0x293) | TILEMAP_PAL(15);
x++;
for (i = 0; i < window->width; i++) {
@ -467,6 +473,7 @@ static void PutWindowTopBorderTilemap(Window *window, s32 y, u16 tilemaps[4][32]
tilemaps[0][y][x] = TILEMAP_TILE_NUM(0x293) | TILEMAP_PAL(15) | TILEMAP_FLIP_HORIZONTAL(1);
break;
}
}
}
@ -583,7 +590,7 @@ static void PutWindowRightBorderTilemap(Window *window, s32 x, s32 y, s32 a3, u1
}
// arm9.bin::0200456C
static void PutWindowBottomBorderTilemap(Window *window, s32 y, u16 tilemaps[4][32][32], u8 a3)
static void PutWindowBottomBorderTilemap(Window *window, s32 y, u16 tilemaps[4][32][32], bool8 a3)
{
s32 x;
s32 i;
@ -598,12 +605,13 @@ static void PutWindowBottomBorderTilemap(Window *window, s32 y, u16 tilemaps[4][
switch (window->type) {
case WINDOW_TYPE_0:
case WINDOW_TYPE_WITHOUT_BORDER:
case WINDOW_TYPE_ONLY_TEXT:
case WINDOW_TYPE_ONLY_TEXT: {
break;
}
case WINDOW_TYPE_NORMAL:
case WINDOW_TYPE_WITH_HEADER:
case WINDOW_TYPE_WITH_HEADER: {
tilemaps[0][y][x] = TILEMAP_TILE_NUM(0x2D8) | TILEMAP_PAL(15) | TILEMAP_FLIP_VERTICAL(1);
if (a3 != 0)
if (a3)
tilemaps[1][y][x] = TILEMAP_TILE_NUM(0x293) | TILEMAP_PAL(15) | TILEMAP_FLIP_VERTICAL(1);
else
tilemaps[1][y][x] = TILEMAP_TILE_NUM(0x2DB) | TILEMAP_PAL(15);
@ -615,12 +623,13 @@ static void PutWindowBottomBorderTilemap(Window *window, s32 y, u16 tilemaps[4][
}
tilemaps[0][y][x] = TILEMAP_TILE_NUM(0x2D8) | TILEMAP_PAL(15) | TILEMAP_FLIP_VERTICAL(1) | TILEMAP_FLIP_HORIZONTAL(1);
if (a3 != 0)
if (a3)
tilemaps[1][y][x] = TILEMAP_TILE_NUM(0x293) | TILEMAP_PAL(15) | TILEMAP_FLIP_VERTICAL(1) | TILEMAP_FLIP_HORIZONTAL(1);
else
tilemaps[1][y][x] = TILEMAP_TILE_NUM(0x2DB) | TILEMAP_PAL(15);
break;
case WINDOW_TYPE_4:
}
case WINDOW_TYPE_4: {
tilemaps[0][y][x] = TILEMAP_TILE_NUM(0x2E8) | TILEMAP_PAL(15) | TILEMAP_FLIP_VERTICAL(1);
tilemaps[1][y][x] = TILEMAP_TILE_NUM(0x2DB) | TILEMAP_PAL(15);
x++;
@ -633,7 +642,8 @@ static void PutWindowBottomBorderTilemap(Window *window, s32 y, u16 tilemaps[4][
tilemaps[0][y][x] = TILEMAP_TILE_NUM(0x2E8) | TILEMAP_PAL(15) | TILEMAP_FLIP_VERTICAL(1) | TILEMAP_FLIP_HORIZONTAL(1);
tilemaps[1][y][x] = TILEMAP_TILE_NUM(0x2DB) | TILEMAP_PAL(15);
break;
case WINDOW_TYPE_FILL_TRANSPARENT:
}
case WINDOW_TYPE_FILL_TRANSPARENT: {
tilemaps[0][y][x] = TILEMAP_TILE_NUM(0x2DC) | TILEMAP_PAL(15) | TILEMAP_FLIP_VERTICAL(1);
x++;
for (i = 0; i < window->width; i++) {
@ -643,7 +653,8 @@ static void PutWindowBottomBorderTilemap(Window *window, s32 y, u16 tilemaps[4][
tilemaps[0][y][x] = TILEMAP_TILE_NUM(0x2DC) | TILEMAP_PAL(15) | TILEMAP_FLIP_VERTICAL(1) | TILEMAP_FLIP_HORIZONTAL(1);
break;
case WINDOW_TYPE_7:
}
case WINDOW_TYPE_7: {
tilemaps[0][y][x] = TILEMAP_TILE_NUM(0x293) | TILEMAP_PAL(15) | TILEMAP_FLIP_VERTICAL(1);
x++;
for (i = 0; i < window->width; i++) {
@ -653,6 +664,7 @@ static void PutWindowBottomBorderTilemap(Window *window, s32 y, u16 tilemaps[4][
tilemaps[0][y][x] = TILEMAP_TILE_NUM(0x293) | TILEMAP_PAL(15) | TILEMAP_FLIP_VERTICAL(1) | TILEMAP_FLIP_HORIZONTAL(1);
break;
}
}
}
@ -825,9 +837,9 @@ void sub_80073B8(s32 windowId)
{
Window *window = &gWindows[windowId];
window->unk3C = &window->unk1C[(u32)window->unk2C >> 2];
window->unk3C = &window->unk1C[(u32)window->unk2C / 4];
window->unk40 = window->unk1C;
window->unk46 = 1;
window->unk46 = TRUE;
}
// arm9.bin::02003E9C
@ -841,7 +853,7 @@ void sub_80073E0(s32 windowId)
{
Window *window = &gWindows[windowId];
if (window->unk44 == 0) {
if (!window->unk44) {
window->unk30 = &window->unk28[window->unk3C - window->unk1C];
window->unk34 = window->unk3C;
window->unk38 = (window->unk40 - window->unk3C + 1) * 4;
@ -853,7 +865,7 @@ void sub_80073E0(s32 windowId)
window->unk38 = 0;
}
window->unk46 = 0;
window->unk46 = FALSE;
}
// arm9.bin::02003D74

View File

@ -8,13 +8,13 @@
static void AddUnderScoreHighlightInternal(Window *windows, u32 windowId, s32 x, s32 y, s32 width, u32 color);
static void DisplayMonPortrait(Window *windows, u16 dst[32][32], s32 winID, const u8 *compressedData, u32 palNum);
static void DisplayMonPortraitFlipped(Window *windows, s32 winID, const u8 *compressedData, s32 palNum);
static u32 FlipPixelsHorizontally(u32 a0);
static u32 FlipPixelsHorizontally(u32 gfx);
static s32 HexDigitValue(u8 chr);
static void nullsub_129(u32 windowId, s32 x, s32 y, s32 width, u32 color);
static void sub_8007AA4(Window *windows, u32 windowId, s32 x, s32 y, s32 a4, u32 color);
static void sub_8007BA8(Window *windows, u32 windowId, s32 x, s32 y, s32 a4, s32 color);
static void sub_8007D00(Window *windows, u32 windowId, s32 x, s32 y, s32 a4, s32 color);
static void sub_8007E64(Window *windows, u16 dst[32][32], u32 winID, s32 x, s32 y, s32 w, s32 h, u32 *src, u32 palNum);
static void WriteGFXToWindow(Window *windows, u16 dst[32][32], u32 winID, s32 x, s32 y, s32 w, s32 h, u32 *src, u32 palNum);
static void sub_8008030(Window *a0, u16 a1[32][32], u32 a2, s32 a3, s32 a4, s32 a5, s32 a6, u32 *a7, u32 a8);
static void sub_8008334(u32 *r7, u32 *r12);
static void sub_80084A4(Window *a0, u16 a1[32][32], u32 a2, s32 a3, s32 a4, s32 a5, s32 a6, u32 a8);
@ -72,13 +72,13 @@ u32 DrawCharOnWindowInternal(Window *windows, s32 x, s32 y, u32 chr, u32 color,
}
if (sp0->unkA & 1) {
r3 = window->unk18 + ((((y / 8) * window->width) + (x / 8)) * 8);
r3 = window->winGFX + ((((y / 8) * window->width) + (x / 8)) * 8);
r3 += y % 8;
shiftData = &gCharMasksOffsets[x % 8];
xDiv8 = x / 8;
yDiv8 = y / 8;
if (yDiv8 < window->heightInTiles) {
if (yDiv8 < window->totalHeight) {
for (i = 0; i < gCharHeight[gCurrentCharmap]; i++) {
r2 = (local_44[1] << 0x10) | (local_44[0]);
if (r2 != 0) {
@ -123,7 +123,7 @@ u32 DrawCharOnWindowInternal(Window *windows, s32 x, s32 y, u32 chr, u32 color,
if (y % 8 == 0) {
r3 += window->unk20;
yDiv8++;
if (yDiv8 >= window->heightInTiles)
if (yDiv8 >= window->totalHeight)
break;
}
}
@ -133,13 +133,13 @@ u32 DrawCharOnWindowInternal(Window *windows, s32 x, s32 y, u32 chr, u32 color,
bool8 notFirstIteration = FALSE;
u32 r1;
r3 = window->unk18 + ((((y / 8) * window->width) + (x / 8)) * 8);
r3 = window->winGFX + ((((y / 8) * window->width) + (x / 8)) * 8);
r3 += y - (y / 8 * 8);
shiftData = &gCharMasksOffsets[x - ((x / 8) * 8)];
xDiv8 = x / 8;
yDiv8 = y / 8;
if (yDiv8 < window->heightInTiles) {
if (yDiv8 < window->totalHeight) {
for (i = 0; i < gCharHeight[gCurrentCharmap]; i++) {
r4 = (local_44[1] << 0x10) | (local_44[0]);
r2 = (0x11111111 & r4) + (sp18 & r4);
@ -216,7 +216,7 @@ u32 DrawCharOnWindowInternal(Window *windows, s32 x, s32 y, u32 chr, u32 color,
if (y % 8 == 0) {
r3 += window->unk20;
yDiv8++;
if (yDiv8 >= window->heightInTiles)
if (yDiv8 >= window->totalHeight)
break;
}
}
@ -263,11 +263,11 @@ static void AddUnderScoreHighlightInternal(Window *windows, u32 windowId, s32 x,
r4 = y / 8;
dest = window->unk18 + (((window->width * r4) + (x / 8)) * 8);
dest = window->winGFX + (((window->width * r4) + (x / 8)) * 8);
dest += (r4 * -8) + y;
r6 = x / 8;
if (y / 8 >= window->heightInTiles) {
if (y / 8 >= window->totalHeight) {
return;
}
else {
@ -324,7 +324,7 @@ static void sub_8007AA4(Window *windows, u32 windowId, s32 x, s32 y, s32 a4, u32
u32 ip = gUnknown_80B853C[color & 0xF] + 0x11111111;
const u32 unkBits[] = {0xF, 0xF0, 0xF00, 0xF000, 0xF0000, 0xF00000, 0xF000000, 0xF0000000};
s32 r3 = y / 8;
u32 *dest = window->unk18 + ((window->width * r3 + x / 8) * 8);
u32 *dest = window->winGFX + ((window->width * r3 + x / 8) * 8);
s32 r2 = x / 8;
dest += r3 * -8 + y;
@ -343,7 +343,7 @@ static void sub_8007AA4(Window *windows, u32 windowId, s32 x, s32 y, s32 a4, u32
LOOP_MIDDLE:
if (a4 <= 0)
return;
if (r3 >= window->heightInTiles)
if (r3 >= window->totalHeight)
return;
dest[0] |= ip;
@ -374,10 +374,10 @@ static void sub_8007BA8(Window *windows, u32 windowId, s32 x, s32 y, s32 a4, s32
Window *window = &windows[windowId];
yDiv8 = y / 8;
if (yDiv8 >= window->heightInTiles)
if (yDiv8 >= window->totalHeight)
return;
dst = window->unk18 + (((yDiv8 * window->width) + x / 8) * 8);
dst = window->winGFX + (((yDiv8 * window->width) + x / 8) * 8);
dst += y - (yDiv8 * 8);
for (i = 0; i < color; i++) {
@ -418,7 +418,7 @@ static void sub_8007BA8(Window *windows, u32 windowId, s32 x, s32 y, s32 a4, s32
if ((y % 8) == 0) {
dst += window->unk20;
yDiv8++;
if (yDiv8 >= window->heightInTiles)
if (yDiv8 >= window->totalHeight)
return;
}
}
@ -443,10 +443,10 @@ static void sub_8007D00(Window *windows, u32 windowId, s32 x, s32 y, s32 a4, s32
Window *window = &windows[windowId];
yDiv8 = y / 8;
if (yDiv8 >= window->heightInTiles)
if (yDiv8 >= window->totalHeight)
return;
dst = window->unk18 + (((yDiv8 * window->width) + x / 8) * 8);
dst = window->winGFX + (((yDiv8 * window->width) + x / 8) * 8);
dst += y - (yDiv8 * 8);
for (i = 0; i < color; i++) {
@ -487,94 +487,102 @@ static void sub_8007D00(Window *windows, u32 windowId, s32 x, s32 y, s32 a4, s32
if ((y % 8) == 0) {
dst += window->unk20;
yDiv8++;
if (yDiv8 >= window->heightInTiles)
if (yDiv8 >= window->totalHeight)
return;
}
}
}
void sub_8007E20(u32 winID, u32 x, u32 y, u32 w, u32 h, u32* src, u32 palNum)
void WriteGFXToBG0Window(u32 winID, u32 x, u32 y, u32 w, u32 h, u32* srcGFX, u32 palNum)
{
sub_8007E64(gWindows, gBgTilemaps[0], winID, x, y, w, h, src, palNum);
WriteGFXToWindow(gWindows, gBgTilemaps[0], winID, x, y, w, h, srcGFX, palNum);
}
UNUSED static void nullsub_160(void)
{
}
static void sub_8007E64(Window *windows, u16 dst[32][32], u32 winID, s32 x, s32 y, s32 w, s32 h, u32* src, u32 palNum)
// srcGFX: Each u32 is 8 packed pixels, 4 bits per pixel.
static void WriteGFXToWindow(Window *windows, u16 dst[32][32], u32 winID, s32 x, s32 y, s32 w, s32 h, u32* srcGFX, u32 palNum)
{
s32 iterY;
s32 iterX;
s32 baseNum;
u32 *dstGFX;
s32 curX;
u32 *curDstGFX;
Window *win = &windows[winID];
x /= 8;
y /= 8;
w /= 8;
h /= 8;
x /= 8; // pixelX to tileX
y /= 8; // pixelY to tileY
w /= 8; // pixelW to tileW
h /= 8; // pixelH to tileH
palNum <<= 12; // Pal shift
if (y < win->heightInTiles) {
s32 id = (win->width * y) + x;
u32 *unk18Ptr = &win->unk18[id * 8];
if (y >= win->totalHeight)
return;
for (iterY = 0; iterY < h; iterY++) {
s32 curX = x;
u32 *loopUnk18Ptr = unk18Ptr;
baseNum = (win->width * y) + x;
dstGFX = &win->winGFX[baseNum * 8];
for (iterX = 0; iterX < w; iterX++) {
if (curX < win->width) {
if (win->unk3C > loopUnk18Ptr)
win->unk3C = loopUnk18Ptr;
for (iterY = 0; iterY < h; iterY++) {
curX = x;
curDstGFX = dstGFX;
*(loopUnk18Ptr++) = *(src++);
*(loopUnk18Ptr++) = *(src++);
*(loopUnk18Ptr++) = *(src++);
*(loopUnk18Ptr++) = *(src++);
*(loopUnk18Ptr++) = *(src++);
*(loopUnk18Ptr++) = *(src++);
*(loopUnk18Ptr++) = *(src++);
*(loopUnk18Ptr++) = *src;
for (iterX = 0; iterX < w; iterX++) {
if (curX < win->width) {
if (win->unk3C > curDstGFX)
win->unk3C = curDstGFX;
if (win->unk40 < loopUnk18Ptr)
win->unk40 = loopUnk18Ptr;
*(curDstGFX++) = *(srcGFX++);
*(curDstGFX++) = *(srcGFX++);
*(curDstGFX++) = *(srcGFX++);
*(curDstGFX++) = *(srcGFX++);
*(curDstGFX++) = *(srcGFX++);
*(curDstGFX++) = *(srcGFX++);
*(curDstGFX++) = *(srcGFX++);
*(curDstGFX++) = *srcGFX;
src++;
dst[win->y + y][win->x + curX] &= 0xFFF;
dst[win->y + y][win->x + curX] |= palNum;
}
else {
loopUnk18Ptr += 8;
src += 8;
}
if (win->unk40 < curDstGFX)
win->unk40 = curDstGFX;
curX++;
srcGFX++;
dst[win->y + y][win->x + curX] &= 0xFFF;
dst[win->y + y][win->x + curX] |= palNum;
}
else {
curDstGFX += 8;
srcGFX += 8;
}
y++;
unk18Ptr += win->unk20;
unk18Ptr += 8;
if (y >= win->heightInTiles)
break;
curX++;
}
y++;
dstGFX += win->unk20;
dstGFX += 8;
if (y >= win->totalHeight)
break;
}
}
static u32 FlipPixelsHorizontally(u32 a0)
// Flips all 8 pixels (4bpp)
static u32 FlipPixelsHorizontally(u32 gfx)
{
u32 r0;
u32 ret;
r0 = (a0 >> 28) & 0xF;
r0 |= (a0 >> 20) & 0xF0;
r0 |= (a0 >> 12) & 0xF00;
r0 |= (a0 >> 4) & 0xF000;
r0 |= (a0 << 4) & 0xF0000;
r0 |= (a0 << 12) & 0xF00000;
r0 |= (a0 << 20) & 0xF000000;
r0 |= (a0 << 28) & 0xF0000000;
ret = (gfx >> 28) & 0x0000000F;
ret |= (gfx >> 20) & 0x000000F0;
ret |= (gfx >> 12) & 0x00000F00;
ret |= (gfx >> 04) & 0x0000F000;
ret |= (gfx << 04) & 0x000F0000;
ret |= (gfx << 12) & 0x00F00000;
ret |= (gfx << 20) & 0x0F000000;
ret |= (gfx << 28) & 0xF0000000;
return r0;
return ret;
}
UNUSED static void sub_8007FEC(u32 a0, u32 a1, u32 a2, u32 a3, u32 a4, u32 *a5, u32 a6)
@ -586,7 +594,7 @@ UNUSED static void nullsub_161(void)
{
}
// Similar to sub_8007E64
// Similar to WriteGFXToWindow
static void sub_8008030(Window *a0, u16 a1[32][32], u32 a2, s32 a3, s32 a4, s32 a5, s32 a6, u32 *a7, u32 a8)
{
s32 i, j;
@ -598,8 +606,8 @@ static void sub_8008030(Window *a0, u16 a1[32][32], u32 a2, s32 a3, s32 a4, s32
a6 /= 8;
a8 <<= 12; // Pal shift
if (a4 < window->heightInTiles) {
u32 *unk18Ptr = &window->unk18[((window->width * a4) + (a3 + a5)) * 8];
if (a4 < window->totalHeight) {
u32 *unk18Ptr = &window->winGFX[((window->width * a4) + (a3 + a5)) * 8];
for (i = 0; i < a6; i++) {
s32 xMaybe = a3 + a5;
u32 *loopUnk18Ptr = unk18Ptr;
@ -631,13 +639,13 @@ static void sub_8008030(Window *a0, u16 a1[32][32], u32 a2, s32 a3, s32 a4, s32
a4++;
unk18Ptr += window->unk20;
unk18Ptr += 8;
if (a4 >= window->heightInTiles)
if (a4 >= window->totalHeight)
break;
}
}
}
// Similar to sub_8007E64
// Similar to WriteGFXToWindow
UNUSED static void sub_80081A4(s32 a0, s32 a3, s32 a4, s32 a7Id)
{
s32 i, j, a5, a6;
@ -649,7 +657,7 @@ UNUSED static void sub_80081A4(s32 a0, s32 a3, s32 a4, s32 a7Id)
a5 = 2;
a6 = 2;
if (a4 < window->heightInTiles) {
if (a4 < window->totalHeight) {
s32 id = (window->width * a4) + a3;
u32 *unk18Ptr = &window->unk28[id * 8];
@ -678,7 +686,7 @@ UNUSED static void sub_80081A4(s32 a0, s32 a3, s32 a4, s32 a7Id)
unk18Ptr += window->unk20;
unk18Ptr += 8;
if (a4 >= window->heightInTiles)
if (a4 >= window->totalHeight)
break;
}
}
@ -701,9 +709,9 @@ static void DisplayMonPortrait(Window *windows, u16 dst[32][32], s32 winID, cons
palNum <<= 12; // Pal shift
DecompressAT((u8 *)window->unk18, (window->width * 32) * window->heightInTiles, compressedData);
DecompressAT((u8 *)window->winGFX, (window->width * 32) * window->totalHeight, compressedData);
for (iterY = 0; iterY < window->heightInTiles; iterY++) {
for (iterY = 0; iterY < window->totalHeight; iterY++) {
for (iterX = 0; iterX < window->width; iterX++) {
dst[window->y + iterY][window->x + iterX] &= 0xFFF;
dst[window->y + iterY][window->x + iterX] |= palNum;
@ -713,7 +721,7 @@ static void DisplayMonPortrait(Window *windows, u16 dst[32][32], s32 winID, cons
window->unk30 = window->unk28;
window->unk34 = window->unk1C;
window->unk38 = window->unk2C;
window->unk44 = 1;
window->unk44 = TRUE;
}
static void sub_8008334(u32 *r7, u32 *r12)
@ -757,7 +765,7 @@ static void DisplayMonPortraitFlipped(Window *windows, s32 winID, const u8 *comp
DisplayMonPortraitSprite(winID, compressedData, palNum);
for (iterY = 0; iterY < window->heightInTiles; iterY++) {
for (iterY = 0; iterY < window->totalHeight; iterY++) {
s32 r8 = window->width / 2;
if (window->width & 1)
@ -768,9 +776,9 @@ static void DisplayMonPortraitFlipped(Window *windows, s32 winID, const u8 *comp
u32 *r5;
s32 baseVal = window->width * iterY;
r4 = &window->unk18[(baseVal + iterX) * 8];
r4 = &window->winGFX[(baseVal + iterX) * 8];
baseVal--;
r5 = &window->unk18[(baseVal + (window->width - iterX)) * 8];
r5 = &window->winGFX[(baseVal + (window->width - iterX)) * 8];
sub_8008334(r4++, r5++);
sub_8008334(r4++, r5++);
@ -805,7 +813,7 @@ static void sub_80084A4(Window *a0, u16 a1[32][32], u32 a2, s32 a3, s32 a4, s32
a6 /= 8;
a8 <<= 12; // Pal shift
if (a4 < window->heightInTiles) {
if (a4 < window->totalHeight) {
for (i = 0; i < a6; i++) {
s32 xMaybe = a3;
for (j = 0; j < a5; j++) {
@ -817,7 +825,7 @@ static void sub_80084A4(Window *a0, u16 a1[32][32], u32 a2, s32 a3, s32 a4, s32
}
a4++;
if (a4 >= window->heightInTiles)
if (a4 >= window->totalHeight)
break;
}
}
@ -944,14 +952,14 @@ UNUSED static void sub_80086C8(Window *windows, s32 windowId, s32 a2, s32 a3, s3
if (a4 + a2 > window->width * 8) {
a4 = (window->width * 8) - a2;
}
if (a3 + a5 > window->heightInTiles * 8) {
a5 = (window->heightInTiles * 8) - a3;
if (a3 + a5 > window->totalHeight * 8) {
a5 = (window->totalHeight * 8) - a3;
}
r2 = window->width * (a3 / 8);
r0 = 8 * (r2 + (a2 / 8));
r1 = a3 - ((a3 / 8) * 8);
r5 = &window->unk18[r0 + r1];
r5 = &window->winGFX[r0 + r1];
while (a5 > 0) {
u32 *loopPtr;
s32 r4, r6;
@ -1011,7 +1019,7 @@ static void sub_8008818(Window *windows, s32 windowId, s32 a2, s32 a3, s32 a4, s
s32 a3Div = a3 / 8;
for (i = 0; i < a5; i += 8) {
u32 *ptr = &window->unk18[((window->width * a3Div) + a2Div) * 8];
u32 *ptr = &window->winGFX[((window->width * a3Div) + a2Div) * 8];
for (j = 0; j < a4; j += 8) {
if (window->unk3C > ptr) {
window->unk3C = ptr;
@ -1059,13 +1067,13 @@ static bool8 xxx_update_bg_vram(Window *windows)
if (r5 == 0)
continue;
if (window->unk45) {
if (window->isWinType0) {
u32 *r2, *r1;
CpuCopy(window->unk28, window->unk18, 0xD00);
// The reason for void casts is because we want to add 0xD00/r5 directly to pointers. Because pointers are u32, without the casts, it would multiply the value by 4.
r2 = (void *)(window->unk18) + 0xD00;
r1 = (void *)(window->unk28) + 0xD00;
CpuCopy(window->unk28, window->winGFX, 0xD00);
// The reason for the casts is because we want to add 0xD00/r5 directly to pointers. Because pointers are u32, without the casts, it would multiply the value by 4.
r2 = (u32 *)(((u8 *)window->winGFX) + 0xD00);
r1 = (u32 *)(((u8 *)window->unk28) + 0xD00);
for (j = 0; j < window->width; j++) {
*(r1++) = *(r2++);
*(r1++) = *(r2++);
@ -1081,14 +1089,14 @@ static bool8 xxx_update_bg_vram(Window *windows)
}
else {
CpuCopy(window->unk30, window->unk34, r5);
window->unk34 += (r5 / 4);
window->unk30 = (void *)(window->unk30) + r5;
window->unk34 += (r5 / sizeof(u32));
window->unk30 = (u32 *)(((u8 *)window->unk30) + r5); // Same as `window->unk30 += (r5 / sizeof(u32));`
window->unk38 -= r5;
}
if (window->unk38 == 0) {
window->unk44 = 0;
}
if (window->unk38 == 0)
window->unk44 = FALSE;
ret = TRUE;
}
@ -1108,7 +1116,7 @@ void sub_80089AC(const WindowTemplate *r4, DungeonPos *r5_Str)
{
u8 *r6;
if (r4->unk0 & 0x40)
if (r4->flags & WINTEMPLATE_FLAG_x40)
return;
r6 = (u8*) gUnknown_3000E94;
@ -1275,15 +1283,15 @@ void PrepareTextbox_8008C6C(Window *windows, u32 windowId)
s32 i;
Window *window = &windows[windowId];
if (!window->unk45) {
s32 count = (window->width * window->heightInTiles) * 32;
if (!window->isWinType0) {
s32 count = (window->width * window->totalHeight) * 32;
for (i = 0; i < count; i += 32) {
CpuClear(&window->unk18[i / 4u], 32);
CpuClear(&window->winGFX[i / 4u], 32);
}
}
else {
s32 count = (window->width * (window->heightInTiles - 1)) * 32;
u32 *ptr = window->unk18;
s32 count = (window->width * (window->totalHeight - 1)) * 32;
u32 *ptr = window->winGFX;
for (i = 0; i < window->width; i++) {
*(ptr++) = 0xFFFFFFFF;
*(ptr++) = 0xEEEEEEEE;
@ -1301,14 +1309,14 @@ void PrepareTextbox_8008C6C(Window *windows, u32 windowId)
}
if (window->type == WINDOW_TYPE_WITH_HEADER) {
window->unk46 = 1;
window->unk46 = TRUE;
AddUnderScoreHighlightInternal(windows, windowId, 0, 10, window->width * 8, 14);
AddUnderScoreHighlightInternal(windows, windowId, 0, 11, window->width * 8, 13);
window->unk46 = 0;
window->unk46 = FALSE;
}
window->unk30 = window->unk28;
window->unk34 = window->unk1C;
window->unk38 = window->unk2C;
window->unk44 = 1;
window->unk44 = TRUE;
}

View File

@ -19,7 +19,7 @@ IWRAM_INIT static void ScrollDownWindowInternal(Window *windows, s32 windowId)
{
Window *window = &windows[windowId];
if (window->heightInTiles > 0) {
if (window->totalHeight > 0) {
s32 i, j;
u32 *dstPtr;
s32 n;
@ -29,12 +29,12 @@ IWRAM_INIT static void ScrollDownWindowInternal(Window *windows, s32 windowId)
s32 unk4 = window->width;
s32 dstAdd = ((window->unk24 + 2) * 8);
dstAdd *= unk4;
dstPtr = window->unk18 + dstAdd;
n = window->heightInTiles - 2;
dstPtr = window->winGFX + dstAdd;
n = window->totalHeight - WINDOW_HEADER_HEIGHT;
}
else {
dstPtr = window->unk18;
n = window->heightInTiles;
dstPtr = window->winGFX;
n = window->totalHeight;
}
id8 = window->unk20 + 8;
@ -69,7 +69,7 @@ IWRAM_INIT static void ScrollDownWindowInternal(Window *windows, s32 windowId)
window->unk30 = window->unk28;
window->unk34 = window->unk1C;
window->unk38 = window->unk2C;
window->unk44 = 1;
window->unk44 = TRUE;
}
}
@ -82,7 +82,7 @@ IWRAM_INIT static void ScrollUpWindowInternal(Window *windows, s32 windowId)
{
Window *window = &windows[windowId];
if (window->heightInTiles > 0) {
if (window->totalHeight > 0) {
s32 i;
s32 j;
u32 *dstPtr;
@ -93,16 +93,16 @@ IWRAM_INIT static void ScrollUpWindowInternal(Window *windows, s32 windowId)
s32 dstAdd;
if (window->type == WINDOW_TYPE_WITH_HEADER) {
n = window->heightInTiles - 2;
n = window->totalHeight - WINDOW_HEADER_HEIGHT;
}
else {
n = window->heightInTiles;
n = window->totalHeight;
}
unk8 = window->heightInTiles - 1;
unk8 = window->totalHeight - 1;
unk4 = window->width;
dstAdd = (unk8 * unk4) * 8;
dstPtr = window->unk18 + dstAdd;
dstPtr = window->winGFX + dstAdd;
id8 = window->unk20 + 8;
for (i = 0; i < window->width; i++) {
@ -151,7 +151,7 @@ IWRAM_INIT static void ScrollUpWindowInternal(Window *windows, s32 windowId)
window->unk30 = window->unk28;
window->unk34 = window->unk1C;
window->unk38 = window->unk2C;
window->unk44 = 1;
window->unk44 = TRUE;
}
}
@ -164,7 +164,7 @@ IWRAM_INIT static void sub_82729B8(Window *windows, s32 id)
{
s32 i, j;
Window *window = &windows[id];
u32 *dstPtr = window->unk18;
u32 *dstPtr = window->winGFX;
s32 id8 = window->unk20 + 8;
s32 id9 = window->unk20 + 9;
@ -206,7 +206,7 @@ IWRAM_INIT static void sub_82729B8(Window *windows, s32 id)
window->unk30 = window->unk28;
window->unk34 = window->unk1C;
window->unk38 = window->unk2C;
window->unk44 = 1;
window->unk44 = TRUE;
}
IWRAM_INIT void sub_8272A78(s32 id)
@ -218,7 +218,7 @@ IWRAM_INIT static void sub_8272A8C(Window *windows, s32 id)
{
s32 i, j;
Window *window = &windows[id];
u32 *dstPtr = window->unk18;
u32 *dstPtr = window->winGFX;
s32 id8 = window->unk20 + 8;
for (i = 0; i < window->width; i++) {
@ -259,7 +259,7 @@ IWRAM_INIT static void sub_8272A8C(Window *windows, s32 id)
window->unk30 = window->unk28;
window->unk34 = window->unk1C;
window->unk38 = window->unk2C;
window->unk44 = 1;
window->unk44 = TRUE;
}
#ifndef NONMATCHING

View File

@ -30,22 +30,22 @@ static EWRAM_INIT struct WorldMap *sWorldMapPtr = NULL;
static EWRAM_INIT WindowTemplates sWorldMapWindows = {
.id = {
[0] = {
.unk0 = 0,
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_NORMAL,
.pos = { 2, 10 },
.width = 26,
.height = 9,
.heightInTiles = 9,
.totalHeight = 9,
.unk12 = 0,
.header = NULL,
},
[1] = {
.unk0 = 0,
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_NORMAL,
.pos = { 23, 6 },
.width = 5,
.height = 3,
.heightInTiles = 3,
.totalHeight = 3,
.unk12 = 0,
.header = NULL,
},
@ -484,12 +484,12 @@ static void PrintDungeonName(DungeonLocation *dungLocation)
WindowTemplates windows = {
.id = {
[0] = {
.unk0 = 0,
.flags = WINTEMPLATE_FLAG_NONE,
.type = WINDOW_TYPE_NORMAL,
.pos = { 12, 2 },
.width = 16,
.height = 2,
.heightInTiles = 2,
.totalHeight = 2,
.unk12 = 0,
.header = NULL,
},
@ -542,7 +542,7 @@ static bool8 PlayerEnterDungeonPrompt_Async(u8 *str)
height /= 8;
sWorldMapWindows.id[0].pos.y = 19 - height;
sWorldMapWindows.id[0].heightInTiles = height;
sWorldMapWindows.id[0].totalHeight = height;
sWorldMapWindows.id[0].height = height;
sWorldMapWindows.id[1].pos.y = 14 - height;
ShowWindows(&sWorldMapWindows, TRUE, TRUE);