Skip to content
🌋️
Alchemy
Theme: Weyard
Theme: Modern
Mode: Auto
Mode: Light
Mode: Dark
Alchemy
Source
Reference
Loading...
Searching...
No Matches
speakers.c
Go to the documentation of this file.
1
/// @file
2
/// Speaker definitions: portraits and idle lines by sprite.
3
/// Part of object.c, the field object, compiled only through it.
4
5
#include "
../object_internal.h
"
6
7
/// Returns the speaker definition of sprite id from gBattleFx_DefinitionTable,
8
/// or its last entry when there is none. The search stops after 0x82 entries,
9
/// all but the table's last of its 131.
10
struct
BattleEffectEntry
*
BattleFx_FindDefinition
(
u32
id
) {
11
struct
BattleEffectEntry
*entry =
gBattleFx_DefinitionTable
;
12
u32
definitionIndex = 0;
13
14
if
(entry->
id
!=
id
) {
15
do
{
16
definitionIndex += 1;
17
entry++;
18
if
(definitionIndex > 0x81)
19
break
;
20
}
while
(entry->
id
!=
id
);
21
}
22
return
entry;
23
}
24
25
/// Returns the sprite id stored by a live actor's animated sprite, or 0 when
26
/// that actor has no animated sprite or its sprite-id pointer is absent.
27
s32
BattleFx_GetAnimationValue
(
s32
id
) {
28
struct
BattleRenderObject
*
object
=
ObjectTable_Get
(
id
);
29
30
if
(object->
kind
!= 1 || object->
animation
==
NULL
||
31
object->
animation
->
value28
==
NULL
) {
32
return
0;
33
}
34
return
*
object
->animation->value28;
35
}
36
37
/// Returns the portrait shown beside the messages of sprite id (0x100 plus
38
/// its definition's value), or 0 with no portrait or with gGameState.speech
39
/// off.
40
s32
BattleFx_GetResourceId
(
u32
id
) {
41
u8
portraitId;
42
43
if
(
gGameState
.
speech
== 0 ||
44
(portraitId =
BattleFx_FindDefinition
(
id
)->value) == 0xFF) {
45
return
0;
46
}
47
return
portraitId + 0x100;
48
}
49
50
/// Returns the definition flags of actor id's sprite, which choose its line
51
/// when it has nothing to say.
52
s32
BattleFx_GetFlags
(
s32
id
) {
53
return
BattleFx_FindDefinition
(
BattleFx_GetAnimationValue
(
id
))->
flags
;
54
}
ObjectTable_Get
void * ObjectTable_Get(u32 actorIndex)
Returns the actor in slot index (0 to 65), or NULL.
Definition
actors.c:462
gBattleFx_DefinitionTable
const struct BattleEffectEntry gBattleFx_DefinitionTable[131]
Speaker definitions: {sprite, portrait (0xff for none), idle line flags}.
Definition
fxdata.c:163
gGameState
struct GameState gGameState
object_internal.h
What every part of object.c shares: its includes and the macros and types more than one part uses.
BattleFx_GetAnimationValue
s32 BattleFx_GetAnimationValue(s32 id)
Returns the sprite id stored by a live actor's animated sprite, or 0 when that actor has no animated ...
Definition
speakers.c:27
BattleFx_GetResourceId
s32 BattleFx_GetResourceId(u32 id)
Returns the portrait shown beside the messages of sprite id (0x100 plus its definition's value),...
Definition
speakers.c:40
BattleFx_FindDefinition
struct BattleEffectEntry * BattleFx_FindDefinition(u32 id)
Returns the speaker definition of sprite id from gBattleFx_DefinitionTable, or its last entry when th...
Definition
speakers.c:10
BattleFx_GetFlags
s32 BattleFx_GetFlags(s32 id)
Returns the definition flags of actor id's sprite, which choose its line when it has nothing to say.
Definition
speakers.c:52
NULL
#define NULL
Definition
bilibin.h:6
BattleAnimationState::value28
s16 * value28
Definition
battle_effect_runtime.h:17
BattleEffectEntry
A speaker definition, a row of gBattleFx_DefinitionTable: a sprite, its portrait (0xff for none) and ...
Definition
battle_effect_runtime.h:39
BattleEffectEntry::id
u16 id
Definition
battle_effect_runtime.h:40
BattleEffectEntry::flags
u8 flags
Definition
battle_effect_runtime.h:42
BattleRenderObject
A field actor as the speaker lookup reads it: its kind (1 for an animated sprite) and that sprite.
Definition
battle_effect_runtime.h:22
BattleRenderObject::animation
struct BattleAnimationState * animation
Definition
battle_effect_runtime.h:33
BattleRenderObject::kind
u8 kind
Definition
battle_effect_runtime.h:34
GameState::speech
u8 speech
1 shows speakers' portraits beside their messages
Definition
game_state.h:64
s32
signed int s32
Definition
types.h:14
u32
unsigned int u32
Definition
types.h:15
u8
unsigned char u8
Definition
types.h:11
src
object
object
speakers.c