2017-09-01 19:01:58 +02:00
|
|
|
#include "global.h"
|
|
|
|
#include "text.h"
|
2017-09-01 19:43:26 +02:00
|
|
|
#include "text_window.h"
|
2017-09-01 19:01:58 +02:00
|
|
|
#include "window.h"
|
|
|
|
#include "palette.h"
|
2018-01-21 13:32:11 +01:00
|
|
|
#include "bg.h"
|
|
|
|
#include "graphics.h"
|
|
|
|
|
|
|
|
// const rom data
|
2018-04-17 10:54:39 +02:00
|
|
|
const u8 gTextWindowFrame1_Gfx[] = INCBIN_U8("graphics/text_window/1.4bpp");
|
|
|
|
static const u8 sTextWindowFrame2_Gfx[] = INCBIN_U8("graphics/text_window/2.4bpp");
|
|
|
|
static const u8 sTextWindowFrame3_Gfx[] = INCBIN_U8("graphics/text_window/3.4bpp");
|
|
|
|
static const u8 sTextWindowFrame4_Gfx[] = INCBIN_U8("graphics/text_window/4.4bpp");
|
|
|
|
static const u8 sTextWindowFrame5_Gfx[] = INCBIN_U8("graphics/text_window/5.4bpp");
|
|
|
|
static const u8 sTextWindowFrame6_Gfx[] = INCBIN_U8("graphics/text_window/6.4bpp");
|
|
|
|
static const u8 sTextWindowFrame7_Gfx[] = INCBIN_U8("graphics/text_window/7.4bpp");
|
|
|
|
static const u8 sTextWindowFrame8_Gfx[] = INCBIN_U8("graphics/text_window/8.4bpp");
|
|
|
|
static const u8 sTextWindowFrame9_Gfx[] = INCBIN_U8("graphics/text_window/9.4bpp");
|
|
|
|
static const u8 sTextWindowFrame10_Gfx[] = INCBIN_U8("graphics/text_window/10.4bpp");
|
|
|
|
static const u8 sTextWindowFrame11_Gfx[] = INCBIN_U8("graphics/text_window/11.4bpp");
|
|
|
|
static const u8 sTextWindowFrame12_Gfx[] = INCBIN_U8("graphics/text_window/12.4bpp");
|
|
|
|
static const u8 sTextWindowFrame13_Gfx[] = INCBIN_U8("graphics/text_window/13.4bpp");
|
|
|
|
static const u8 sTextWindowFrame14_Gfx[] = INCBIN_U8("graphics/text_window/14.4bpp");
|
|
|
|
static const u8 sTextWindowFrame15_Gfx[] = INCBIN_U8("graphics/text_window/15.4bpp");
|
|
|
|
static const u8 sTextWindowFrame16_Gfx[] = INCBIN_U8("graphics/text_window/16.4bpp");
|
|
|
|
static const u8 sTextWindowFrame17_Gfx[] = INCBIN_U8("graphics/text_window/17.4bpp");
|
|
|
|
static const u8 sTextWindowFrame18_Gfx[] = INCBIN_U8("graphics/text_window/18.4bpp");
|
|
|
|
static const u8 sTextWindowFrame19_Gfx[] = INCBIN_U8("graphics/text_window/19.4bpp");
|
|
|
|
static const u8 sTextWindowFrame20_Gfx[] = INCBIN_U8("graphics/text_window/20.4bpp");
|
2018-01-21 13:32:11 +01:00
|
|
|
|
|
|
|
const u16 gTextWindowFrame1_Pal[] = INCBIN_U16("graphics/text_window/1.gbapal");
|
|
|
|
static const u16 sTextWindowFrame2_Pal[] = INCBIN_U16("graphics/text_window/2.gbapal");
|
|
|
|
static const u16 sTextWindowFrame3_Pal[] = INCBIN_U16("graphics/text_window/3.gbapal");
|
|
|
|
static const u16 sTextWindowFrame4_Pal[] = INCBIN_U16("graphics/text_window/4.gbapal");
|
|
|
|
static const u16 sTextWindowFrame5_Pal[] = INCBIN_U16("graphics/text_window/5.gbapal");
|
|
|
|
static const u16 sTextWindowFrame6_Pal[] = INCBIN_U16("graphics/text_window/6.gbapal");
|
|
|
|
static const u16 sTextWindowFrame7_Pal[] = INCBIN_U16("graphics/text_window/7.gbapal");
|
|
|
|
static const u16 sTextWindowFrame8_Pal[] = INCBIN_U16("graphics/text_window/8.gbapal");
|
|
|
|
static const u16 sTextWindowFrame9_Pal[] = INCBIN_U16("graphics/text_window/9.gbapal");
|
|
|
|
static const u16 sTextWindowFrame10_Pal[] = INCBIN_U16("graphics/text_window/10.gbapal");
|
|
|
|
static const u16 sTextWindowFrame11_Pal[] = INCBIN_U16("graphics/text_window/11.gbapal");
|
|
|
|
static const u16 sTextWindowFrame12_Pal[] = INCBIN_U16("graphics/text_window/12.gbapal");
|
|
|
|
static const u16 sTextWindowFrame13_Pal[] = INCBIN_U16("graphics/text_window/13.gbapal");
|
|
|
|
static const u16 sTextWindowFrame14_Pal[] = INCBIN_U16("graphics/text_window/14.gbapal");
|
|
|
|
static const u16 sTextWindowFrame15_Pal[] = INCBIN_U16("graphics/text_window/15.gbapal");
|
|
|
|
static const u16 sTextWindowFrame16_Pal[] = INCBIN_U16("graphics/text_window/16.gbapal");
|
|
|
|
static const u16 sTextWindowFrame17_Pal[] = INCBIN_U16("graphics/text_window/17.gbapal");
|
|
|
|
static const u16 sTextWindowFrame18_Pal[] = INCBIN_U16("graphics/text_window/18.gbapal");
|
|
|
|
static const u16 sTextWindowFrame19_Pal[] = INCBIN_U16("graphics/text_window/19.gbapal");
|
|
|
|
static const u16 sTextWindowFrame20_Pal[] = INCBIN_U16("graphics/text_window/20.gbapal");
|
|
|
|
|
|
|
|
static const u16 sUnknown_0851017C[][16] =
|
2017-09-01 19:01:58 +02:00
|
|
|
{
|
2018-01-21 13:32:11 +01:00
|
|
|
INCBIN_U16("graphics/text_window/message_box.gbapal"),
|
|
|
|
INCBIN_U16("graphics/text_window/text_pal1.gbapal"),
|
|
|
|
INCBIN_U16("graphics/text_window/text_pal2.gbapal"),
|
|
|
|
INCBIN_U16("graphics/text_window/text_pal3.gbapal"),
|
|
|
|
INCBIN_U16("graphics/text_window/text_pal4.gbapal")
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct TilesPal sWindowFrames[WINDOW_FRAMES_COUNT] =
|
|
|
|
{
|
|
|
|
{gTextWindowFrame1_Gfx, gTextWindowFrame1_Pal},
|
|
|
|
{sTextWindowFrame2_Gfx, sTextWindowFrame2_Pal},
|
|
|
|
{sTextWindowFrame3_Gfx, sTextWindowFrame3_Pal},
|
|
|
|
{sTextWindowFrame4_Gfx, sTextWindowFrame4_Pal},
|
|
|
|
{sTextWindowFrame5_Gfx, sTextWindowFrame5_Pal},
|
|
|
|
{sTextWindowFrame6_Gfx, sTextWindowFrame6_Pal},
|
|
|
|
{sTextWindowFrame7_Gfx, sTextWindowFrame7_Pal},
|
|
|
|
{sTextWindowFrame8_Gfx, sTextWindowFrame8_Pal},
|
|
|
|
{sTextWindowFrame9_Gfx, sTextWindowFrame9_Pal},
|
|
|
|
{sTextWindowFrame10_Gfx, sTextWindowFrame10_Pal},
|
|
|
|
{sTextWindowFrame11_Gfx, sTextWindowFrame11_Pal},
|
|
|
|
{sTextWindowFrame12_Gfx, sTextWindowFrame12_Pal},
|
|
|
|
{sTextWindowFrame13_Gfx, sTextWindowFrame13_Pal},
|
|
|
|
{sTextWindowFrame14_Gfx, sTextWindowFrame14_Pal},
|
|
|
|
{sTextWindowFrame15_Gfx, sTextWindowFrame15_Pal},
|
|
|
|
{sTextWindowFrame16_Gfx, sTextWindowFrame16_Pal},
|
|
|
|
{sTextWindowFrame17_Gfx, sTextWindowFrame17_Pal},
|
|
|
|
{sTextWindowFrame18_Gfx, sTextWindowFrame18_Pal},
|
|
|
|
{sTextWindowFrame19_Gfx, sTextWindowFrame19_Pal},
|
|
|
|
{sTextWindowFrame20_Gfx, sTextWindowFrame20_Pal}
|
|
|
|
};
|
|
|
|
|
|
|
|
// code
|
|
|
|
const struct TilesPal *GetWindowFrameTilesPal(u8 id)
|
|
|
|
{
|
|
|
|
if (id >= WINDOW_FRAMES_COUNT)
|
|
|
|
return &sWindowFrames[0];
|
2017-09-01 19:01:58 +02:00
|
|
|
else
|
2018-01-21 13:32:11 +01:00
|
|
|
return &sWindowFrames[id];
|
2017-09-01 19:01:58 +02:00
|
|
|
}
|
|
|
|
|
2018-06-17 16:48:58 +02:00
|
|
|
void LoadMessageBoxGfx(u8 windowId, u16 destOffset, u8 palOffset)
|
2017-09-01 19:01:58 +02:00
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
LoadBgTiles(GetWindowAttribute(windowId, WINDOW_BG), gMessageBox_Gfx, 0x1C0, destOffset);
|
2017-11-08 18:05:47 +01:00
|
|
|
LoadPalette(GetOverworldTextboxPalettePtr(), palOffset, 0x20);
|
2017-09-01 19:01:58 +02:00
|
|
|
}
|
|
|
|
|
2018-07-16 20:23:05 +02:00
|
|
|
void LoadUserWindowBorderGfx_(u8 windowId, u16 destOffset, u8 palOffset)
|
2017-09-01 19:01:58 +02:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
LoadUserWindowBorderGfx(windowId, destOffset, palOffset);
|
2017-09-01 19:01:58 +02:00
|
|
|
}
|
|
|
|
|
2018-06-17 16:48:58 +02:00
|
|
|
void LoadWindowGfx(u8 windowId, u8 frameId, u16 destOffset, u8 palOffset)
|
2017-09-01 19:01:58 +02:00
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
LoadBgTiles(GetWindowAttribute(windowId, WINDOW_BG), sWindowFrames[frameId].tiles, 0x120, destOffset);
|
2018-01-21 13:32:11 +01:00
|
|
|
LoadPalette(sWindowFrames[frameId].pal, palOffset, 0x20);
|
2017-09-01 19:01:58 +02:00
|
|
|
}
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
void LoadUserWindowBorderGfx(u8 windowId, u16 destOffset, u8 palOffset)
|
2017-09-01 19:01:58 +02:00
|
|
|
{
|
2018-06-17 16:48:58 +02:00
|
|
|
LoadWindowGfx(windowId, gSaveBlock2Ptr->optionsWindowFrameType, destOffset, palOffset);
|
2017-09-01 19:01:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void sub_8098858(u8 windowId, u16 tileNum, u8 palNum)
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
u8 bgLayer = GetWindowAttribute(windowId, WINDOW_BG);
|
2017-09-01 19:01:58 +02:00
|
|
|
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)
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
u8 bgLayer = GetWindowAttribute(windowId, WINDOW_BG);
|
2017-09-01 19:01:58 +02:00
|
|
|
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)
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
u8 bgLayer = GetWindowAttribute(windowId, WINDOW_BG);
|
2017-09-01 19:01:58 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-01-21 13:32:11 +01:00
|
|
|
const u16 *stdpal_get(u8 id)
|
2017-09-01 19:01:58 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
2018-01-21 13:32:11 +01:00
|
|
|
|
|
|
|
return (const u16 *)(sUnknown_0851017C) + id;
|
2017-09-01 19:01:58 +02:00
|
|
|
}
|
|
|
|
|
2018-01-21 13:32:11 +01:00
|
|
|
const u16 *GetOverworldTextboxPalettePtr(void)
|
2017-09-01 19:01:58 +02:00
|
|
|
{
|
2018-01-21 13:32:11 +01:00
|
|
|
return gMessageBox_Pal;
|
2017-09-01 19:01:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void sub_8098C6C(u8 bg, u16 destOffset, u8 palOffset)
|
|
|
|
{
|
2018-01-21 13:32:11 +01:00
|
|
|
LoadBgTiles(bg, sWindowFrames[gSaveBlock2Ptr->optionsWindowFrameType].tiles, 0x120, destOffset);
|
2018-01-16 18:59:06 +01:00
|
|
|
LoadPalette(GetWindowFrameTilesPal(gSaveBlock2Ptr->optionsWindowFrameType)->pal, palOffset, 0x20);
|
2017-09-01 19:01:58 +02:00
|
|
|
}
|