Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
fighter_info.c
Go to the documentation of this file.
1/* FIGHTSTG's fighter data, loaded into FIGHTSTG_fighterCache. */
2
4
5/* The part of the fighters' file at an offset from its start */
6static inline void *getFightersPart(FightersFile *file, s32 offset) {
7 return (u8 *)file + offset;
8}
9
10/* the match depends on reaching the cache through the symbol until a fighter
11 is found, and on each branch storing and returning its own info */
13 FightersFile *file;
14 FighterEntry *entry;
15 FighterInfo *partners;
16 FighterInfoEnemy *enemies;
17 FighterCache *cache;
18 FighterInfo *info;
19 s32 i;
20
21 if (id == FIGHTSTG_fighterCache.id) {
24 }
26 }
28 entry = getFightersPart(file, file->entries);
29 partners = getFightersPart(file, file->partners);
30 enemies = getFightersPart(file, file->enemies);
31 while (entry->id != 0) {
32 if (entry->id == id) {
34 cache = &FIGHTSTG_fighterCache;
35 cache->index = i = entry->index;
36 cache->kind = entry->kind;
37 cache->isEnemy = entry->kind >= 0x3A;
38 if (cache->isEnemy) {
39 info = (FighterInfo *)&enemies[i];
40 cache->partnerInfo = info;
41 cache->enemyInfo = info;
42 return info;
43 } else {
44 info = &partners[i];
45 cache->partnerInfo = info;
46 cache->enemyInfo = info;
47 return info;
48 }
49 }
50 entry++;
51 }
52 return NULL;
53}
54
55/* Loads entry index of the fighters file into FIGHTSTG_fighterCache: its id
56 and kind, and its info, an enemy's from kind 0x3A on or else a partner's */
59 FighterEntry *entries = getFightersPart(file, file->entries);
60 FighterInfo *partners = getFightersPart(file, file->partners);
61 FighterInfoEnemy *enemies = getFightersPart(file, file->enemies);
62 FighterEntry *entry = &entries[index];
63 FighterInfo *info;
64 s32 i;
66
67 cache->id = entry->id;
68 cache->index = i = entry->index;
69 cache->kind = entry->kind;
70 cache->isEnemy = entry->kind >= 0x3A;
71 if (cache->isEnemy == 0) {
72 info = &partners[i];
73 } else {
74 info = (FighterInfo *)&enemies[i];
75 }
76 cache->partnerInfo = info;
77 cache->enemyInfo = info;
78}
79
80/* Fighter id's face parts (FaceRect), in the fighters file */
83
84 /* face assumes the file is at base: move it to where the file is */
85 return (FaceRect *)(FIGHTSTG_getFighterInfo(id)->face - file->base + (s32)file);
86}
87
88/* The first and last entries of the fighters file that are enemies (enemy
89 set) or partners */
90void FIGHTSTG_getFighterRange(u32 enemy, s32 *min, s32 *max) {
92 FighterEntry *entry = getFightersPart(file, file->entries);
93 s32 lo = 0xFF;
94 s32 hi = 0;
95 s32 i = 0;
96
97 while (entry->id != 0) {
98 if ((entry->kind >= 0x3A) == enemy) {
99 if (i < lo) {
100 lo = i;
101 }
102 if (hi < i) {
103 hi = i;
104 }
105 }
106 entry++;
107 i++;
108 }
109 *min = lo;
110 *max = hi;
111}
FighterCache FIGHTSTG_fighterCache
the fighters' data, loaded one at a time
Definition battle.c:21
FIGHTSTG.PRO: the battle.
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
unsigned int u32
Definition common.h:12
unsigned char u8
Definition common.h:8
void FIGHTSTG_cacheFighter(s32 index)
Loads entry index of the fighters file into FIGHTSTG_fighterCache: its id and kind,...
FaceRect * FIGHTSTG_getFighterFace(s32 id)
Fighter id's face parts (FaceRect), in the fighters file.
static void * getFightersPart(FightersFile *file, s32 offset)
The part of the fighters' file at an offset from its start.
Definition fighter_info.c:6
FighterInfo * FIGHTSTG_getFighterInfo(s32 id)
the match depends on reaching the cache through the symbol until a fighter is found,...
void FIGHTSTG_getFighterRange(u32 enemy, s32 *min, s32 *max)
The first and last entries of the fighters file that are enemies (enemy set) or partners.
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
#define FILE_FIGHTERS
The fighters' file, which FIGHTSTG_fighterCache.funcs reads.
Definition model.h:189
A part of a fighter's face (its eyes, then up to 14 more) and where its three frames are in its textu...
Definition model.h:298
FIGHTSTG_fighterCache: the last fighter getInfo found, and the fighters' file's functions.
Definition model.h:265
s32 isEnemy
the kind is 0x3A or more
Definition model.h:267
FighterInfo * enemyInfo
Definition model.h:271
s32 index
in the partners' or the enemies' table
Definition model.h:268
FighterInfo * partnerInfo
both hold the info found, read by isEnemy
Definition model.h:270
An entry of the fighters' file's list.
Definition model.h:210
u8 kind
0x3A and up: an enemy
Definition model.h:213
u8 index
in the partners' or the enemies' table
Definition model.h:212
An enemy's FighterInfo: it has 3 cameras where a partner has 12.
Definition model.h:242
A fighter's entry in its file, from FIGHTSTG_fighterCache.funcs.getInfo.
Definition model.h:225
s32 face
its FaceRects: an offset in the fighters' file
Definition model.h:229
The fighters' file: offsets from its start.
Definition model.h:217
s32 enemies
FighterInfoEnemy.
Definition model.h:221
s32 base
the address FighterInfo.face assumes the file is at
Definition model.h:218
s32 partners
FighterInfo.
Definition model.h:220
s32 entries
FighterEntry, up to an id 0.
Definition model.h:219
void *(* load)(u32 file)
Definition file.h:92