Correct some union room chat documentation

This commit is contained in:
GriffinR
2023-02-02 00:09:53 -05:00
parent 62aed217fe
commit 5793a1a5e7
10 changed files with 94 additions and 99 deletions

View File

@@ -1427,10 +1427,10 @@ const u32 gNamingScreenKeyboardSymbols_Tilemap[] = INCBIN_U32("graphics/naming_s
const u16 gUnionRoomChat_Background_Pal[] = INCBIN_U16("graphics/union_room_chat/background.gbapal");
const u32 gUnionRoomChat_Background_Gfx[] = INCBIN_U32("graphics/union_room_chat/background.4bpp.lz");
const u32 gUnionRoomChat_Background_Tilemap[] = INCBIN_U32("graphics/union_room_chat/background.bin.lz");
const u16 gUnionRoomChat_Window_Pal1[] = INCBIN_U16("graphics/union_room_chat/window_1.gbapal");
const u16 gUnionRoomChat_Window_Pal2[] = INCBIN_U16("graphics/union_room_chat/window_2.gbapal");
const u32 gUnionRoomChat_Border_Gfx[] = INCBIN_U32("graphics/union_room_chat/border.4bpp.lz");
const u32 gUnionRoomChat_Border_Tilemap[] = INCBIN_U32("graphics/union_room_chat/border.bin.lz");
const u16 gUnionRoomChat_InputText_Pal[] = INCBIN_U16("graphics/union_room_chat/input_text.gbapal");
const u16 gUnionRoomChat_Keyboard_Pal[] = INCBIN_U16("graphics/union_room_chat/keyboard.gbapal");
const u32 gUnionRoomChat_Keyboard_Gfx[] = INCBIN_U32("graphics/union_room_chat/keyboard.4bpp.lz");
const u32 gUnionRoomChat_Keyboard_Tilemap[] = INCBIN_U32("graphics/union_room_chat/keyboard.bin.lz");
const u32 gUnionRoomChat_RButtonLabels[] = INCBIN_U32("graphics/union_room_chat/r_button_labels.4bpp.lz");
const u16 gTilesetPalettes_General[][16] =

View File

@@ -116,6 +116,13 @@ enum {
// Shared by all above
#define PALTAG_INTERFACE 0
enum {
WIN_CHAT_HISTORY,
WIN_TEXT_ENTRY,
WIN_KEYBOARD,
WIN_SWAP_MENU,
};
struct UnionRoomChat
{
u32 filler1;
@@ -166,8 +173,7 @@ struct UnionRoomChatDisplay
u8 bg1Buffer[BG_SCREEN_SIZE];
u8 bg3Buffer[BG_SCREEN_SIZE];
u8 bg2Buffer[BG_SCREEN_SIZE];
u8 unk2128[0x20];
u8 unk2148[0x20];
u8 textEntryTiles[TILE_SIZE_4BPP * 2];
};
struct UnionRoomChatSprites
@@ -247,11 +253,11 @@ static void FreeSprites(void);
static void ResetGpuBgState(void);
static void SetBgTilemapBuffers(void);
static void ClearBg0(void);
static void LoadChatWindowBorderGfx(void);
static void LoadKeyboardWindowGfx(void);
static void LoadChatWindowGfx(void);
static void LoadChatUnkPalette(void);
static void LoadChatMessagesWindow(void);
static void LoadKeyboardWindow(void);
static void DrawKeyboardWindow(void);
static void LoadKeyboardSwapWindow(void);
static void LoadTextEntryWindow(void);
static void CreateKeyboardCursorSprite(void);
@@ -520,8 +526,8 @@ static const u8 *const sUnionRoomKeyboardText[UNION_ROOM_KB_PAGE_COUNT - 1][UNIO
}
};
static const u16 sUnk_Palette1[] = INCBIN_U16("graphics/union_room_chat/unk_palette1.gbapal");
static const u16 sUnk_Palette2[] = INCBIN_U16("graphics/union_room_chat/unk_palette2.gbapal");
static const u16 sUnusedPalette[] = INCBIN_U16("graphics/union_room_chat/unused.gbapal"); // Loaded but never apparently used
static const u16 sChatMessagesWindow_Pal[] = INCBIN_U16("graphics/union_room_chat/chat_messages_window.gbapal");
static const struct BgTemplate sBgTemplates[] = {
{
@@ -560,7 +566,7 @@ static const struct BgTemplate sBgTemplates[] = {
};
static const struct WindowTemplate sWinTemplates[] = {
{
[WIN_CHAT_HISTORY] = {
.bg = 3,
.tilemapLeft = 8,
.tilemapTop = 1,
@@ -568,7 +574,8 @@ static const struct WindowTemplate sWinTemplates[] = {
.height = 19,
.paletteNum = 15,
.baseBlock = 0x0001,
}, {
},
[WIN_TEXT_ENTRY] = {
.bg = 1,
.tilemapLeft = 9,
.tilemapTop = 18,
@@ -576,7 +583,8 @@ static const struct WindowTemplate sWinTemplates[] = {
.height = 2,
.paletteNum = 12,
.baseBlock = 0x007a,
}, {
},
[WIN_KEYBOARD] = {
.bg = 1,
.tilemapLeft = 0,
.tilemapTop = 2,
@@ -584,7 +592,8 @@ static const struct WindowTemplate sWinTemplates[] = {
.height = 15,
.paletteNum = 7,
.baseBlock = 0x0020,
}, {
},
[WIN_SWAP_MENU] = {
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 2,
@@ -749,15 +758,15 @@ static const u32 sTextEntryArrowTiles[] = INCBIN_U32("graphics/union_room_chat/t
static const u32 sRButtonGfxTiles[] = INCBIN_U32("graphics/union_room_chat/r_button.4bpp.lz");
static const struct CompressedSpriteSheet sSpriteSheets[] = {
{sKeyboardCursorTiles, 0x1000, 0},
{sTextEntryArrowTiles, 0x0040, 1},
{sTextEntryCursorTiles, 0x0040, 2},
{sRButtonGfxTiles, 0x0080, 3},
{gUnionRoomChat_RButtonLabels, 0x0400, 4}
{.data = sKeyboardCursorTiles, .size = 0x1000, .tag = GFXTAG_KEYBOARD_CURSOR},
{.data = sTextEntryArrowTiles, .size = 0x0040, .tag = GFXTAG_TEXT_ENTRY_ARROW},
{.data = sTextEntryCursorTiles, .size = 0x0040, .tag = GFXTAG_TEXT_ENTRY_CURSOR},
{.data = sRButtonGfxTiles, .size = 0x0080, .tag = GFXTAG_RBUTTON_ICON},
{.data = gUnionRoomChat_RButtonLabels, .size = 0x0400, .tag = GFXTAG_RBUTTON_LABELS}
};
static const struct SpritePalette sSpritePalette = {
sUnionRoomChatInterfacePal, 0
.data = sUnionRoomChatInterfacePal, .tag = PALTAG_INTERFACE
};
static const struct OamData sOam_KeyboardCursor = {
@@ -960,7 +969,7 @@ static void CB2_LoadInterface(void)
sChat->handleInputTask = CreateTask(Task_HandlePlayerInput, 8);
sChat->receiveMessagesTask = CreateTask(Task_ReceiveChatMessage, 7);
LoadWirelessStatusIndicatorSpriteGfx();
CreateWirelessStatusIndicatorSprite(232, 150);
CreateWirelessStatusIndicatorSprite(DISPLAY_WIDTH - 8, DISPLAY_HEIGHT - 10);
}
break;
}
@@ -1749,7 +1758,7 @@ static void RegisterTextAtRow(void)
static void ResetMessageEntryBuffer(void)
{
sChat->messageEntryBuffer[0] = EOS;
sChat->lastBufferCursorPos = 15;
sChat->lastBufferCursorPos = MAX_MESSAGE_LENGTH;
sChat->bufferCursorPos = 0;
}
@@ -2053,10 +2062,10 @@ static void Task_ReceiveChatMessage(u8 taskId)
tState = 3;
// fall through
case 3:
for (; tI < 5 && ((tBlockReceivedStatus >> tI) & 1) == 0; tI++)
for (; tI < MAX_RFU_PLAYERS && ((tBlockReceivedStatus >> tI) & 1) == 0; tI++)
;
if (tI == 5)
if (tI == MAX_RFU_PLAYERS)
{
tState = 1;
return;
@@ -2244,7 +2253,7 @@ static bool32 Display_LoadGfx(u8 *state)
ClearBg0();
break;
case 2:
LoadChatWindowBorderGfx();
LoadKeyboardWindowGfx();
break;
case 3:
LoadChatWindowGfx();
@@ -2254,7 +2263,7 @@ static bool32 Display_LoadGfx(u8 *state)
break;
case 5:
LoadChatMessagesWindow();
LoadKeyboardWindow();
DrawKeyboardWindow();
LoadKeyboardSwapWindow();
LoadTextEntryWindow();
break;
@@ -2280,7 +2289,7 @@ static bool32 Display_ShowKeyboardSwapMenu(u8 *state)
{
case 0:
ShowKeyboardSwapMenu();
CopyWindowToVram(3, COPYWIN_FULL);
CopyWindowToVram(WIN_SWAP_MENU, COPYWIN_FULL);
break;
case 1:
return IsDma3ManagerBusyWithBgCopy();
@@ -2296,7 +2305,7 @@ static bool32 Display_HideKeyboardSwapMenu(u8 *state)
{
case 0:
HideKeyboardSwapMenu();
CopyWindowToVram(3, COPYWIN_FULL);
CopyWindowToVram(WIN_SWAP_MENU, COPYWIN_FULL);
break;
case 1:
return IsDma3ManagerBusyWithBgCopy();
@@ -2316,7 +2325,7 @@ static bool32 Display_SwitchPages(u8 *state)
return TRUE;
PrintCurrentKeyboardPage();
CopyWindowToVram(2, COPYWIN_GFX);
CopyWindowToVram(WIN_KEYBOARD, COPYWIN_GFX);
break;
case 1:
if (IsDma3ManagerBusyWithBgCopy())
@@ -2393,7 +2402,7 @@ static bool32 Display_UpdateMessageBuffer(u8 *state)
FillTextEntryWindow(x, width, 0);
str = GetMessageEntryBuffer();
DrawTextEntryMessage(0, str, 3, 1, 2);
CopyWindowToVram(1, COPYWIN_GFX);
CopyWindowToVram(WIN_TEXT_ENTRY, COPYWIN_GFX);
break;
case 1:
if (!IsDma3ManagerBusyWithBgCopy())
@@ -2422,7 +2431,7 @@ static bool32 Display_AskRegisterText(u8 *state)
length = StringLength_Multibyte(str);
FillTextEntryWindow(x, length, PIXEL_FILL(6));
DrawTextEntryMessage(x, str, 0, 4, 5);
CopyWindowToVram(1, COPYWIN_GFX);
CopyWindowToVram(WIN_TEXT_ENTRY, COPYWIN_GFX);
break;
case 1:
if (!IsDma3ManagerBusyWithBgCopy())
@@ -2463,7 +2472,7 @@ static bool32 Display_CancelRegister(u8 *state)
length = StringLength_Multibyte(str);
FillTextEntryWindow(x, length, PIXEL_FILL(0));
DrawTextEntryMessage(x, str, 3, 1, 2);
CopyWindowToVram(1, COPYWIN_GFX);
CopyWindowToVram(WIN_TEXT_ENTRY, COPYWIN_GFX);
break;
case 1:
if (!IsDma3ManagerBusyWithBgCopy())
@@ -2501,7 +2510,7 @@ static bool32 Display_ReturnToKeyboard(u8 *state)
{
case 0:
PrintCurrentKeyboardPage();
CopyWindowToVram(2, COPYWIN_GFX);
CopyWindowToVram(WIN_KEYBOARD, COPYWIN_GFX);
(*state)++;
break;
case 1:
@@ -2527,7 +2536,7 @@ static bool32 Display_ScrollChat(u8 *state)
str = GetLastReceivedMessage();
colorIdx = GetReceivedPlayerIndex();
PrintChatMessage(row, str, colorIdx);
CopyWindowToVram(0, COPYWIN_GFX);
CopyWindowToVram(WIN_CHAT_HISTORY, COPYWIN_GFX);
break;
case 1:
if (IsDma3ManagerBusyWithBgCopy())
@@ -2546,8 +2555,8 @@ static bool32 Display_ScrollChat(u8 *state)
}
// fall through
case 2:
ScrollWindow(0, 0, 5, PIXEL_FILL(1));
CopyWindowToVram(0, COPYWIN_GFX);
ScrollWindow(WIN_CHAT_HISTORY, 0, 5, PIXEL_FILL(1));
CopyWindowToVram(WIN_CHAT_HISTORY, COPYWIN_GFX);
sDisplay->scrollCount++;
(*state)++;
// fall through
@@ -2864,7 +2873,7 @@ static void DestroyStdMessageWindow(void)
static void FillTextEntryWindow(u16 x, u16 width, u8 fillValue)
{
FillWindowPixelRect(1, fillValue, x * 8, 1, width * 8, 14);
FillWindowPixelRect(WIN_TEXT_ENTRY, fillValue, x * 8, 1, width * 8, 14);
}
static void DrawTextEntryMessage(u16 x, u8 *str, u8 bgColor, u8 fgColor, u8 shadowColor)
@@ -2881,7 +2890,7 @@ static void DrawTextEntryMessage(u16 x, u8 *str, u8 bgColor, u8 fgColor, u8 shad
strBuffer[1] = EXT_CTRL_CODE_MIN_LETTER_SPACING;
strBuffer[2] = 8;
StringCopy(&strBuffer[3], str);
AddTextPrinterParameterized3(1, FONT_SHORT, x * 8, 1, color, TEXT_SKIP_DRAW, strBuffer);
AddTextPrinterParameterized3(WIN_TEXT_ENTRY, FONT_SHORT, x * 8, 1, color, TEXT_SKIP_DRAW, strBuffer);
}
static void PrintCurrentKeyboardPage(void)
@@ -2894,7 +2903,7 @@ static void PrintCurrentKeyboardPage(void)
u8 str[45];
u8 *str2;
FillWindowPixelBuffer(2, PIXEL_FILL(15));
FillWindowPixelBuffer(WIN_KEYBOARD, PIXEL_FILL(15));
page = GetCurrentKeyboardPage();
color[0] = TEXT_COLOR_TRANSPARENT;
color[1] = TEXT_DYNAMIC_COLOR_5;
@@ -2916,7 +2925,7 @@ static void PrintCurrentKeyboardPage(void)
return;
StringCopy(&str[3], sUnionRoomKeyboardText[page][i]);
AddTextPrinterParameterized3(2, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str);
AddTextPrinterParameterized3(WIN_KEYBOARD, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str);
}
}
else
@@ -2927,7 +2936,7 @@ static void PrintCurrentKeyboardPage(void)
str2 = GetRegisteredTextByRow(i);
if (GetStringWidth(FONT_SMALL, str2, 0) <= 40)
{
AddTextPrinterParameterized3(2, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str2);
AddTextPrinterParameterized3(WIN_KEYBOARD, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str2);
}
else
{
@@ -2938,8 +2947,8 @@ static void PrintCurrentKeyboardPage(void)
StringCopyN_Multibyte(str, str2, length);
} while (GetStringWidth(FONT_SMALL, str, 0) > 35);
AddTextPrinterParameterized3(2, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str);
AddTextPrinterParameterized3(2, FONT_SMALL, left + 35, top, color, TEXT_SKIP_DRAW, sText_Ellipsis);
AddTextPrinterParameterized3(WIN_KEYBOARD, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str);
AddTextPrinterParameterized3(WIN_KEYBOARD, FONT_SMALL, left + 35, top, color, TEXT_SKIP_DRAW, sText_Ellipsis);
}
}
}
@@ -2989,17 +2998,17 @@ static bool32 SlideKeyboardPageIn(void)
static void ShowKeyboardSwapMenu(void)
{
FillWindowPixelBuffer(3, PIXEL_FILL(1));
DrawTextBorderOuter(3, 1, 13);
PrintMenuActionTextsAtPos(3, FONT_SHORT, 8, 1, 14, ARRAY_COUNT(sKeyboardPageTitleTexts), sKeyboardPageTitleTexts);
InitMenuNormal(3, FONT_SHORT, 0, 1, 14, 5, GetCurrentKeyboardPage());
PutWindowTilemap(3);
FillWindowPixelBuffer(WIN_SWAP_MENU, PIXEL_FILL(1));
DrawTextBorderOuter(WIN_SWAP_MENU, 1, 13);
PrintMenuActionTextsAtPos(WIN_SWAP_MENU, FONT_SHORT, 8, 1, 14, ARRAY_COUNT(sKeyboardPageTitleTexts), sKeyboardPageTitleTexts);
InitMenuNormal(WIN_SWAP_MENU, FONT_SHORT, 0, 1, 14, 5, GetCurrentKeyboardPage());
PutWindowTilemap(WIN_SWAP_MENU);
}
static void HideKeyboardSwapMenu(void)
{
ClearStdWindowAndFrameToTransparent(3, FALSE);
ClearWindowTilemap(3);
ClearStdWindowAndFrameToTransparent(WIN_SWAP_MENU, FALSE);
ClearWindowTilemap(WIN_SWAP_MENU);
}
static void PrintChatMessage(u16 row, u8 *str, u8 colorIdx)
@@ -3009,8 +3018,8 @@ static void PrintChatMessage(u16 row, u8 *str, u8 colorIdx)
color[0] = TEXT_COLOR_WHITE;
color[1] = colorIdx * 2 + 2;
color[2] = colorIdx * 2 + 3;
FillWindowPixelRect(0, PIXEL_FILL(1), 0, row * 15, 168, 15);
AddTextPrinterParameterized3(0, FONT_SHORT, 0, row * 15 + 1, color, TEXT_SKIP_DRAW, str);
FillWindowPixelRect(WIN_CHAT_HISTORY, PIXEL_FILL(1), 0, row * 15, 168, 15);
AddTextPrinterParameterized3(WIN_CHAT_HISTORY, FONT_SHORT, 0, row * 15 + 1, color, TEXT_SKIP_DRAW, str);
}
static void ResetGpuBgState(void)
@@ -3053,12 +3062,12 @@ static void ClearBg0(void)
CopyBgTilemapBufferToVram(0);
}
static void LoadChatWindowBorderGfx(void)
static void LoadKeyboardWindowGfx(void)
{
LoadPalette(gUnionRoomChat_Window_Pal2, BG_PLTT_ID(7), PLTT_SIZE_4BPP);
LoadPalette(gUnionRoomChat_Window_Pal1, BG_PLTT_ID(12), PLTT_SIZE_4BPP);
DecompressAndCopyTileDataToVram(1, gUnionRoomChat_Border_Gfx, 0, 0, 0);
CopyToBgTilemapBuffer(1, gUnionRoomChat_Border_Tilemap, 0, 0);
LoadPalette(gUnionRoomChat_Keyboard_Pal, BG_PLTT_ID(7), PLTT_SIZE_4BPP);
LoadPalette(gUnionRoomChat_InputText_Pal, BG_PLTT_ID(12), PLTT_SIZE_4BPP);
DecompressAndCopyTileDataToVram(1, gUnionRoomChat_Keyboard_Gfx, 0, 0, 0);
CopyToBgTilemapBuffer(1, gUnionRoomChat_Keyboard_Tilemap, 0, 0);
CopyBgTilemapBufferToVram(1);
}
@@ -3070,8 +3079,12 @@ static void LoadChatWindowGfx(void)
ptr = DecompressAndCopyTileDataToVram(2, gUnionRoomChat_Background_Gfx, 0, 0, 0);
if (ptr)
{
CpuFastCopy(&ptr[0x220], sDisplay->unk2128, sizeof(sDisplay->unk2128));
CpuFastCopy(&ptr[0x420], sDisplay->unk2148, sizeof(sDisplay->unk2148));
// The below is nonsense. Tiles 0x11 and 0x21 of the background tileset are
// the second half of "OK" and the "T" in "START" in the instructions header.
// They're later blitted onto the text entry window, then immediately cleared.
// The window has a different palette as well, so the tiles would appear mostly black anyway.
CpuFastCopy(&ptr[0x11 * TILE_SIZE_4BPP], &sDisplay->textEntryTiles[TILE_SIZE_4BPP * 0], TILE_SIZE_4BPP);
CpuFastCopy(&ptr[0x21 * TILE_SIZE_4BPP], &sDisplay->textEntryTiles[TILE_SIZE_4BPP * 1], TILE_SIZE_4BPP);
}
CopyToBgTilemapBuffer(2, gUnionRoomChat_Background_Tilemap, 0, 0);
@@ -3080,23 +3093,23 @@ static void LoadChatWindowGfx(void)
static void LoadChatUnkPalette(void)
{
LoadPalette(sUnk_Palette1, BG_PLTT_ID(8), sizeof(sUnk_Palette1));
RequestDma3Fill(0, (void *)BG_CHAR_ADDR(1) + 0x20, 0x20, 1);
LoadPalette(sUnusedPalette, BG_PLTT_ID(8), sizeof(sUnusedPalette));
RequestDma3Fill(0, (void *)BG_CHAR_ADDR(1) + TILE_SIZE_4BPP, TILE_SIZE_4BPP, 1);
}
static void LoadChatMessagesWindow(void)
{
LoadPalette(sUnk_Palette2, BG_PLTT_ID(15), sizeof(sUnk_Palette2));
PutWindowTilemap(0);
FillWindowPixelBuffer(0, PIXEL_FILL(1));
CopyWindowToVram(0, COPYWIN_FULL);
LoadPalette(sChatMessagesWindow_Pal, BG_PLTT_ID(15), sizeof(sChatMessagesWindow_Pal));
PutWindowTilemap(WIN_CHAT_HISTORY);
FillWindowPixelBuffer(WIN_CHAT_HISTORY, PIXEL_FILL(1));
CopyWindowToVram(WIN_CHAT_HISTORY, COPYWIN_FULL);
}
static void LoadKeyboardWindow(void)
static void DrawKeyboardWindow(void)
{
PutWindowTilemap(2);
PutWindowTilemap(WIN_KEYBOARD);
PrintCurrentKeyboardPage();
CopyWindowToVram(2, COPYWIN_FULL);
CopyWindowToVram(WIN_KEYBOARD, COPYWIN_FULL);
}
static void LoadTextEntryWindow(void)
@@ -3106,20 +3119,21 @@ static void LoadTextEntryWindow(void)
unused[0] = 0;
unused[1] = 0xFF;
// Pointless, cleared below. The tiles are nonsense anyway, see LoadChatWindowGfx.
for (i = 0; i < MAX_MESSAGE_LENGTH; i++)
BlitBitmapToWindow(1, sDisplay->unk2128, i * 8, 0, 8, 16);
BlitBitmapToWindow(WIN_TEXT_ENTRY, sDisplay->textEntryTiles, i * 8, 0, 8, 16);
FillWindowPixelBuffer(1, PIXEL_FILL(0));
PutWindowTilemap(1);
CopyWindowToVram(1, COPYWIN_FULL);
FillWindowPixelBuffer(WIN_TEXT_ENTRY, PIXEL_FILL(0));
PutWindowTilemap(WIN_TEXT_ENTRY);
CopyWindowToVram(WIN_TEXT_ENTRY, COPYWIN_FULL);
}
static void LoadKeyboardSwapWindow(void)
{
FillWindowPixelBuffer(3, PIXEL_FILL(1));
LoadUserWindowBorderGfx(3, 1, BG_PLTT_ID(13));
LoadUserWindowBorderGfx_(3, 0xA, BG_PLTT_ID(2));
LoadPalette(gStandardMenuPalette, BG_PLTT_ID(14), PLTT_SIZE_4BPP);
FillWindowPixelBuffer(WIN_SWAP_MENU, PIXEL_FILL(1));
LoadUserWindowBorderGfx(WIN_SWAP_MENU, 1, BG_PLTT_ID(13));
LoadUserWindowBorderGfx_(WIN_SWAP_MENU, 0xA, BG_PLTT_ID(2));
LoadPalette(gStandardMenuPalette, BG_PLTT_ID(14), PLTT_SIZE_4BPP);
}
static void InitScanlineEffect(void)