summaryrefslogtreecommitdiff
path: root/src/text_window.c
diff options
context:
space:
mode:
authorDizzyEggg <jajkodizzy@wp.pl>2017-09-01 19:01:58 +0200
committerDizzyEggg <jajkodizzy@wp.pl>2017-09-01 19:01:58 +0200
commit6987dd9a210fd0b3b29163c1a51cc9671a65ac2f (patch)
tree405eb44388ee37d1eeb855c5ef66bda3fa90b412 /src/text_window.c
parent1d2be3c5e81f575276283ea24ac5432b9de2b3ad (diff)
decompile text window
Diffstat (limited to 'src/text_window.c')
-rw-r--r--src/text_window.c133
1 files changed, 133 insertions, 0 deletions
diff --git a/src/text_window.c b/src/text_window.c
new file mode 100644
index 000000000..356e1f339
--- /dev/null
+++ b/src/text_window.c
@@ -0,0 +1,133 @@
+#include "global.h"
+#include "text.h"
+#include "window.h"
+#include "palette.h"
+
+extern u8 LoadBgTiles(u8 bg, const void *src, u16 size, u16 destOffset);
+extern void FillBgTilemapBufferRect(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height, u8 palette);
+
+struct TilesPal
+{
+ u32* tiles;
+ u16* pal;
+};
+
+extern const struct TilesPal gUnknown_0851021C[];
+extern const u32 gUnknown_08DDD748[];
+extern const u16 gUnknown_0851017C[];
+extern const u16 gUnknown_08DDD728[];
+
+const u16* sub_8098C64(void);
+void sub_809882C(u8 windowId, u16 destOffset, u8 palOffset);
+
+const struct TilesPal* sub_8098758(u8 id)
+{
+ if (id > 19)
+ return &gUnknown_0851021C[0];
+ else
+ return &gUnknown_0851021C[id];
+}
+
+void copy_textbox_border_tile_patterns_to_vram(u8 windowId, u16 destOffset, u8 palOffset)
+{
+ LoadBgTiles(GetWindowAttribute(windowId, WINDOW_PRIORITY), gUnknown_08DDD748, 0x1C0, destOffset);
+ LoadPalette(sub_8098C64(), palOffset, 0x20);
+}
+
+void box_border_load_tiles_and_pal(u8 windowId, u16 destOffset, u8 palOffset)
+{
+ sub_809882C(windowId, destOffset, palOffset);
+}
+
+void sub_80987D4(u8 windowId, u8 frameId, u16 destOffset, u8 palOffset)
+{
+ LoadBgTiles(GetWindowAttribute(windowId, WINDOW_PRIORITY), gUnknown_0851021C[frameId].tiles, 0x120, destOffset);
+ LoadPalette(gUnknown_0851021C[frameId].pal, palOffset, 0x20);
+}
+
+void sub_809882C(u8 windowId, u16 destOffset, u8 palOffset)
+{
+ sub_80987D4(windowId, gSaveBlock2Ptr->optionsWindowFrameType, destOffset, palOffset);
+}
+
+void sub_8098858(u8 windowId, u16 tileNum, u8 palNum)
+{
+ u8 bgLayer = GetWindowAttribute(windowId, WINDOW_PRIORITY);
+ u16 tilemapLeft = GetWindowAttribute(windowId, WINDOW_TILEMAP_LEFT);
+ u16 tilemapTop = GetWindowAttribute(windowId, WINDOW_TILEMAP_TOP);
+ u16 width = GetWindowAttribute(windowId, WINDOW_WIDTH);
+ u16 height = GetWindowAttribute(windowId, WINDOW_HEIGHT);
+
+ FillBgTilemapBufferRect(bgLayer, tileNum + 0, tilemapLeft - 1, tilemapTop - 1, 1, 1, palNum);
+ FillBgTilemapBufferRect(bgLayer, tileNum + 1, tilemapLeft, tilemapTop - 1, width, 1, palNum);
+ FillBgTilemapBufferRect(bgLayer, tileNum + 2, tilemapLeft + width, tilemapTop - 1, 1, 1, palNum);
+ FillBgTilemapBufferRect(bgLayer, tileNum + 3, tilemapLeft - 1, tilemapTop, 1, height, palNum);
+ FillBgTilemapBufferRect(bgLayer, tileNum + 5, tilemapLeft + width, tilemapTop, 1, height, palNum);
+ FillBgTilemapBufferRect(bgLayer, tileNum + 6, tilemapLeft - 1, tilemapTop + height, 1, 1, palNum);
+ FillBgTilemapBufferRect(bgLayer, tileNum + 7, tilemapLeft, tilemapTop + height, width, 1, palNum);
+ FillBgTilemapBufferRect(bgLayer, tileNum + 8, tilemapLeft + width, tilemapTop + height, 1, 1, palNum);
+}
+
+void sub_80989E0(u8 windowId, u16 tileNum, u8 palNum)
+{
+ u8 bgLayer = GetWindowAttribute(windowId, WINDOW_PRIORITY);
+ u16 tilemapLeft = GetWindowAttribute(windowId, WINDOW_TILEMAP_LEFT);
+ u16 tilemapTop = GetWindowAttribute(windowId, WINDOW_TILEMAP_TOP);
+ u16 width = GetWindowAttribute(windowId, WINDOW_WIDTH);
+ u16 height = GetWindowAttribute(windowId, WINDOW_HEIGHT);
+
+ FillBgTilemapBufferRect(bgLayer, tileNum + 0, tilemapLeft, tilemapTop, 1, 1, palNum);
+ FillBgTilemapBufferRect(bgLayer, tileNum + 1, tilemapLeft + 1, tilemapTop, width - 2, 1, palNum);
+ FillBgTilemapBufferRect(bgLayer, tileNum + 2, tilemapLeft + width - 1, tilemapTop, 1, 1, palNum);
+ FillBgTilemapBufferRect(bgLayer, tileNum + 3, tilemapLeft, tilemapTop + 1, 1, height - 2, palNum);
+ FillBgTilemapBufferRect(bgLayer, tileNum + 5, tilemapLeft + width - 1, tilemapTop + 1, 1, height - 2, palNum);
+ FillBgTilemapBufferRect(bgLayer, tileNum + 6, tilemapLeft, tilemapTop + height - 1, 1, 1, palNum);
+ FillBgTilemapBufferRect(bgLayer, tileNum + 7, tilemapLeft + 1, tilemapTop + height - 1, width - 2, 1, palNum);
+ FillBgTilemapBufferRect(bgLayer, tileNum + 8, tilemapLeft + width - 1, tilemapTop + height - 1, 1, 1, palNum);
+}
+
+void rbox_fill_rectangle(u8 windowId)
+{
+ u8 bgLayer = GetWindowAttribute(windowId, WINDOW_PRIORITY);
+ u16 tilemapLeft = GetWindowAttribute(windowId, WINDOW_TILEMAP_LEFT);
+ u16 tilemapTop = GetWindowAttribute(windowId, WINDOW_TILEMAP_TOP);
+ u16 width = GetWindowAttribute(windowId, WINDOW_WIDTH);
+ u16 height = GetWindowAttribute(windowId, WINDOW_HEIGHT);
+
+ FillBgTilemapBufferRect(bgLayer, 0, tilemapLeft - 1, tilemapTop - 1, width + 2, height + 2, 0x11);
+}
+
+const u16* stdpal_get(u8 id)
+{
+ switch (id)
+ {
+ case 0:
+ id = 0;
+ break;
+ case 1:
+ id = 0x10;
+ break;
+ case 2:
+ id = 0x20;
+ break;
+ case 3:
+ id = 0x30;
+ break;
+ case 4:
+ default:
+ id = 0x40;
+ break;
+ }
+ return &gUnknown_0851017C[id];
+}
+
+const u16* sub_8098C64(void)
+{
+ return gUnknown_08DDD728;
+}
+
+void sub_8098C6C(u8 bg, u16 destOffset, u8 palOffset)
+{
+ LoadBgTiles(bg, gUnknown_0851021C[gSaveBlock2Ptr->optionsWindowFrameType].tiles, 0x120, destOffset);
+ LoadPalette(sub_8098758(gSaveBlock2Ptr->optionsWindowFrameType)->pal, palOffset, 0x20);
+}