diff --git a/include/window.h b/include/window.h index 3c463a4c..71d41c2a 100644 --- a/include/window.h +++ b/include/window.h @@ -20,19 +20,91 @@ typedef struct { #include "util.h" -struct Window { - u8 PAD[4]; - u8 field_0x4; - u8 field_0x5; - u8 width; - u8 field_0x7; - u8 field_0x8; - u8 field_0x9[3]; - void *field_0xC; - u8 field_0x10[0xD0]; -}; +typedef struct { + s32 x; + s32 y; +} Point; -extern struct Window WINDOW_LIST[]; +typedef struct { + u32 state; + u8 is_dirty; + u8 padding_05[3]; + Point base_pos; + Point alt_pos; + u8 unk18; + u8 unk19; + u16 padding_1A; + Point extra_pos; +} CursorParams; + +typedef struct { + u32 unk00; + u8 x; + u8 y; + u8 width; + u8 height; + volatile u8 bg_id; + s8 unk09; + u16 unk0A; + u32 unk0C; +} WindowTemplate; + +typedef struct { + u16 unk00; + u16 unk02; + u16 unk04; + u16 unk06; + u8 padding_08[0x0C]; + u16 unk14; + u16 unk16; + u16 unk18; + u16 unk1A; + u16 unk1C; + u16 padding_1E; + u32 unk20; + u32 unk24; + u16 padding_28; + u16 unk2A; + u8 unk2C; + u8 unk2D; + u8 unk2E; + u8 unk2F; + u8 padding_30[0x0C]; + u8 unk3C; + u8 padding_3D; + u8 unk3E; + u8 padding_3F; +} WindowBlock; + +typedef struct { + u8 pixels[8][8]; +} WindowTile; + +typedef struct Window { + WindowTemplate template; + s8 id; + u8 unk11; + u16 base_tile; + WindowTile *pixel_buffer; + u8 *vram_base; + u32 transfer_length; + u32 row_stride; + WindowTile *active_transfer_src; + u8 *active_vram_dest; + u32 active_transfer_len; + u16 unk30; + u16 unk32; + WindowBlock render_elem_1; + WindowBlock render_elem_2; + u8 unkB4; + s8 next_window_id; + s8 is_active; + u8 unkB7; + u32 unkB8; + CursorParams cursor_params; +} Window; + +extern Window WINDOW_LIST[20]; struct Window *GetWindow(s32 window_id); void *GetWindowContents(s32 window_id); diff --git a/src/main_02028284.c b/src/main_02028284.c index 9b83bcb8..d859c16e 100644 --- a/src/main_02028284.c +++ b/src/main_02028284.c @@ -3,13 +3,13 @@ void GetWindowRectangle(s32 window_id, struct unk_02028284* out) { - struct Window *w = &WINDOW_LIST[window_id]; - s32 top = w->field_0x5 << 3; + WindowTemplate *tmpl = &WINDOW_LIST[window_id].template; + s32 top = tmpl->y << 3; s32 left; out->field_0x0 = top; - out->field_0x4 = top + (w->field_0x7 << 3); - left = w->field_0x4 << 3; + out->field_0x4 = top + (tmpl->height << 3); + left = tmpl->x << 3; out->field_0x8 = left; - out->field_0xC = left + (w->width << 3); + out->field_0xC = left + (tmpl->width << 3); } diff --git a/src/main_0202833C.c b/src/main_0202833C.c index a2ffbd6c..acd9c378 100644 --- a/src/main_0202833C.c +++ b/src/main_0202833C.c @@ -3,7 +3,7 @@ void* GetWindowContents(s32 window_id) { - struct Window *w = &WINDOW_LIST[window_id]; + WindowTemplate *tmpl = &WINDOW_LIST[window_id].template; - return w->field_0xC; + return (void *)tmpl->unk0C; } diff --git a/src/overlay_31_02382820.c b/src/overlay_31_02382820.c index 3fae466e..2e5172a7 100644 --- a/src/overlay_31_02382820.c +++ b/src/overlay_31_02382820.c @@ -151,7 +151,7 @@ void DungeonMenuSwitch(s32 window_id) PreprocessString(str_buff, 0x400, DUNGEON_MENU_SWITCH_STR1, 0, &str_values); struct Window* window2 = GetWindow(window_id); s32 text_width = sub_020265A8(str_buff); - s32 x_offset = (window2->width * 8 - text_width) / 2; + s32 x_offset = (window2->template.width * 8 - text_width) / 2; DrawTextInWindow(window_id, x_offset, 2, str_buff); UpdateWindow(window_id); }