2020-06-02 18:51:26 -04:00
|
|
|
#include "global.h"
|
|
|
|
#include "task.h"
|
|
|
|
#include "bg.h"
|
|
|
|
#include "palette.h"
|
|
|
|
#include "gpu_regs.h"
|
|
|
|
#include "malloc.h"
|
|
|
|
#include "scanline_effect.h"
|
|
|
|
#include "m4a.h"
|
|
|
|
#include "dynamic_placeholder_text_util.h"
|
|
|
|
#include "overworld.h"
|
|
|
|
#include "strings.h"
|
|
|
|
#include "string_util.h"
|
|
|
|
#include "international_string_util.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "librfu.h"
|
|
|
|
#include "link_rfu.h"
|
|
|
|
#include "union_room.h"
|
|
|
|
#include "constants/songs.h"
|
|
|
|
#include "constants/union_room.h"
|
2022-11-09 14:29:57 -05:00
|
|
|
#include "constants/rgb.h"
|
2020-06-02 18:51:26 -04:00
|
|
|
|
2020-06-03 14:07:40 -04:00
|
|
|
enum {
|
|
|
|
COLORMODE_NORMAL,
|
|
|
|
COLORMODE_WHITE_LGRAY,
|
|
|
|
COLORMODE_RED,
|
|
|
|
COLORMODE_GREEN,
|
|
|
|
COLORMODE_WHITE_DGRAY,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define GROUPTYPE_TRADE 0
|
|
|
|
#define GROUPTYPE_BATTLE 1
|
|
|
|
#define GROUPTYPE_UNION 2
|
|
|
|
#define GROUPTYPE_TOTAL 3
|
|
|
|
#define GROUPTYPE_NONE -1
|
|
|
|
#define NUM_GROUPTYPES 4
|
|
|
|
|
|
|
|
struct WirelessCommunicationStatusScreen
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
2020-06-03 14:07:40 -04:00
|
|
|
u32 groupCounts[NUM_GROUPTYPES];
|
|
|
|
u32 prevGroupCounts[NUM_GROUPTYPES];
|
|
|
|
u32 activities[NUM_TASK_DATA];
|
|
|
|
u8 taskId;
|
|
|
|
u8 rfuTaskId;
|
|
|
|
u8 filler[10];
|
2020-06-02 18:51:26 -04:00
|
|
|
};
|
|
|
|
|
2020-06-03 14:07:40 -04:00
|
|
|
static struct WirelessCommunicationStatusScreen * sStatusScreen;
|
2020-06-02 18:51:26 -04:00
|
|
|
|
2020-06-03 14:07:40 -04:00
|
|
|
static void CB2_InitWirelessCommunicationScreen(void);
|
|
|
|
static void Task_WirelessCommunicationScreen(u8);
|
|
|
|
static void WCSS_AddTextPrinterParameterized(u8, u8, const u8 *, u8, u8, u8);
|
|
|
|
static bool32 UpdateCommunicationCounts(u32 *, u32 *, u32 *, u8);
|
2020-06-02 18:51:26 -04:00
|
|
|
|
2022-11-09 14:29:57 -05:00
|
|
|
static const u16 sPalettes[][16] = {
|
|
|
|
INCBIN_U16("graphics/wireless_status_screen/default.gbapal"),
|
|
|
|
{}, // All black. Never read
|
|
|
|
INCBIN_U16("graphics/wireless_status_screen/anim_00.gbapal"),
|
|
|
|
INCBIN_U16("graphics/wireless_status_screen/anim_01.gbapal"),
|
|
|
|
INCBIN_U16("graphics/wireless_status_screen/anim_02.gbapal"),
|
|
|
|
INCBIN_U16("graphics/wireless_status_screen/anim_03.gbapal"),
|
|
|
|
INCBIN_U16("graphics/wireless_status_screen/anim_04.gbapal"),
|
|
|
|
INCBIN_U16("graphics/wireless_status_screen/anim_05.gbapal"),
|
|
|
|
INCBIN_U16("graphics/wireless_status_screen/anim_06.gbapal"),
|
|
|
|
INCBIN_U16("graphics/wireless_status_screen/anim_07.gbapal"),
|
|
|
|
INCBIN_U16("graphics/wireless_status_screen/anim_08.gbapal"),
|
|
|
|
INCBIN_U16("graphics/wireless_status_screen/anim_09.gbapal"),
|
|
|
|
INCBIN_U16("graphics/wireless_status_screen/anim_10.gbapal"),
|
|
|
|
INCBIN_U16("graphics/wireless_status_screen/anim_11.gbapal"),
|
|
|
|
INCBIN_U16("graphics/wireless_status_screen/anim_12.gbapal"),
|
|
|
|
INCBIN_U16("graphics/wireless_status_screen/anim_13.gbapal")
|
|
|
|
};
|
|
|
|
static const u32 sBgTiles_Gfx[] = INCBIN_U32("graphics/wireless_status_screen/bg.4bpp.lz");
|
|
|
|
static const u32 sBgTiles_Tilemap[] = INCBIN_U32("graphics/wireless_status_screen/bg.bin.lz");
|
2020-06-02 18:51:26 -04:00
|
|
|
|
|
|
|
static const struct BgTemplate sBgTemplates[] = {
|
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.charBaseIndex = 2,
|
2020-06-03 14:07:40 -04:00
|
|
|
.mapBaseIndex = 31,
|
2020-06-02 18:51:26 -04:00
|
|
|
.priority = 0
|
|
|
|
}, {
|
|
|
|
.bg = 1,
|
|
|
|
.charBaseIndex = 0,
|
2020-06-03 14:07:40 -04:00
|
|
|
.mapBaseIndex = 8,
|
2020-06-02 18:51:26 -04:00
|
|
|
.priority = 1
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-06-03 14:07:40 -04:00
|
|
|
static const struct WindowTemplate sWindowTemplates[] = {
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
2020-06-03 14:07:40 -04:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 3,
|
|
|
|
.tilemapTop = 0,
|
|
|
|
.width = 24,
|
|
|
|
.height = 3,
|
2022-08-19 16:32:00 +01:00
|
|
|
.paletteNum = 15,
|
2020-06-02 18:51:26 -04:00
|
|
|
.baseBlock = 0x0001
|
|
|
|
}, {
|
2020-06-03 14:07:40 -04:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 3,
|
|
|
|
.tilemapTop = 4,
|
|
|
|
.width = 21,
|
|
|
|
.height = 15,
|
2022-08-19 16:32:00 +01:00
|
|
|
.paletteNum = 15,
|
2020-06-02 18:51:26 -04:00
|
|
|
.baseBlock = 0x0049
|
|
|
|
}, {
|
2020-06-03 14:07:40 -04:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 24,
|
|
|
|
.tilemapTop = 4,
|
|
|
|
.width = 3,
|
|
|
|
.height = 15,
|
2022-08-19 16:32:00 +01:00
|
|
|
.paletteNum = 15,
|
2020-06-02 18:51:26 -04:00
|
|
|
.baseBlock = 0x0184
|
2020-06-03 14:07:40 -04:00
|
|
|
}, DUMMY_WIN_TEMPLATE
|
2020-06-02 18:51:26 -04:00
|
|
|
};
|
|
|
|
|
2020-06-03 14:07:40 -04:00
|
|
|
static const u8 *const sHeaderTexts[NUM_GROUPTYPES + 1] = {
|
|
|
|
[0] = gText_WirelessCommStatus,
|
|
|
|
[GROUPTYPE_TRADE + 1] = gText_PeopleTrading,
|
|
|
|
[GROUPTYPE_BATTLE + 1] = gText_PeopleBattling,
|
|
|
|
[GROUPTYPE_UNION + 1] = gText_PeopleInUnionRoom,
|
|
|
|
[GROUPTYPE_TOTAL + 1] = gText_PeopleCommunicating
|
2020-06-02 18:51:26 -04:00
|
|
|
};
|
|
|
|
|
2020-06-03 14:07:40 -04:00
|
|
|
// Activity, group type, number of players
|
|
|
|
// 0 players means the number of players can change and should be counted dynamically
|
|
|
|
// GROUPTYPE_TOTAL have no unique group and are simply counted in the total of "people communicating"
|
|
|
|
static const u8 sActivityGroupInfo[][3] = {
|
|
|
|
{ACTIVITY_BATTLE_SINGLE, GROUPTYPE_BATTLE, 2},
|
|
|
|
{ACTIVITY_BATTLE_DOUBLE, GROUPTYPE_BATTLE, 2},
|
|
|
|
{ACTIVITY_BATTLE_MULTI, GROUPTYPE_BATTLE, 4},
|
|
|
|
{ACTIVITY_TRADE, GROUPTYPE_TRADE, 2},
|
2021-10-05 23:38:36 -04:00
|
|
|
{ACTIVITY_WONDER_CARD_DUP, GROUPTYPE_TOTAL, 2},
|
|
|
|
{ACTIVITY_WONDER_NEWS_DUP, GROUPTYPE_TOTAL, 2},
|
2020-06-03 14:07:40 -04:00
|
|
|
{ACTIVITY_POKEMON_JUMP, GROUPTYPE_TOTAL, 0},
|
|
|
|
{ACTIVITY_BERRY_CRUSH, GROUPTYPE_TOTAL, 0},
|
|
|
|
{ACTIVITY_BERRY_PICK, GROUPTYPE_TOTAL, 0},
|
|
|
|
{ACTIVITY_SEARCH, GROUPTYPE_NONE, 0},
|
|
|
|
{ACTIVITY_SPIN_TRADE, GROUPTYPE_TRADE, 0},
|
|
|
|
{ACTIVITY_BERRY_BLENDER, GROUPTYPE_TOTAL, 0},
|
|
|
|
{ACTIVITY_RECORD_CORNER, GROUPTYPE_TOTAL, 0},
|
|
|
|
{ACTIVITY_NONE | IN_UNION_ROOM, GROUPTYPE_UNION, 1},
|
|
|
|
{ACTIVITY_BATTLE_SINGLE | IN_UNION_ROOM, GROUPTYPE_UNION, 2},
|
|
|
|
{ACTIVITY_TRADE | IN_UNION_ROOM, GROUPTYPE_UNION, 2},
|
|
|
|
{ACTIVITY_CHAT | IN_UNION_ROOM, GROUPTYPE_UNION, 0},
|
|
|
|
{ACTIVITY_CARD | IN_UNION_ROOM, GROUPTYPE_UNION, 2},
|
|
|
|
{ACTIVITY_PLYRTALK | IN_UNION_ROOM, GROUPTYPE_UNION, 1},
|
|
|
|
{ACTIVITY_NPCTALK | IN_UNION_ROOM, GROUPTYPE_UNION, 2},
|
|
|
|
{ACTIVITY_ACCEPT | IN_UNION_ROOM, GROUPTYPE_UNION, 1},
|
|
|
|
{ACTIVITY_DECLINE | IN_UNION_ROOM, GROUPTYPE_UNION, 1},
|
2021-10-05 23:38:36 -04:00
|
|
|
{ACTIVITY_WONDER_CARD, GROUPTYPE_TOTAL, 2},
|
|
|
|
{ACTIVITY_WONDER_NEWS, GROUPTYPE_TOTAL, 2},
|
2020-06-03 14:07:40 -04:00
|
|
|
{ACTIVITY_CONTEST_COOL, GROUPTYPE_TOTAL, 0},
|
|
|
|
{ACTIVITY_CONTEST_BEAUTY, GROUPTYPE_TOTAL, 0},
|
|
|
|
{ACTIVITY_CONTEST_CUTE, GROUPTYPE_TOTAL, 0},
|
|
|
|
{ACTIVITY_CONTEST_SMART, GROUPTYPE_TOTAL, 0},
|
|
|
|
{ACTIVITY_CONTEST_TOUGH, GROUPTYPE_TOTAL, 0},
|
|
|
|
{ACTIVITY_BATTLE_TOWER, GROUPTYPE_BATTLE, 2},
|
|
|
|
{ACTIVITY_BATTLE_TOWER_OPEN, GROUPTYPE_BATTLE, 2}
|
2020-06-02 18:51:26 -04:00
|
|
|
};
|
|
|
|
|
2020-06-03 14:07:40 -04:00
|
|
|
static void CB2_RunWirelessCommunicationScreen(void)
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
|
|
|
RunTasks();
|
|
|
|
RunTextPrinters();
|
|
|
|
AnimateSprites();
|
|
|
|
BuildOamBuffer();
|
|
|
|
UpdatePaletteFade();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-03 14:07:40 -04:00
|
|
|
static void VBlankCB_WirelessCommunicationScreen(void)
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
|
|
|
LoadOam();
|
|
|
|
ProcessSpriteCopyRequests();
|
|
|
|
TransferPlttBuffer();
|
|
|
|
}
|
|
|
|
|
2020-06-03 14:07:40 -04:00
|
|
|
void ShowWirelessCommunicationScreen(void)
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
2020-06-03 14:07:40 -04:00
|
|
|
SetMainCallback2(CB2_InitWirelessCommunicationScreen);
|
2020-06-02 18:51:26 -04:00
|
|
|
}
|
|
|
|
|
2020-06-03 14:07:40 -04:00
|
|
|
static void CB2_InitWirelessCommunicationScreen(void)
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
2020-06-03 14:07:40 -04:00
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, 0);
|
|
|
|
sStatusScreen = AllocZeroed(sizeof(struct WirelessCommunicationStatusScreen));
|
2020-06-02 18:51:26 -04:00
|
|
|
SetVBlankCallback(NULL);
|
|
|
|
ResetBgsAndClearDma3BusyFlags(0);
|
|
|
|
InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates));
|
2021-03-29 09:38:19 -04:00
|
|
|
SetBgTilemapBuffer(1, Alloc(BG_SCREEN_SIZE));
|
|
|
|
SetBgTilemapBuffer(0, Alloc(BG_SCREEN_SIZE));
|
2020-06-03 14:07:40 -04:00
|
|
|
DecompressAndLoadBgGfxUsingHeap(1, sBgTiles_Gfx, 0, 0, 0);
|
|
|
|
CopyToBgTilemapBuffer(1, sBgTiles_Tilemap, 0, 0);
|
2020-06-02 18:51:26 -04:00
|
|
|
InitWindows(sWindowTemplates);
|
|
|
|
DeactivateAllTextPrinters();
|
|
|
|
ResetPaletteFade();
|
|
|
|
ResetSpriteData();
|
|
|
|
ResetTasks();
|
|
|
|
ScanlineEffect_Stop();
|
|
|
|
m4aSoundVSyncOn();
|
2020-06-03 14:07:40 -04:00
|
|
|
SetVBlankCallback(VBlankCB_WirelessCommunicationScreen);
|
|
|
|
sStatusScreen->taskId = CreateTask(Task_WirelessCommunicationScreen, 0);
|
|
|
|
sStatusScreen->rfuTaskId = CreateTask_ListenToWireless();
|
|
|
|
sStatusScreen->prevGroupCounts[GROUPTYPE_TOTAL] = 1;
|
2021-11-03 23:02:06 -04:00
|
|
|
ChangeBgX(0, 0, BG_COORD_SET);
|
|
|
|
ChangeBgY(0, 0, BG_COORD_SET);
|
|
|
|
ChangeBgX(1, 0, BG_COORD_SET);
|
|
|
|
ChangeBgY(1, 0, BG_COORD_SET);
|
2023-01-18 11:07:12 -05:00
|
|
|
LoadPalette(sPalettes, BG_PLTT_ID(0), PLTT_SIZE_4BPP);
|
2020-06-02 18:51:26 -04:00
|
|
|
Menu_LoadStdPalAt(0xF0);
|
|
|
|
DynamicPlaceholderTextUtil_Reset();
|
2022-08-19 16:32:00 +01:00
|
|
|
FillBgTilemapBufferRect(0, 0, 0, 0, 32, 32, 15);
|
2020-06-02 18:51:26 -04:00
|
|
|
CopyBgTilemapBufferToVram(1);
|
2020-06-03 14:07:40 -04:00
|
|
|
SetMainCallback2(CB2_RunWirelessCommunicationScreen);
|
2020-06-02 18:51:26 -04:00
|
|
|
RunTasks();
|
|
|
|
RunTextPrinters();
|
|
|
|
AnimateSprites();
|
|
|
|
BuildOamBuffer();
|
|
|
|
UpdatePaletteFade();
|
|
|
|
}
|
|
|
|
|
2020-06-03 14:07:40 -04:00
|
|
|
static void CB2_ExitWirelessCommunicationStatusScreen(void)
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
FreeAllWindowBuffers();
|
2020-06-03 14:07:40 -04:00
|
|
|
for (i = 0; i < (int)ARRAY_COUNT(sBgTemplates); i++)
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
|
|
|
Free(GetBgTilemapBuffer(i));
|
|
|
|
}
|
2020-06-03 14:07:40 -04:00
|
|
|
Free(sStatusScreen);
|
2020-06-02 18:51:26 -04:00
|
|
|
SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic);
|
|
|
|
}
|
|
|
|
|
2022-11-09 14:29:57 -05:00
|
|
|
// Cycle through palettes that relocate various shades of blue to create the wave effect at the bottom of the screen.
|
|
|
|
static void CyclePalette(s16 * counter, s16 * palIdx)
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
2022-11-09 14:29:57 -05:00
|
|
|
s32 idx;
|
2020-06-03 14:07:40 -04:00
|
|
|
if (++(*counter) > 5)
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
2022-11-09 14:29:57 -05:00
|
|
|
if (++(*palIdx) == (int)ARRAY_COUNT(sPalettes) - 2)
|
2020-06-03 14:07:40 -04:00
|
|
|
*palIdx = 0;
|
|
|
|
|
|
|
|
*counter = 0;
|
2020-06-02 18:51:26 -04:00
|
|
|
}
|
2022-11-09 14:29:57 -05:00
|
|
|
idx = *palIdx + 2; // +2 skips over default.pal and the empty black palette after it
|
2023-01-18 11:07:12 -05:00
|
|
|
LoadPalette(sPalettes[idx], BG_PLTT_ID(0), PLTT_SIZEOF(8));
|
2020-06-02 18:51:26 -04:00
|
|
|
}
|
|
|
|
|
2020-06-03 14:07:40 -04:00
|
|
|
static void PrintHeaderTexts(void)
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
|
|
|
s32 i;
|
2020-06-03 14:07:40 -04:00
|
|
|
FillWindowPixelBuffer(0, PIXEL_FILL(0));
|
|
|
|
FillWindowPixelBuffer(1, PIXEL_FILL(0));
|
|
|
|
FillWindowPixelBuffer(2, PIXEL_FILL(0));
|
2022-11-09 14:29:57 -05:00
|
|
|
|
|
|
|
// Print title
|
2021-10-30 16:47:37 -04:00
|
|
|
WCSS_AddTextPrinterParameterized(0, FONT_NORMAL, sHeaderTexts[0], GetStringCenterAlignXOffset(FONT_NORMAL, sHeaderTexts[0], 0xC0), 6, COLORMODE_GREEN);
|
2022-11-09 14:29:57 -05:00
|
|
|
|
|
|
|
// Print label for each group (excluding total)
|
|
|
|
for (i = 0; i < NUM_GROUPTYPES - 1; i++)
|
2021-10-30 16:47:37 -04:00
|
|
|
WCSS_AddTextPrinterParameterized(1, FONT_NORMAL, sHeaderTexts[i + 1], 0, 30 * i + 8, COLORMODE_WHITE_LGRAY);
|
2022-11-09 14:29:57 -05:00
|
|
|
|
|
|
|
// Print label for total
|
2021-10-30 16:47:37 -04:00
|
|
|
WCSS_AddTextPrinterParameterized(1, FONT_NORMAL, sHeaderTexts[i + 1], 0, 30 * i + 8, COLORMODE_RED);
|
2022-11-09 14:29:57 -05:00
|
|
|
|
2020-06-02 18:51:26 -04:00
|
|
|
PutWindowTilemap(0);
|
2021-11-03 15:29:18 -04:00
|
|
|
CopyWindowToVram(0, COPYWIN_GFX);
|
2020-06-02 18:51:26 -04:00
|
|
|
PutWindowTilemap(1);
|
2021-11-03 15:29:18 -04:00
|
|
|
CopyWindowToVram(1, COPYWIN_GFX);
|
2020-06-02 18:51:26 -04:00
|
|
|
}
|
|
|
|
|
2020-06-03 14:07:40 -04:00
|
|
|
#define tState data[0]
|
|
|
|
|
|
|
|
static void Task_WirelessCommunicationScreen(u8 taskId)
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
|
|
|
s32 i;
|
2020-06-03 14:07:40 -04:00
|
|
|
switch (gTasks[taskId].tState)
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
|
|
|
case 0:
|
2020-06-03 14:07:40 -04:00
|
|
|
PrintHeaderTexts();
|
|
|
|
gTasks[taskId].tState++;
|
2020-06-02 18:51:26 -04:00
|
|
|
break;
|
|
|
|
case 1:
|
2022-11-09 14:29:57 -05:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK);
|
2020-06-02 18:51:26 -04:00
|
|
|
ShowBg(1);
|
|
|
|
CopyBgTilemapBufferToVram(0);
|
|
|
|
ShowBg(0);
|
2020-06-03 14:07:40 -04:00
|
|
|
gTasks[taskId].tState++;
|
2020-06-02 18:51:26 -04:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (!gPaletteFade.active)
|
2020-06-03 14:07:40 -04:00
|
|
|
gTasks[taskId].tState++;
|
2020-06-02 18:51:26 -04:00
|
|
|
break;
|
|
|
|
case 3:
|
2020-06-03 14:07:40 -04:00
|
|
|
if (UpdateCommunicationCounts(sStatusScreen->groupCounts, sStatusScreen->prevGroupCounts, sStatusScreen->activities, sStatusScreen->rfuTaskId))
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
2020-06-03 14:07:40 -04:00
|
|
|
FillWindowPixelBuffer(2, PIXEL_FILL(0));
|
|
|
|
for (i = 0; i < NUM_GROUPTYPES; i++)
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
2020-06-03 14:07:40 -04:00
|
|
|
ConvertIntToDecimalStringN(gStringVar4, sStatusScreen->groupCounts[i], STR_CONV_MODE_RIGHT_ALIGN, 2);
|
|
|
|
if (i != GROUPTYPE_TOTAL)
|
2021-10-30 16:47:37 -04:00
|
|
|
WCSS_AddTextPrinterParameterized(2, FONT_NORMAL, gStringVar4, 12, 30 * i + 8, COLORMODE_WHITE_LGRAY);
|
2020-06-02 18:51:26 -04:00
|
|
|
else
|
2021-10-30 16:47:37 -04:00
|
|
|
WCSS_AddTextPrinterParameterized(2, FONT_NORMAL, gStringVar4, 12, 98, COLORMODE_RED);
|
2020-06-02 18:51:26 -04:00
|
|
|
}
|
|
|
|
PutWindowTilemap(2);
|
2021-11-03 15:29:18 -04:00
|
|
|
CopyWindowToVram(2, COPYWIN_FULL);
|
2020-06-02 18:51:26 -04:00
|
|
|
}
|
2020-06-03 14:07:40 -04:00
|
|
|
if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON))
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2020-06-03 14:07:40 -04:00
|
|
|
gTasks[sStatusScreen->rfuTaskId].data[15] = 0xFF;
|
|
|
|
gTasks[taskId].tState++;
|
2020-06-02 18:51:26 -04:00
|
|
|
}
|
2022-11-09 14:29:57 -05:00
|
|
|
CyclePalette(&gTasks[taskId].data[7], &gTasks[taskId].data[8]);
|
2020-06-02 18:51:26 -04:00
|
|
|
break;
|
|
|
|
case 4:
|
2022-11-09 14:29:57 -05:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
|
2020-06-03 14:07:40 -04:00
|
|
|
gTasks[taskId].tState++;
|
2020-06-02 18:51:26 -04:00
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2020-06-03 14:07:40 -04:00
|
|
|
SetMainCallback2(CB2_ExitWirelessCommunicationStatusScreen);
|
2020-06-02 18:51:26 -04:00
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-03 14:07:40 -04:00
|
|
|
#undef tState
|
|
|
|
|
|
|
|
static void WCSS_AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 * str, u8 x, u8 y, u8 mode)
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
|
|
|
u8 color[3];
|
|
|
|
|
|
|
|
switch (mode)
|
|
|
|
{
|
2020-06-03 14:07:40 -04:00
|
|
|
case COLORMODE_NORMAL:
|
|
|
|
color[0] = TEXT_COLOR_TRANSPARENT;
|
2021-04-09 22:39:34 -04:00
|
|
|
color[1] = TEXT_COLOR_DARK_GRAY;
|
|
|
|
color[2] = TEXT_COLOR_LIGHT_GRAY;
|
2020-06-02 18:51:26 -04:00
|
|
|
break;
|
2020-06-03 14:07:40 -04:00
|
|
|
case COLORMODE_WHITE_LGRAY:
|
|
|
|
color[0] = TEXT_COLOR_TRANSPARENT;
|
|
|
|
color[1] = TEXT_COLOR_WHITE;
|
2021-04-09 22:39:34 -04:00
|
|
|
color[2] = TEXT_COLOR_LIGHT_GRAY;
|
2020-06-02 18:51:26 -04:00
|
|
|
break;
|
2020-06-03 14:07:40 -04:00
|
|
|
case COLORMODE_RED:
|
|
|
|
color[0] = TEXT_COLOR_TRANSPARENT;
|
|
|
|
color[1] = TEXT_COLOR_RED;
|
|
|
|
color[2] = TEXT_COLOR_LIGHT_RED;
|
2020-06-02 18:51:26 -04:00
|
|
|
break;
|
2020-06-03 14:07:40 -04:00
|
|
|
case COLORMODE_GREEN:
|
|
|
|
color[0] = TEXT_COLOR_TRANSPARENT;
|
|
|
|
color[1] = TEXT_COLOR_LIGHT_GREEN;
|
|
|
|
color[2] = TEXT_COLOR_GREEN;
|
2020-06-02 18:51:26 -04:00
|
|
|
break;
|
2020-06-03 14:07:40 -04:00
|
|
|
case COLORMODE_WHITE_DGRAY:
|
|
|
|
color[0] = TEXT_COLOR_TRANSPARENT;
|
|
|
|
color[1] = TEXT_COLOR_WHITE;
|
2021-04-09 22:39:34 -04:00
|
|
|
color[2] = TEXT_COLOR_DARK_GRAY;
|
2020-06-02 18:51:26 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-11-03 18:29:18 -04:00
|
|
|
AddTextPrinterParameterized4(windowId, fontId, x, y, 0, 0, color, TEXT_SKIP_DRAW, str);
|
2020-06-02 18:51:26 -04:00
|
|
|
}
|
|
|
|
|
2021-10-05 23:38:36 -04:00
|
|
|
static u32 CountPlayersInGroupAndGetActivity(struct RfuPlayer * player, u32 * groupCounts)
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
2020-06-03 14:07:40 -04:00
|
|
|
int i, j, k;
|
2021-10-05 23:38:36 -04:00
|
|
|
u32 activity = player->rfu.data.activity;
|
2020-06-02 18:51:26 -04:00
|
|
|
|
2020-06-03 14:07:40 -04:00
|
|
|
#define group_activity(i) (sActivityGroupInfo[(i)][0])
|
|
|
|
#define group_type(i) (sActivityGroupInfo[(i)][1])
|
|
|
|
#define group_players(i) (sActivityGroupInfo[(i)][2])
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_COUNT(sActivityGroupInfo); i++)
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
2023-02-01 15:44:48 -05:00
|
|
|
#ifdef UBFIX
|
|
|
|
// GROUPTYPE_NONE is -1, and shouldn't be used as an index into groupCounts.
|
|
|
|
// In theory the only activity with this group type (ACTIVITY_SEARCH) wouldn't
|
|
|
|
// satisfy the condition below, but not necessarily.
|
|
|
|
if (group_type(i) == GROUPTYPE_NONE)
|
|
|
|
continue;
|
|
|
|
#endif
|
2021-10-05 23:38:36 -04:00
|
|
|
if (activity == group_activity(i) && player->groupScheduledAnim == UNION_ROOM_SPAWN_IN)
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
2020-06-03 14:07:40 -04:00
|
|
|
if (group_players(i) == 0)
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 04:22:50 -03:00
|
|
|
k = 0;
|
2020-06-03 14:07:40 -04:00
|
|
|
for (j = 0; j < RFU_CHILD_MAX; j++)
|
2021-10-05 23:38:36 -04:00
|
|
|
if (player->rfu.data.partnerInfo[j] != 0) k++;
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 04:22:50 -03:00
|
|
|
k++;
|
2020-06-03 14:07:40 -04:00
|
|
|
groupCounts[group_type(i)] += k;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
groupCounts[group_type(i)] += group_players(i);
|
2020-06-02 18:51:26 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-03 14:07:40 -04:00
|
|
|
return activity;
|
|
|
|
|
|
|
|
#undef group_activity
|
|
|
|
#undef group_type
|
|
|
|
#undef group_players
|
2020-06-02 18:51:26 -04:00
|
|
|
}
|
|
|
|
|
2020-06-03 14:07:40 -04:00
|
|
|
static bool32 HaveCountsChanged(u32 * currCounts, u32 * prevCounts)
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
|
|
|
s32 i;
|
2020-06-03 14:07:40 -04:00
|
|
|
for (i = 0; i < NUM_GROUPTYPES; i++)
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
2020-06-03 14:07:40 -04:00
|
|
|
if (currCounts[i] != prevCounts[i])
|
2020-06-02 18:51:26 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-06-03 14:07:40 -04:00
|
|
|
static bool32 UpdateCommunicationCounts(u32 * groupCounts, u32 * prevGroupCounts, u32 * activities, u8 taskId)
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
2020-06-03 14:07:40 -04:00
|
|
|
bool32 activitiesChanged = FALSE;
|
|
|
|
u32 groupCountBuffer[NUM_GROUPTYPES] = {0, 0, 0, 0};
|
2021-10-05 23:38:36 -04:00
|
|
|
struct RfuPlayer ** players = (void *)gTasks[taskId].data;
|
2020-06-02 18:51:26 -04:00
|
|
|
s32 i;
|
|
|
|
|
2020-06-03 14:07:40 -04:00
|
|
|
for (i = 0; i < NUM_TASK_DATA; i++)
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
2021-10-05 23:38:36 -04:00
|
|
|
u32 activity = CountPlayersInGroupAndGetActivity(&(*players)[i], groupCountBuffer);
|
2020-06-03 14:07:40 -04:00
|
|
|
if (activity != activities[i])
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
2020-06-03 14:07:40 -04:00
|
|
|
activities[i] = activity;
|
|
|
|
activitiesChanged = TRUE;
|
2020-06-02 18:51:26 -04:00
|
|
|
}
|
|
|
|
}
|
2020-06-03 14:07:40 -04:00
|
|
|
|
|
|
|
if (!HaveCountsChanged(groupCountBuffer, prevGroupCounts))
|
2020-06-02 18:51:26 -04:00
|
|
|
{
|
2020-06-03 14:07:40 -04:00
|
|
|
if (activitiesChanged == TRUE)
|
|
|
|
return TRUE;
|
|
|
|
else
|
2020-06-02 18:51:26 -04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-06-03 14:07:40 -04:00
|
|
|
memcpy(groupCounts, groupCountBuffer, sizeof(groupCountBuffer));
|
|
|
|
memcpy(prevGroupCounts, groupCountBuffer, sizeof(groupCountBuffer));
|
|
|
|
|
2021-08-24 19:59:32 -03:00
|
|
|
groupCounts[GROUPTYPE_TOTAL] = groupCounts[GROUPTYPE_TRADE]
|
|
|
|
+ groupCounts[GROUPTYPE_BATTLE]
|
|
|
|
+ groupCounts[GROUPTYPE_UNION]
|
2020-06-03 14:07:40 -04:00
|
|
|
+ groupCounts[GROUPTYPE_TOTAL];
|
|
|
|
return TRUE;
|
2020-06-02 18:51:26 -04:00
|
|
|
}
|
|
|
|
}
|