Alchemy
Loading...
Searching...
No Matches

lobby.c File Reference

The Battle Arena overlay: the lobby where linked and monster battles start, the exchange of the two parties, the attendant and the records of wins. More...

Go to the source code of this file.

Data Structures

struct  LinkPeer
 The partner console's signature as the lobby reads it: a word for each slot column. More...

Macros

#define LOBBY_UNIT_RECORD_BYTES   0x154
#define LOBBY_RECOVERY_RECORD_BYTES   0x140
#define LOBBY_UNIT_RECORD_COUNT   3
#define LOBBY_LINK_READY_MASK   3
#define LOBBY_TRANSFER_RETRY_LIMIT   24
#define LOBBY_SEND_TIMEOUT_FRAMES   600
#define LOBBY_RECEIVE_TIMEOUT_FRAMES   900
#define LOBBY_PEER_WAIT_FRAMES   25
#define PEER_TAG(a, b, c, d)
#define LOBBY_NO_RESULT
 What a lobby handler's early exit returns.

Functions

u8 * LinkLobby_GetEntrances (void)
s32 SceneData_ReturnZero (void)
static s32 LinkLobby_InitializeSerial (void)
 Reinitializes the serial runtime while interrupts are locked.
u8 * LinkLobby_GetExits (void)
s32 LinkLobby_SelectPlacements (void)
 Selects the post-link-battle placements for entrances nine and eleven.
static s32 LinkLobby_PeerSlotMatches (s32 slot)
 Checks one language-specific peer signature slot and updates link-side flags.
static void LinkLobby_WriteSlotValue (s32 slot)
 Publishes a protocol slot value in the outgoing signature payload.
static s32 LinkLobby_PollPeerReady (void)
static s32 LinkLobby_PromptToParticipate (void)
 Prompts for participation unless entering battle or a prompt is still pending.
static s32 LinkLobby_ReportDisconnection (void)
 Resets the disconnect trigger and displays the attendant's warning.
static s32 LinkLobby_ReceivePartyRecords (void)
 Receives three unit records and a recovery table; returns the occupied count or the original transfer failure.
static s32 LinkLobby_CopyPartyOwnerIds (u16 *ownerIds)
 Copies at most three active owner IDs, terminates with 0xff, and returns count.
static s32 LinkLobby_SendPartyRecords (void)
 Sends up to three active owners, pads missing records, then sends recovery data.
static s32 LinkLobby_ExchangePartyRecords (void)
 Orders send/receive by link side and records the received owner count.
static s32 LinkLobby_EnterBattle (void)
 Waits for the opponent, exchanges parties and starts the arena battle.
static s32 LinkLobby_ChooseBattleMode (void)
 Offers a linked challenge or a monster battle and publishes the response.
static s32 LinkLobby_ReportWinTallies (s32 actor)
 Reports total or consecutive linked wins according to the leader's facing.
static s32 LinkLobby_ChooseDebugPartyPreset (s32 actorId)
 Selects a debug party preset; A accepts and B cancels.
static s32 LinkLobby_OpenSanctum (s32 actorId)
 Runs the sanctum service for this actor within an event.
static s32 LinkLobby_PartyContains (s32 ownerId)
 Tests the first three linked-battle owners, or four outside linked finals.
static UNUSED void State_NoOp (void)
 UNUSED: the original empty lobby callback.
static s32 LinkLobby_TalkByProgress (s32 actor)
 Chooses each party member's dialogue from participation and round outcome.
static s32 LinkLobby_LeaveArena (void)
 Removes the link IRQ handlers, restores sound parameters and leaves the arena.
static s32 LinkLobby_TalkToAttendant (s32 actor)
 Selects the attendant's rules or post-battle line from the round outcome.
static s32 LinkLobby_ExplainPartyOrder (s32 actor)
 Alternates between the linked-party size and reorder instructions.
static s32 LinkLobby_ReportMonsterRecord (s32 actorId)
 Reports the stored consecutive-monster-battle record when nonzero.
u8 * LinkLobby_GetEvents (void)
static s32 LinkLobby_SaveBattleResults (void)
 Shows saving/saved messages around the linked battle results save.
