Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
wstag949.c
Go to the documentation of this file.
1/*
2 * WSTAG949: Protocol Ruins, East Sector, in the extra chapter. The European
3 * version's: in its extra chapter (STORY_EXTRA), mode 661 starts it instead of
4 * WSTAG376.
5 */
6
7#include "common.h"
8#include "field/stage.h"
9/* Defined below, after the code that uses them */
10extern Vec2 farSpriteSpots[];
11
12#if VERSION_EU
13#define STAGE_TEXT TEXT_FILE(TEXT_TALKS_09)
14#define STAGE_FILE 0x919
15#define STAGE_FILE_8 0x1BE
16#elif VERSION_JP
17#define STAGE_TEXT 0x89B
18#define STAGE_FILE 0x8EC
19#define STAGE_FILE_8 0x1B0
20#endif
21
22/* Draws the 36 sprites of STAGE_FILE at their places, scrolling at 1/8 of the layer */
24 SpriteDrawer drawer;
25 s32 pos[2];
26 s32 scroll[2];
27 Layer *layer;
28 s32 i;
29
30 switch (task->state) {
31 case TASK_INIT:
32 default:
33 task->nextState(task);
34 break;
35 case TASK_RUN:
36 initSpriteDrawer(&drawer);
37 drawer.setLayerId(FIELD_LAYER_MAP, 0xC);
38 drawer.setTexture(0x140, 0x100);
39 drawer.setAltClut(0, 0x1F0);
41 layer->getScroll(layer, scroll);
42 pos[0] = (scroll[0] - 0x2C0) >> 3;
43 pos[1] = (scroll[1] - 0x280) >> 3;
44 for (i = 0; i < 0x24; i++) {
45 drawer.draw(FILE_CACHE.getEntry(STAGE_FILE << 16), 0, farSpriteSpots[i].x + pos[0], farSpriteSpots[i].y + pos[1]);
46 }
47 break;
48 case TASK_DONE:
49 case TASK_KILL:
50 break;
51 }
52}
53
55
56/* The stage task: creates the far sprites (updateFarSprites) */
57void updateStage(StageTask *task, void **children) {
58 switch (task->state) {
59 case TASK_INIT:
60 default:
61 children[0] = createFarSprites();
62 task->nextState(task);
63 break;
64 case TASK_RUN:
65 case TASK_DONE:
66 case TASK_KILL:
67 break;
68 }
69}
70
71#define STAGE_CHILDREN_SIZE 0x8
73
74const CVECTOR stageColor = { 0x80, 0x80, 0x80, 0x00 };
75/* Sets the stage up: its map, actors, battles and events, playing PYRA_BGM */
98
100 { 596, 399 }, { 809, 564 }, { 820, 832 }, { 1143, 1009 },
101 { 738, 1035 }, { 416, 1055 }, { 36, 28 }, { 140, 0 },
102 { 178, 159 }, { 218, 202 }, { 186, 242 }, { 299, 93 },
103 { 418, 16 }, { 440, 329 }, { 476, 369 }, { 725, 82 },
104 { 1137, 24 }, { 1213, 103 }, { 1281, 147 }, { 1349, 48 },
105 { 669, 632 }, { 491, 796 }, { 661, 889 }, { 624, 926 },
106 { 998, 634 }, { 1026, 648 }, { 890, 940 }, { 915, 959 },
107 { 826, 1119 }, { 1028, 1089 }, { 1227, 1002 }, { 1306, 861 },
108 { 498, 1190 }, { 146, 569 }, { 187, 590 }, { 394, 616 },
109};
111 { 0x200, 0x100, 0x21C, 0x1A6, 0x70, 0xA6, 0x230, 0x1FE },
112 { 0x200, 0x100, 0x200, 0x100, 0, 0, 0x220, 0x1FE },
113 { 0x200, 0x100, 0x216, 0x138, 0x58, 0x38, 0x200, 0x1FD },
114 { 0x200, 0x100, 0x208, 0x1BC, 0x20, 0xBC, 0x210, 0x1FD },
115 { 0x200, 0x100, 0x210, 0x1BC, 0x40, 0xBC, 0x220, 0x1FD },
116 { 0x200, 0x100, 0x200, 0x1BC, 0, 0xBC, 0x230, 0x1FD },
117 { 0x140, 0x100, 0x16A, 0x100, 0xA8, 0, 0x140, 0x1FF },
118 { 0x140, 0x100, 0x15A, 0x100, 0x68, 0, 0x150, 0x1FF },
119 { 0x140, 0x100, 0x150, 0x100, 0x40, 0, 0x160, 0x1FF },
120 { 0x140, 0x100, 0x162, 0x100, 0x88, 0, 0x170, 0x1FF },
121};
161 { NULL, NULL, 0x39 },
162 { NULL, NULL, 0 },
163};
172 { NULL, actor2Talk0Actions, 0x87 },
173 { NULL, NULL, 0 },
174};
176 { actor3Talk0Conditions, NULL, 0x81 },
178 { actor3Talk2Conditions, NULL, 0x83 },
179 { NULL, NULL, 0 },
180};
182 { actor4Talk0Conditions, NULL, 0x84 },
184 { actor4Talk2Conditions, NULL, 0x86 },
185 { NULL, NULL, 0 },
186};
187u16 actor0Conditions[] = { ITEM(0, 0x192), 0, CODES_END };
188u16 actor1Conditions[] = { ITEM(0, 0x192), 1, CODES_END };
191FieldActorEntry actor2 = { NULL, actor2Talks, 0x3D, 5, 97, 242, 1 };
192FieldActorEntry actor3 = { NULL, actor3Talks, 0x90, 6, 1073, 145, 1 };
193FieldActorEntry actor4 = { NULL, actor4Talks, 0x91, 7, 520, 220, 7 };
195 &actor0,
196 &actor1,
197 &actor2,
198 &actor3,
199 &actor4,
200 NULL,
201};
203 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
204};
206 { { { CODES_END, 0 }, { CODES_END, 0 } }, SLOT_EXIT, 0x294, 0x510, 0x88, 1, 0, 0, 0 },
207 { { { CODES_END, 0 }, { CODES_END, 0 } }, SLOT_DEPTH, 8, 0, 0, 0, 0, 0, 0 },
208 { { { CODES_END, 0 }, { CODES_END, 0 } }, SLOT_DEPTH, 4, 0, 0, 0, 0, 0, 0 },
209 { { { CODES_END, 0 }, { CODES_END, 0 } }, SLOT_MAP, 1, 0, 0, 0, 0, 0, 0 },
210 { { { CODES_END, 0 }, { CODES_END, 0 } }, SLOT_MAP, 0, 0, 0, 0, 0, 0, 0 },
211 { { { CODES_END, 0 }, { CODES_END, 0 } }, SLOT_DROP, 6, 0, 0, 0, 0, 0, 0 },
212 { { { CODES_END, 0 }, { CODES_END, 0 } }, SLOT_DROP, 5, 0, 0, 0, 0, 0, 0 },
213 { { { CODES_END, 0 }, { CODES_END, 0 } }, SLOT_CLIMB_UP, 9, 0x7E, 0x1AF, 0, 0, 0, 0 },
214 { { { CODES_END, 0 }, { CODES_END, 0 } }, SLOT_CLIMB_DOWN, 9, 0x6D, 0x117, 0, 0, 0, 0 },
215 { { { CODES_END, 0 }, { CODES_END, 0 } }, 0, 0, 0, 0, 0, 0, 0, 0 },
216};
217void (*stageFuncs[])(void) = {
219};
221 { 9000, NULL, 0, FIELDSTG_startEventBattle5, NULL },
222 { -1, NULL, 0, NULL, NULL },
223};
237AreaBattle area1Battle0 = { 0, 0, MUSIC(1, 0) };
238AreaBattle area1Battle1 = { 0, 0, MUSIC(1, 0) };
239AreaBattle area1Battle2 = { 0, 0, MUSIC(1, 0) };
240AreaBattle area1Battle3 = { 0, 0, MUSIC(1, 0) };
241AreaBattle area1Battle4 = { 0, 0, MUSIC(1, 0) };
242AreaBattle area1Battle5 = { 0, 0, MUSIC(1, 0) };
243AreaBattle area1Battle6 = { 0, 0, MUSIC(1, 0) };
244AreaBattle area1Battle7 = { 0, 0, MUSIC(1, 0) };
250AreaBattle area2Battle0 = { 0, 0, MUSIC(1, 0) };
251AreaBattle area2Battle1 = { 0, 0, MUSIC(1, 0) };
252AreaBattle area2Battle2 = { 0, 0, MUSIC(1, 0) };
253AreaBattle area2Battle3 = { 0, 0, MUSIC(1, 0) };
254AreaBattle area2Battle4 = { 0, 0, MUSIC(1, 0) };
255AreaBattle area2Battle5 = { 0, 0, MUSIC(1, 0) };
256AreaBattle area2Battle6 = { 0, 0, MUSIC(1, 0) };
257AreaBattle area2Battle7 = { 0, 0, MUSIC(1, 0) };
265AreaBattle area3Battle2 = { 0, 0, MUSIC(1, 0) };
266AreaBattle area3Battle3 = { 0, 0, MUSIC(1, 0) };
267AreaBattle area3Battle4 = { 0, 0, MUSIC(1, 0) };
268AreaBattle area3Battle5 = { 0, 0, MUSIC(1, 0) };
269AreaBattle area3Battle6 = { 0, 0, MUSIC(1, 0) };
270AreaBattle area3Battle7 = { 0, 0, MUSIC(1, 0) };
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
unsigned short u16
Definition common.h:10
void * createFarSprites(void)
Creates the updateFarSprites task.
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
#define TASK_RUN
Definition task.h:35
#define TASK_KILL
Definition task.h:37
#define TASK_INIT
Tasks: every game object is a task, a heap block that starts with this header and is updated once per...
Definition task.h:34
#define TASK_DONE
Definition task.h:36
The stage overlays (AAA/PRO/WSTAG###.PRO), loaded at 0x800A4CA4 on top of FIELDSTG.
void updateStage()
The names every stage defines, each its own (config/<version>/stages/<stage>.txt).
void * FIELDSTG_startEventBattle5(void)
Starts battle 5 of the fourth area: the end of the stages' events 9000.
Definition field.c:1010
#define SLOT_CLIMB_UP
Definition field_map.h:256
#define SLOT_DEPTH
the player's depth, arg
Definition field_map.h:259
#define FIELD_LAYER_MAP
the map, its objects and characters, and the menus
Definition field_map.h:20
#define SLOT_MAP
the map the player is on, arg (FieldMap.setMap)
Definition field_map.h:260
#define FIELD_MAP_FLOOR0
Some of FieldMap's maps (files): those of the floors the player walks on come first,...
Definition field_map.h:85
#define SLOT_CLIMB_DOWN
Definition field_map.h:257
#define FIELD_MAP_FLOOR1
Definition field_map.h:86
#define SLOT_EXIT
The kinds of StageSlot (type).
Definition field_map.h:255
#define FIELD_MAP_AREAS
a cell's value: its battle area (FieldBattles), or 0
Definition field_map.h:87
#define FIELD_MAP_TRIGGERS
a cell's value: a direction (3 bits) and a StageSlot (5)
Definition field_map.h:88
#define SLOT_DROP
Definition field_map.h:258
FieldMap FIELDSTG_map
Definition fieldstg.c:3660
FieldState FIELDSTG_state
Definition fieldstg.c:2641
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
#define EVENT_BATTLE(id)
action: FIELDSTG_battleFuncs.startEventBattle
Definition game_state.h:72
#define CODES_END
Definition game_state.h:83
#define ITEM(kind, id)
an item, in the bag or equipped; kind (bits 9-11) isn't read, and the scripts set it after the item's...
Definition game_state.h:80
#define FLAG(group, id)
The codes of the (code, value) pairs that FLAGS_00 checks as conditions and applies as actions (event...
Definition game_state.h:68
#define CARD_BATTLE(opponent, kind)
action: startCardBattle
Definition game_state.h:73
#define MUSIC_BATTLE
BATL0000: the maps' random battles (AreaBattle, nearly all of them)
Definition sound.h:76
#define MUSIC_PROTOCOL_RUINS
PYRA_BGM: the Protocol Ruins.
Definition sound.h:85
#define MUSIC(bank, n)
A field's or a battle's music (FieldState.music, Battle.music): track (SEP) n of the first sequence o...
Definition sound.h:70
#define MUSIC_BANK(music)
The sound bank of a music, which a stage loads for it (FieldState.soundBank)
Definition sound.h:148
#define MUSIC_BOSS_1
BOSS_001: the Digimon Arena's, the cities', the dungeons' and the A.o.A's boss battles.
Definition sound.h:109
void initSpriteDrawer(SpriteDrawer *obj)
Clears a sprite drawer to neutral (no scale, gray tint, follows the scroll), gives it its methods and...
FIELDSTG's start of the stage (StageEntry.init in FIELDSTG_stages): the stage's task,...
#define SPECIAL_HAS_FIVE_EPIC_ITEMS
the European and Japanese versions: the player has the Muramasa, Super Nova, Punishment,...
Definition story.h:1678
#define FLAG_CARD_BATTLE_WON
set by updateModeFlags on the way back from a card battle: 1 if the player won it (FLAGS_00....
Definition story.h:166
#define FLAG_ZHU_QUE_LEADER_FOUGHT
wstag949 (extra chapter): the Zhu Que Leader sees the 5 strongest Epic Items and starts a battle; set...
Definition story.h:968
#define FLAG_BAI_HU_LEADER_FOUGHT
wstag949 (extra chapter): the Bai Hu Leader sees the 5 strongest Epic Items and starts a battle; set ...
Definition story.h:971
#define FLAG_CARD_BATTLE_ENDED
set by updateModeFlags on the way back from a card battle; the talks that follow one test it and clea...
Definition story.h:169
Where an actor's frames go in VRAM: one of the records after the FieldImage (Actor....
Definition field_map.h:114
A battle of an area's BattleList, which can start on the field (see FIELDSTG_startEncounter); FIGHTST...
Definition field_map.h:402
The battles of an area of the map (its cells' value at FieldMap.files[4]), one picked at random.
Definition field_map.h:411
A character of the field (FieldState.actors, a list of pointers up to NULL), which FIELDSTG_updateFie...
Definition field_map.h:194
The battles of a place (FieldState.battles), by area of the map: the fourth area's are also the ones ...
Definition field_map.h:422
An event of the table FieldState.events, up to the first id -1, which FIELDSTG_startEvent starts.
Definition field_map.h:141
void(* setFile)(s32 index, s32 file)
FIELDSTG_setMapFile.
Definition field_map.h:100
void(* setFirstMap)(s32 index)
FIELDSTG_setFirstMap: the map the player starts on (GAME.mapIndex), when the mode is new.
Definition field_map.h:104
s32 sheetEntry
the stage's sprite sheet, loaded before the field starts, or 0
Definition field_map.h:445
FieldEvent * events
up to the first id -1
Definition field_map.h:451
s32 soundBank
SOUND.loadBank's, or 0.
Definition field_map.h:459
StageTile * objects
the map objects, up to the first margin 0
Definition field_map.h:446
s32 imageFile
or an image archive file, or 0
Definition field_map.h:449
FieldBattles * battles
Definition field_map.h:450
Vec2 start
where the player starts
Definition field_map.h:456
StageSlot * slots
up to the first type 0
Definition field_map.h:447
ActorImage * actors
then the actors', from actors[2]
Definition field_map.h:454
s32 mapFile
the file of the map's tiles (FIELDSTG_createMapStreamer)
Definition field_map.h:444
s32 startDir
and its direction
Definition field_map.h:457
CVECTOR spriteColor
the field's sprites' color, unless cd is 0
Definition field_map.h:458
s32 textFile
the stage's text file, for the talks
Definition field_map.h:461
union FieldState::@12 images
s32 music
SOUND.playSound's, or 0.
Definition field_map.h:460
What a character says (FIELDSTG_runActorAction): the first whose conditions hold, or the last,...
Definition field_map.h:176
void *(* getEntry)(u32 fileAndIndex)
Definition file.h:96
struct Layer *(* getLayer)(s32 id)
Definition gfx.h:28
GfxFuncs funcs
Definition gfx.h:77
A drawing layer (GFX.funcs.createLayer): a DRAWENV with a pair of ordering tables,...
Definition gfx.h:128
void(* getScroll)()
Definition gfx.h:148
Draws sprites from a sprite sheet (such as file 0x277, the menu graphics): a sheet has a table of fra...
Definition gfx.h:223
void(* setAltClut)()
(x, y)
Definition gfx.h:243
void(* setLayerId)()
(id, depth)
Definition gfx.h:244
void(* draw)()
(sheet, frame, x, y)
Definition gfx.h:246
void(* setTexture)()
(x, y)
Definition gfx.h:242
What the player can trigger on a map (FIELDSTG_updateTriggers): a record of the table at FieldState....
Definition field_map.h:276
The task a stage starts (startStage), updated by its updateStage.
Definition stage.h:26
void(* nextState)(struct StageTask *task)
Definition stage.h:27
s32 state
Definition stage.h:27
An object of a map, which FIELDSTG draws: a record of the table at FieldState.objects,...
Definition field_map.h:208
Definition gfx.h:352
s32 y
Definition gfx.h:354
s32 x
Definition gfx.h:353
u16 actor1Conditions[]
Definition wstag949.c:188
AreaBattle area2Battle7
Definition wstag949.c:257
FieldActorEntry actor0
Definition wstag949.c:189
void(* stageFuncs[])(void)
The stage's functions (common/start_stage.inc.c calls the first): a StageFuncs in the stages with a t...
Definition wstag949.c:217
FieldTalk actor2Talks[]
Definition wstag949.c:171
AreaBattle area2Battle6
Definition wstag949.c:256
u16 actor4Talk1Actions[]
Definition wstag949.c:154
Vec2 farSpriteSpots[]
Defined below, after the code that uses them.
Definition wstag949.c:99
AreaBattle area1Battle6
Definition wstag949.c:243
u16 actor1Talk3Actions[]
Definition wstag949.c:134
u16 actor1Talk2Actions[]
Definition wstag949.c:132
u16 actor1Talk1Conditions[]
Definition wstag949.c:124
AreaBattle area0Battle7
Definition wstag949.c:231
FieldActorEntry actor2
Definition wstag949.c:191
const CVECTOR stageColor
the color the setup copies to FIELDSTG_state.spriteColor
Definition wstag949.c:74
u16 actor3Talk0Conditions[]
Definition wstag949.c:136
#define STAGE_FILE_8
Definition wstag949.c:15
AreaBattle area3Battle4
Definition wstag949.c:267
AreaBattle area3Battle3
Definition wstag949.c:266
AreaBattle area0Battle1
Definition wstag949.c:225
AreaBattle area2Battle0
Definition wstag949.c:250
FieldActorEntry * stageActors[]
Definition wstag949.c:194
AreaBattle area1Battle2
Definition wstag949.c:239
AreaBattle area3Battle0
Definition wstag949.c:263
u16 actor4Talk1Conditions[]
Definition wstag949.c:149
AreaBattle area0Battle6
Definition wstag949.c:230
FieldTalk actor1Talks[]
Definition wstag949.c:164
AreaBattle area3Battle2
Definition wstag949.c:265
u16 actor1Talk0Conditions[]
Definition wstag949.c:122
FieldTalk actor0Talks[]
Definition wstag949.c:160
AreaBattle area3Battle1
Definition wstag949.c:264
AreaBattle area0Battle3
Definition wstag949.c:227
u16 actor3Talk2Conditions[]
Definition wstag949.c:143
u16 actor3Talk1Conditions[]
Definition wstag949.c:137
u16 actor2Talk0Actions[]
Definition wstag949.c:135
FieldTalk actor4Talks[]
Definition wstag949.c:181
FieldActorEntry actor4
Definition wstag949.c:193
AreaBattle area3Battle6
Definition wstag949.c:269
ActorImage stageImages[]
Definition wstag949.c:110
u16 actor1Talk1Actions[]
Definition wstag949.c:125
void setupStage(void)
Sets the stage up: its map, actors, battles and events, playing PYRA_BGM.
Definition wstag949.c:76
AreaBattle area2Battle4
Definition wstag949.c:254
u16 actor4Talk0Conditions[]
Definition wstag949.c:148
StageTile stageObjects[]
The tables and color setupStage gives FIELDSTG_state (FieldState)
Definition wstag949.c:202
FieldTalk actor3Talks[]
Definition wstag949.c:175
u16 actor3Talk1Actions[]
Definition wstag949.c:142
BattleList area3Battles
Definition wstag949.c:271
AreaBattle area3Battle5
Definition wstag949.c:268
AreaBattle area0Battle5
Definition wstag949.c:229
BattleList area1Battles
Definition wstag949.c:245
BattleList area2Battles
Definition wstag949.c:258
AreaBattle area1Battle4
Definition wstag949.c:241
AreaBattle area2Battle2
Definition wstag949.c:252
AreaBattle area1Battle5
Definition wstag949.c:242
StageSlot stageSlots[]
Definition wstag949.c:205
AreaBattle area2Battle1
Definition wstag949.c:251
u16 actor1Talk0Actions[]
Definition wstag949.c:123
AreaBattle area1Battle3
Definition wstag949.c:240
AreaBattle area1Battle0
Definition wstag949.c:237
u16 actor1Talk2Conditions[]
Definition wstag949.c:131
FieldActorEntry actor1
Definition wstag949.c:190
void updateFarSprites(StageTask *task)
Draws the 36 sprites of STAGE_FILE at their places, scrolling at 1/8 of the layer.
Definition wstag949.c:23
AreaBattle area0Battle0
Definition wstag949.c:224
AreaBattle area0Battle2
Definition wstag949.c:226
#define STAGE_FILE
Definition wstag949.c:14
AreaBattle area2Battle5
Definition wstag949.c:255
AreaBattle area1Battle1
Definition wstag949.c:238
AreaBattle area2Battle3
Definition wstag949.c:253
AreaBattle area0Battle4
Definition wstag949.c:228
#define STAGE_TEXT
Definition wstag949.c:13
AreaBattle area3Battle7
Definition wstag949.c:270
BattleList area0Battles
Definition wstag949.c:232
AreaBattle area1Battle7
Definition wstag949.c:244
u16 actor4Talk2Conditions[]
Definition wstag949.c:155
FieldActorEntry actor3
Definition wstag949.c:192
FieldBattles stageBattles[]
Definition wstag949.c:276
FieldEvent stageEvents[]
Definition wstag949.c:220
u16 actor1Talk3Conditions[]
Definition wstag949.c:133
u16 actor0Conditions[]
Definition wstag949.c:187