diff --git a/graphics/union_room_chat/unk_palette2.pal b/graphics/union_room_chat/chat_messages_window.pal similarity index 100% rename from graphics/union_room_chat/unk_palette2.pal rename to graphics/union_room_chat/chat_messages_window.pal diff --git a/graphics/union_room_chat/window_1.pal b/graphics/union_room_chat/input_text.pal similarity index 100% rename from graphics/union_room_chat/window_1.pal rename to graphics/union_room_chat/input_text.pal diff --git a/graphics/union_room_chat/border.bin b/graphics/union_room_chat/keyboard.bin similarity index 100% rename from graphics/union_room_chat/border.bin rename to graphics/union_room_chat/keyboard.bin diff --git a/graphics/union_room_chat/border.png b/graphics/union_room_chat/keyboard.png similarity index 100% rename from graphics/union_room_chat/border.png rename to graphics/union_room_chat/keyboard.png diff --git a/graphics/union_room_chat/r_button.png b/graphics/union_room_chat/r_button.png index 168a293f35..06079ca211 100644 Binary files a/graphics/union_room_chat/r_button.png and b/graphics/union_room_chat/r_button.png differ diff --git a/graphics/union_room_chat/unk_palette1.pal b/graphics/union_room_chat/unused.pal similarity index 100% rename from graphics/union_room_chat/unk_palette1.pal rename to graphics/union_room_chat/unused.pal diff --git a/graphics/union_room_chat/window_2.pal b/graphics/union_room_chat/window_2.pal deleted file mode 100644 index a8c95a3c04..0000000000 --- a/graphics/union_room_chat/window_2.pal +++ /dev/null @@ -1,19 +0,0 @@ -JASC-PAL -0100 -16 -156 197 98 -41 131 222 -0 82 172 -197 255 106 -172 230 49 -246 246 213 -255 49 49 -255 148 148 -131 164 213 -238 238 90 -65 65 65 -115 115 115 -172 172 172 -230 230 255 -0 0 0 -255 255 255 diff --git a/include/graphics.h b/include/graphics.h index 45dd9175de..135eaa95e3 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4992,10 +4992,10 @@ extern const u32 gUsePokeblockCondition_Gfx[]; extern const u16 gUnionRoomChat_Background_Pal[]; extern const u32 gUnionRoomChat_Background_Gfx[]; extern const u32 gUnionRoomChat_Background_Tilemap[]; -extern const u16 gUnionRoomChat_Window_Pal1[]; -extern const u16 gUnionRoomChat_Window_Pal2[]; -extern const u32 gUnionRoomChat_Border_Gfx[]; -extern const u32 gUnionRoomChat_Border_Tilemap[]; +extern const u16 gUnionRoomChat_InputText_Pal[]; +extern const u16 gUnionRoomChat_Keyboard_Pal[]; +extern const u32 gUnionRoomChat_Keyboard_Gfx[]; +extern const u32 gUnionRoomChat_Keyboard_Tilemap[]; extern const u32 gUnionRoomChat_RButtonLabels[]; // Use Pokeblock diff --git a/src/graphics.c b/src/graphics.c index 40ed78ae69..e8f891d8b2 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -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] = diff --git a/src/union_room_chat.c b/src/union_room_chat.c old mode 100755 new mode 100644 index 5d91e264a0..253e025689 --- a/src/union_room_chat.c +++ b/src/union_room_chat.c @@ -173,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 @@ -254,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); @@ -527,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[] = { { @@ -759,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 = { @@ -970,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; } @@ -1759,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; } @@ -2063,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; @@ -2254,7 +2253,7 @@ static bool32 Display_LoadGfx(u8 *state) ClearBg0(); break; case 2: - LoadChatWindowBorderGfx(); + LoadKeyboardWindowGfx(); break; case 3: LoadChatWindowGfx(); @@ -2264,7 +2263,7 @@ static bool32 Display_LoadGfx(u8 *state) break; case 5: LoadChatMessagesWindow(); - LoadKeyboardWindow(); + DrawKeyboardWindow(); LoadKeyboardSwapWindow(); LoadTextEntryWindow(); break; @@ -3063,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); } @@ -3080,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); @@ -3090,19 +3093,19 @@ 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)); + 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(WIN_KEYBOARD); PrintCurrentKeyboardPage(); @@ -3116,8 +3119,9 @@ 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(WIN_TEXT_ENTRY, sDisplay->unk2128, i * 8, 0, 8, 16); + BlitBitmapToWindow(WIN_TEXT_ENTRY, sDisplay->textEntryTiles, i * 8, 0, 8, 16); FillWindowPixelBuffer(WIN_TEXT_ENTRY, PIXEL_FILL(0)); PutWindowTilemap(WIN_TEXT_ENTRY); @@ -3129,7 +3133,7 @@ static void LoadKeyboardSwapWindow(void) 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); + LoadPalette(gStandardMenuPalette, BG_PLTT_ID(14), PLTT_SIZE_4BPP); } static void InitScanlineEffect(void)