static s32 LinkLobby_SaveMonsterBattleResults (void)
 Shows saving/saved messages around the monster battle record save.
static s32 LinkLobby_DrawThreeDigitValue (s32 value)
 Draws a right-to-left three-digit value capped at 999, then redraws the map.
s32 LinkLobby_RunRoundResult (void)
 Processes the entry's monster/link result and restores lobby polling.

Variables

const s32 gLinkLobby_SlotValues []
static s32 sLinkLobbyWaitFrames
u32 gLinkLobbyCallFrames
u8 gLinkLobby_SlotColumns []
struct SceneEntrance gLinkLobbyEntrances []
u32 gLinkLobbyExits []
struct ScenePlacement gLinkLobbyPlacements []
struct ScenePlacement gLinkLobbyBattlePlacements []
struct SceneEvent gLinkLobbyEvents []

Detailed Description

The Battle Arena overlay: the lobby where linked and monster battles start, the exchange of the two parties, the attendant and the records of wins.

Definition in file lobby.c.

Macro Definition Documentation

◆ LOBBY_UNIT_RECORD_BYTES

#define LOBBY_UNIT_RECORD_BYTES   0x154

Definition at line 50 of file lobby.c.

Referenced by LinkLobby_ReceivePartyRecords(), and LinkLobby_SendPartyRecords().

◆ LOBBY_RECOVERY_RECORD_BYTES

#define LOBBY_RECOVERY_RECORD_BYTES   0x140

Definition at line 51 of file lobby.c.

Referenced by LinkLobby_ReceivePartyRecords(), and LinkLobby_SendPartyRecords().

◆ LOBBY_UNIT_RECORD_COUNT

#define LOBBY_UNIT_RECORD_COUNT   3

Definition at line 52 of file lobby.c.

Referenced by LinkLobby_CopyPartyOwnerIds().

◆ LOBBY_LINK_READY_MASK

#define LOBBY_LINK_READY_MASK   3

◆ LOBBY_TRANSFER_RETRY_LIMIT

#define LOBBY_TRANSFER_RETRY_LIMIT   24

Definition at line 54 of file lobby.c.

Referenced by LinkLobby_ReceivePartyRecords(), and LinkLobby_SendPartyRecords().

◆ LOBBY_SEND_TIMEOUT_FRAMES

#define LOBBY_SEND_TIMEOUT_FRAMES   600

Definition at line 55 of file lobby.c.

Referenced by LinkLobby_SendPartyRecords().

◆ LOBBY_RECEIVE_TIMEOUT_FRAMES

#define LOBBY_RECEIVE_TIMEOUT_FRAMES   900

Definition at line 56 of file lobby.c.

Referenced by LinkLobby_ReceivePartyRecords().

◆ LOBBY_PEER_WAIT_FRAMES

#define LOBBY_PEER_WAIT_FRAMES   25

Definition at line 57 of file lobby.c.

Referenced by LinkLobby_EnterBattle(), and LinkLobby_PollPeerReady().

◆ PEER_TAG

#define PEER_TAG ( a,
b,
c,
d )
Value:
((a) | ((b) << 8) | ((c) << 16) | ((d) << 24))

Definition at line 68 of file lobby.c.

◆ LOBBY_NO_RESULT

#define LOBBY_NO_RESULT

What a lobby handler's early exit returns.

The ROM's s32 handlers return nothing there, leaving whatever the last call put in r0 (UB); UBFIX returns 0, as the function ends that fall off do.

Definition at line 117 of file lobby.c.

Referenced by LinkLobby_EnterBattle().

Function Documentation

◆ LinkLobby_GetEntrances()

u8 * LinkLobby_GetEntrances ( void )

Definition at line 120 of file lobby.c.

Referenced by LinkLobby_GetEntrances().

◆ SceneData_ReturnZero()

s32 SceneData_ReturnZero ( void )

Definition at line 122 of file lobby.c.

◆ LinkLobby_InitializeSerial()

s32 LinkLobby_InitializeSerial ( void )
static

Reinitializes the serial runtime while interrupts are locked.

The original s32 entry produces no defined result; its callers ignore it.

Definition at line 126 of file lobby.c.

Referenced by LinkLobby_ChooseBattleMode(), LinkLobby_InitializeSerial(), and LinkLobby_RunRoundResult().

◆ LinkLobby_GetExits()

u8 * LinkLobby_GetExits ( void )

Definition at line 141 of file lobby.c.

Referenced by LinkLobby_GetExits().

◆ LinkLobby_SelectPlacements()

s32 LinkLobby_SelectPlacements ( void )

Selects the post-link-battle placements for entrances nine and eleven.

Definition at line 144 of file lobby.c.

Referenced by LinkLobby_SelectPlacements().

◆ LinkLobby_PeerSlotMatches()

s32 LinkLobby_PeerSlotMatches ( s32 slot)
static

Checks one language-specific peer signature slot and updates link-side flags.

Definition at line 155 of file lobby.c.

Referenced by LinkLobby_ChooseBattleMode(), LinkLobby_EnterBattle(), LinkLobby_PeerSlotMatches(), and LinkLobby_PollPeerReady().

◆ LinkLobby_WriteSlotValue()

void LinkLobby_WriteSlotValue ( s32 slot)
static

Publishes a protocol slot value in the outgoing signature payload.

Definition at line 187 of file lobby.c.

Referenced by LinkLobby_ChooseBattleMode(), LinkLobby_EnterBattle(), LinkLobby_PollPeerReady(), LinkLobby_ReportDisconnection(), LinkLobby_RunRoundResult(), and LinkLobby_WriteSlotValue().

◆ LinkLobby_PollPeerReady()

s32 LinkLobby_PollPeerReady ( void )
static

◆ LinkLobby_PromptToParticipate()

s32 LinkLobby_PromptToParticipate ( void )
static

Prompts for participation unless entering battle or a prompt is still pending.

Retains the original handler's missing result on the message path.

Definition at line 269 of file lobby.c.

Referenced by LinkLobby_PromptToParticipate().

◆ LinkLobby_ReportDisconnection()

s32 LinkLobby_ReportDisconnection ( void )
static

Resets the disconnect trigger and displays the attendant's warning.

The original handler has no defined return value.

Definition at line 297 of file lobby.c.

Referenced by LinkLobby_ReportDisconnection().

◆ LinkLobby_ReceivePartyRecords()

s32 LinkLobby_ReceivePartyRecords ( void )
static

Receives three unit records and a recovery table; returns the occupied count or the original transfer failure.

All size checks observe fresh serial reads.

Definition at line 317 of file lobby.c.

Referenced by LinkLobby_ExchangePartyRecords(), and LinkLobby_ReceivePartyRecords().

◆ LinkLobby_CopyPartyOwnerIds()

s32 LinkLobby_CopyPartyOwnerIds ( u16 * ownerIds)
static

Copies at most three active owner IDs, terminates with 0xff, and returns count.

Passing a null destination only counts the entries.

Definition at line 441 of file lobby.c.

Referenced by LinkLobby_CopyPartyOwnerIds(), and LinkLobby_SendPartyRecords().

◆ LinkLobby_SendPartyRecords()

s32 LinkLobby_SendPartyRecords ( void )
static

Sends up to three active owners, pads missing records, then sends recovery data.

Returns zero on completion or the original serial failure.

Definition at line 477 of file lobby.c.

Referenced by LinkLobby_ExchangePartyRecords(), and LinkLobby_SendPartyRecords().

◆ LinkLobby_ExchangePartyRecords()

s32 LinkLobby_ExchangePartyRecords ( void )
static

Orders send/receive by link side and records the received owner count.

A failed exchange resets the transfer state.

Definition at line 616 of file lobby.c.

Referenced by LinkLobby_EnterBattle(), and LinkLobby_ExchangePartyRecords().

◆ LinkLobby_EnterBattle()

s32 LinkLobby_EnterBattle ( void )
static

Waits for the opponent, exchanges parties and starts the arena battle.

Disconnects restore the lobby callback and actor position; original returns have no defined status.

Definition at line 660 of file lobby.c.

Referenced by LinkLobby_EnterBattle().

◆ LinkLobby_ChooseBattleMode()

s32 LinkLobby_ChooseBattleMode ( void )
static

Offers a linked challenge or a monster battle and publishes the response.

Retains the original shared message tails and ignored return value.

Definition at line 796 of file lobby.c.

Referenced by LinkLobby_ChooseBattleMode().

◆ LinkLobby_ReportWinTallies()

s32 LinkLobby_ReportWinTallies ( s32 actor)
static

Reports total or consecutive linked wins according to the leader's facing.

Retains the original handler's missing return and event-end behavior.

Definition at line 896 of file lobby.c.

Referenced by LinkLobby_ReportWinTallies().

◆ LinkLobby_ChooseDebugPartyPreset()

s32 LinkLobby_ChooseDebugPartyPreset ( s32 actorId)
static

Selects a debug party preset; A accepts and B cancels.

The preset loader's nonzero result selects the unavailable-preset message.

Definition at line 934 of file lobby.c.

Referenced by LinkLobby_ChooseDebugPartyPreset().

◆ LinkLobby_OpenSanctum()

s32 LinkLobby_OpenSanctum ( s32 actorId)
static

Runs the sanctum service for this actor within an event.

Definition at line 993 of file lobby.c.

Referenced by LinkLobby_OpenSanctum().

◆ LinkLobby_PartyContains()

s32 LinkLobby_PartyContains ( s32 ownerId)
static

Tests the first three linked-battle owners, or four outside linked finals.

Definition at line 1003 of file lobby.c.

Referenced by LinkLobby_PartyContains(), LinkLobby_RunRoundResult(), and LinkLobby_TalkByProgress().

◆ State_NoOp()

UNUSED void State_NoOp ( void )
static

UNUSED: the original empty lobby callback.

Definition at line 1028 of file lobby.c.

Referenced by State_NoOp().

◆ LinkLobby_TalkByProgress()

s32 LinkLobby_TalkByProgress ( s32 actor)
static

Chooses each party member's dialogue from participation and round outcome.

Definition at line 1031 of file lobby.c.

Referenced by LinkLobby_TalkByProgress().

◆ LinkLobby_LeaveArena()

s32 LinkLobby_LeaveArena ( void )
static

Removes the link IRQ handlers, restores sound parameters and leaves the arena.

Definition at line 1069 of file lobby.c.

Referenced by LinkLobby_LeaveArena().

◆ LinkLobby_TalkToAttendant()

s32 LinkLobby_TalkToAttendant ( s32 actor)
static

Selects the attendant's rules or post-battle line from the round outcome.

Definition at line 1082 of file lobby.c.

Referenced by LinkLobby_TalkToAttendant().

◆ LinkLobby_ExplainPartyOrder()

s32 LinkLobby_ExplainPartyOrder ( s32 actor)
static

Alternates between the linked-party size and reorder instructions.

Definition at line 1111 of file lobby.c.

Referenced by LinkLobby_ExplainPartyOrder().

◆ LinkLobby_ReportMonsterRecord()

s32 LinkLobby_ReportMonsterRecord ( s32 actorId)
static

Reports the stored consecutive-monster-battle record when nonzero.

Definition at line 1135 of file lobby.c.

Referenced by LinkLobby_ReportMonsterRecord().

◆ LinkLobby_GetEvents()

u8 * LinkLobby_GetEvents ( void )

Definition at line 1154 of file lobby.c.

Referenced by LinkLobby_GetEvents().

◆ LinkLobby_SaveBattleResults()

s32 LinkLobby_SaveBattleResults ( void )
static

Shows saving/saved messages around the linked battle results save.

Definition at line 1157 of file lobby.c.

Referenced by LinkLobby_RunRoundResult(), and LinkLobby_SaveBattleResults().

◆ LinkLobby_SaveMonsterBattleResults()

s32 LinkLobby_SaveMonsterBattleResults ( void )
static

Shows saving/saved messages around the monster battle record save.

Definition at line 1179 of file lobby.c.

Referenced by LinkLobby_RunRoundResult(), and LinkLobby_SaveMonsterBattleResults().

◆ LinkLobby_DrawThreeDigitValue()

s32 LinkLobby_DrawThreeDigitValue ( s32 value)
static

Draws a right-to-left three-digit value capped at 999, then redraws the map.

Definition at line 1200 of file lobby.c.

Referenced by LinkLobby_DrawThreeDigitValue(), and LinkLobby_RunRoundResult().

◆ LinkLobby_RunRoundResult()

s32 LinkLobby_RunRoundResult ( void )

Processes the entry's monster/link result and restores lobby polling.

Returns zero after updating records, messages and party recovery.

Definition at line 1217 of file lobby.c.

Referenced by LinkLobby_RunRoundResult().

Variable Documentation

◆ gLinkLobby_SlotValues

const s32 gLinkLobby_SlotValues[]
Initial value:
= {
PEER_TAG('S', 'G', 'M', 'C'),
PEER_TAG('0', '1', '2', '3'), PEER_TAG('A', 'B', 'C', '1'),
PEER_TAG('C', 'D', 'E', '2'), PEER_TAG('E', 'F', 'G', '3'),
}
#define PEER_TAG(a, b, c, d)
Definition lobby.c:68

Definition at line 71 of file lobby.c.

Referenced by LinkLobby_PeerSlotMatches(), and LinkLobby_WriteSlotValue().

◆ sLinkLobbyWaitFrames

s32 sLinkLobbyWaitFrames
static

Definition at line 109 of file lobby.c.

Referenced by LinkLobby_PollPeerReady(), and LinkLobby_RunRoundResult().

◆ gLinkLobbyCallFrames

u32 gLinkLobbyCallFrames

Definition at line 265 of file lobby.c.

Referenced by LinkLobby_PromptToParticipate(), and LinkLobby_RunRoundResult().

◆ gLinkLobby_SlotColumns

u8 gLinkLobby_SlotColumns[]
Initial value:
= {
0, 1, 1, 1, 1, 0, 0, 0,
}

Definition at line 1406 of file lobby.c.

Referenced by LinkLobby_PeerSlotMatches(), and LinkLobby_WriteSlotValue().

◆ gLinkLobbyEntrances

struct SceneEntrance gLinkLobbyEntrances[]
Initial value:
= {
{ 11, CONDITION_ALWAYS, 128, 0, 164, FACING_NORTH, 0, 16, 0, 416, 310, 0 },
{ 10, CONDITION_ALWAYS, 352, 0, 148, FACING_NORTH, 0, 16, 0, 416, 310, 0 },
{ 8, CONDITION_ALWAYS, 216, 0, 200, FACING_WEST, 0, 16, 0, 416, 310, 0 },
{ 9, CONDITION_ALWAYS, 216, 0, 200, FACING_WEST, 0, 16, 0, 416, 310, 0 },
{ 1, CONDITION_ALWAYS, 216, 0, 288, FACING_NORTH, 0, 16, 0, 416, 310, 0 },
{ 0, CONDITION_ALWAYS, 216, 0, 208, FACING_NORTH, 0, -1, -1, -1, -1, 0 },
}
@ SCENE_TABLE_END
Definition field_scene.h:43
@ CONDITION_ALWAYS
Definition field_scene.h:44
@ FACING_NORTH
Definition field_scene.h:32
@ FACING_WEST
Definition field_scene.h:30

Definition at line 1410 of file lobby.c.

Referenced by LinkLobby_GetEntrances().

◆ gLinkLobbyExits

u32 gLinkLobbyExits[]
Initial value:
= {
}
#define SCENE_EXITS(scene)
Definition field_scene.h:72

Definition at line 1420 of file lobby.c.

Referenced by LinkLobby_GetExits().

◆ gLinkLobbyPlacements

struct ScenePlacement gLinkLobbyPlacements[]

Definition at line 1424 of file lobby.c.

Referenced by LinkLobby_SelectPlacements().

◆ gLinkLobbyBattlePlacements

struct ScenePlacement gLinkLobbyBattlePlacements[]

Definition at line 1470 of file lobby.c.

Referenced by LinkLobby_SelectPlacements().

◆ gLinkLobbyEvents

struct SceneEvent gLinkLobbyEvents[]

Definition at line 1517 of file lobby.c.

Referenced by LinkLobby_GetEvents().