Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
actor_control.c
Go to the documentation of this file.
1/* An actor's moves, controls, methods, drawing and actions. One file: each
2 of the jump tables of these functions starts right where the one
3 before ends, 4 bytes past a multiple of 8, so a new object between
4 them would move the next one's table. */
5
6#include "field/field_mode.h"
7
8/* Whether a flying actor runs into the map at an offset from it: a cell that
9 isn't free, a wall higher than it or a ceiling lower than it (FLIGHT_WALL,
10 FLIGHT_CEILING); then it steps back by offset */
12 s32 blocked = 0;
13 Vec2 pos;
14 u8 cell;
15
16 pos.x = (actor->pos.x >> 8) + x;
17 pos.y = (actor->pos.y >> 8) + y;
18 cell = FIELDSTG_map.isTileFree(&pos);
19 if (cell != 0) {
20 cell = FIELDSTG_map.getCell(GAME.mapIndex, &pos);
21 }
22 if (actor->z != 0 && cell != FLIGHT_OPEN) {
23 switch (cell) {
24 case FLIGHT_WALL(2):
25 if (actor->z < FLIGHT_LEVEL(2)) {
26 cell = 0;
27 }
28 break;
29 case FLIGHT_WALL(3):
30 if (actor->z < FLIGHT_LEVEL(3)) {
31 cell = 0;
32 }
33 break;
34 case FLIGHT_WALL(4):
35 if (actor->z < FLIGHT_LEVEL(4)) {
36 cell = 0;
37 }
38 break;
39 case FLIGHT_WALL(5):
40 if (actor->z < FLIGHT_LEVEL(5)) {
41 cell = 0;
42 }
43 break;
44 case FLIGHT_WALL(6):
45 if (actor->z < FLIGHT_LEVEL(6)) {
46 cell = 0;
47 }
48 break;
49 }
50 switch (cell) {
51 case FLIGHT_CEILING(6):
52 if (actor->z > FLIGHT_LEVEL(6)) {
53 cell = 0;
54 }
55 break;
56 case FLIGHT_CEILING(5):
57 if (actor->z > FLIGHT_LEVEL(5)) {
58 cell = 0;
59 }
60 break;
61 case FLIGHT_CEILING(4):
62 if (actor->z > FLIGHT_LEVEL(4)) {
63 cell = 0;
64 }
65 break;
66 case FLIGHT_CEILING(3):
67 if (actor->z > FLIGHT_LEVEL(3)) {
68 cell = 0;
69 }
70 break;
71 case FLIGHT_CEILING(2):
72 if (actor->z > FLIGHT_LEVEL(2)) {
73 cell = 0;
74 }
75 break;
76 }
77 if (cell == 0) {
78 blocked = 1;
79 }
80 }
81 if (cell == 0) {
82 actor->pos.x -= offset.x;
83 actor->pos.y -= offset.y;
84 }
85 return blocked;
86}
87
88/* Whether a flying actor runs into the map at any of the five probes ahead
89 of it (FIELDSTG_checkFlightProbe) */
91 s32 blocked = 0;
92 s32 i;
93 u8 probe;
94 u8 *sign;
95 Vec2 offset;
96
97 for (i = 0; i < 5; i++) {
98 probe = FIELDSTG_probes[actor->dir][i];
99 sign = FIELDSTG_probeSteps[probe];
100 offset.x = (sign[0] & 1) * actor->speed / 2;
101 if (sign[0] & 0x80) {
102 offset.x = -offset.x;
103 }
104 offset.y = (sign[1] & 1) * actor->speed / 4;
105 if (sign[1] & 0x80) {
106 offset.y = -offset.y;
107 }
108 if (FIELDSTG_checkFlightProbe(actor, FIELDSTG_probePos[probe].x, FIELDSTG_probePos[probe].y, offset)) {
109 blocked = 1;
110 }
111 }
112 return blocked;
113}
114
115/* Walks or runs an actor in the direction of the pad's arrows (an index of
116 FIELDSTG_padDirs), or stops it when none is held */
117void FIELDSTG_moveByPad(Actor *actor, s32 pad) {
118 if (pad != 0 && FIELDSTG_state.menuOpen == 0) {
119 actor->dir = FIELDSTG_padDirs[pad];
120 if (actor->walks != 0) {
121 if (actor->substate != ACTOR_WALK) {
122 actor->setSubstate(actor, ACTOR_WALK);
123 }
124 } else if (actor->substate != ACTOR_RUN) {
125 actor->setSubstate(actor, ACTOR_RUN);
126 }
127 } else {
128 if (actor->substate == ACTOR_WALK) {
129 actor->setSubstate(actor, ACTOR_STAND);
130 }
131 if (actor->substate == ACTOR_RUN) {
132 actor->setSubstate(actor, ACTOR_STOP);
133 }
134 }
135}
136
137/*
138 * The first actor (task id 5) whose box holds the tile pos: halfWidth to
139 * each side of it, half that above and below. The match depends on the
140 * registry being held in a variable.
141 */
143 TaskRegistry *registry = &TASK_REGISTRY;
144 Actor *actor = registry->funcs.find(FIELD_TASK_ACTOR, -1, 1);
145
146 while (actor != NULL) {
147 s32 size = actor->halfWidth;
148
149 if (pos->x >= actor->tile.x - size && actor->tile.x + size >= pos->x) {
150 size >>= 1;
151 if (pos->y >= actor->tile.y - size && actor->tile.y + size >= pos->y) {
152 return actor;
153 }
154 }
155 actor = registry->funcs.findNext();
156 }
157 return NULL;
158}
159
160/* Talks to the character standing at pos, or to the one it stands in for
161 (FIELDSTG_standIns): it answers (ACTOR_TALK), or, for the objects 0x148,
162 0x15F and 0x160, the player works it (ACTOR_USE). Returns 1 when the
163 player acts */
165 Actor *target;
166 s32 i;
167 s32 result;
168
169 target = FIELDSTG_findActorAt(pos);
170 result = 0;
171 if (target != NULL && target->state == TASK_RUN) {
172 if (target->key1 != 0x180) {
173 if (target->key1 != 0x181) {
174 if (target->key1 != 0x182) {
175 for (i = 0; FIELDSTG_standIns[i].character != 0; i++) {
176 if (target->key1 == FIELDSTG_standIns[i].character) {
177 target = TASK_REGISTRY.funcs.find(FIELD_TASK_ACTOR, FIELDSTG_standIns[i].answerer, -1);
178 break;
179 }
180 }
181 switch (target->key1) {
182 case 0x148:
183 case 0x15F:
184 case 0x160:
185 if (target->substate != ACTOR_USED) {
186 target->setSubstate(target, ACTOR_USED);
187 result = 1;
188 target->talkPartner = actor;
189 actor->setSubstate(actor, ACTOR_USE);
190 actor->control = NULL;
191 }
192 break;
193 default:
194 target->setSubstate(target, ACTOR_TALK);
195 target->talkPartner = actor;
196 actor->setSubstate(actor, actor->flying != 0 ? ACTOR_FLOAT : ACTOR_STAND);
197 actor->control = NULL;
198 result = FIELDSTG_state.acting = 1;
199 break;
200 }
201 }
202 }
203 }
204 }
205 return result;
206}
207
208/* Stops the sound of the flight, if it plays */
209static inline void stopFlightSound(Actor *actor) {
210 if (actor->voice != -1) {
212 actor->voice = -1;
213 }
214}
215
216/* Changes the flight's height speed (zSpeed) by 4 a frame, down to -0xC0
217 while the player flies (ACTOR_FLY) and up to 0x80 while it floats */
218static inline void accelerateFlight(Actor *actor) {
219 if (actor->substate == ACTOR_FLY) {
220 if (actor->zSpeed > -0xC0) {
221 actor->zSpeed -= 4;
222 } else {
223 actor->zSpeed = -0xC0;
224 }
225 } else {
226 if (actor->zSpeed < 0x80) {
227 actor->zSpeed += 4;
228 } else {
229 actor->zSpeed = 0x80;
230 }
231 }
232}
233
234/*
235 * Held TRIANGLE flies (ACTOR_FLY, with its sound), else the actor floats
236 * and the sound stops
237 */
238static inline void flyOrFloat(Actor *actor, s32 held) {
239 if (held & (1 << PAD_TRIANGLE)) {
240 if (actor->substate != ACTOR_FLY) {
241 actor->setSubstate(actor, ACTOR_FLY);
242 }
243 if (actor->voice == -1) {
245 }
246 } else {
247 if (actor->substate == ACTOR_FLY) {
248 actor->setSubstate(actor, ACTOR_FLOAT);
249 }
250 stopFlightSound(actor);
251 }
252}
253
254/* Held RIGHT or LEFT turns the actor one direction every 8 frames */
255static inline void turnInFlight(Actor *actor, s32 held) {
256 if (!(GFX.funcs.getFrameCount() & 7)) {
257 if (held & (1 << PAD_RIGHT)) {
258 actor->reloadImage = 1;
259 actor->dir = (actor->dir + 1) & 7;
260 } else if (held & (1 << PAD_LEFT)) {
261 actor->reloadImage = 1;
262 actor->dir = (actor->dir - 1) & 7;
263 }
264 }
265}
266
267/* The player's flight: it rises unless triangle is held (ACTOR_FLY),
268 left and right turn, and cross, low enough, acts on what the player faces;
269 the map's cells hold floors (2 to 6) and ceilings (18 to 22). The match
270 depends on the button's shift and mask as two statements. */
272 Vec2 facing;
273 Vec2 pos;
274 s32 held;
275 s32 pressed;
276 s32 cell;
277 s32 stop;
278 s32 height;
279
280 held = PAD.getHeld(0);
281 pressed = (u32)PAD.getPressed(0) >> PAD_CROSS;
282 pressed &= 1;
284 return;
285 }
286 if (pressed && actor->z < FLIGHT_LEVEL(2)) {
287 actor->getFacingTile(actor, &facing);
288 if (FIELDSTG_talkToActorAt(actor, &facing)) {
289 actor->zSpeed = 0;
290 actor->speed = 0;
291 stopFlightSound(actor);
292 return;
293 }
294 }
295 flyOrFloat(actor, held);
296 turnInFlight(actor, held);
297 accelerateFlight(actor);
298 stop = 0;
299 height = 0;
300 pos.x = actor->pos.x >> 8;
301 pos.y = actor->pos.y >> 8;
302 cell = FIELDSTG_map.getCell(GAME.mapIndex, &pos);
303 actor->z += actor->zSpeed;
304 if (actor->zSpeed > 4) {
305 switch ((u8)cell) {
306 case FLIGHT_CEILING(6):
307 if (actor->z > FLIGHT_LEVEL(6)) {
308 stop = 1;
309 }
310 break;
311 case FLIGHT_CEILING(5):
312 if (actor->z > FLIGHT_LEVEL(5)) {
313 stop = 1;
314 }
315 break;
316 case FLIGHT_CEILING(4):
317 if (actor->z > FLIGHT_LEVEL(4)) {
318 stop = 1;
319 }
320 break;
321 case FLIGHT_CEILING(3):
322 if (actor->z > FLIGHT_LEVEL(3)) {
323 stop = 1;
324 }
325 break;
326 case FLIGHT_CEILING(2):
327 if (actor->z > FLIGHT_LEVEL(2)) {
328 stop = 1;
329 }
330 break;
331 }
332 } else {
333 switch ((u8)cell) {
334 case FLIGHT_WALL(2):
335 if (actor->z < FLIGHT_LEVEL(2)) {
336 stop = 1;
337 height = FLIGHT_LEVEL(2) + FLIGHT_LANDING;
338 }
339 break;
340 case FLIGHT_WALL(3):
341 if (actor->z < FLIGHT_LEVEL(3)) {
342 stop = 1;
343 height = FLIGHT_LEVEL(3) + FLIGHT_LANDING;
344 }
345 break;
346 case FLIGHT_WALL(4):
347 if (actor->z < FLIGHT_LEVEL(4)) {
348 stop = 1;
349 height = FLIGHT_LEVEL(4) + FLIGHT_LANDING;
350 }
351 break;
352 case FLIGHT_WALL(5):
353 if (actor->z < FLIGHT_LEVEL(5)) {
354 stop = 1;
355 height = FLIGHT_LEVEL(5) + FLIGHT_LANDING;
356 }
357 break;
358 case FLIGHT_WALL(6):
359 if (actor->z < FLIGHT_LEVEL(6)) {
360 stop = 1;
361 height = FLIGHT_LEVEL(6) + FLIGHT_LANDING;
362 }
363 break;
364 }
365 }
366 if (stop || actor->z > FLIGHT_Z_MAX || actor->z < FLIGHT_Z_MIN) {
367 if (height != 0) {
368 actor->z = height;
369 }
370 actor->zSpeed = 0;
371 }
372 if (actor->z >= FLIGHT_Z_MAX) {
373 actor->z = FLIGHT_Z_MAX;
374 }
375 if (actor->z <= FLIGHT_Z_MIN) {
376 actor->z = FLIGHT_Z_MIN;
377 }
378}
379
380/*
381 * The player's update while it walks (Actor.control) when no menu, event or
382 * transition is running: the action button or a forced action (condition
383 * 0x12) checks the tile it faces, for an object to act on or, failing that,
384 * an event; otherwise the pad moves it. The match depends on the object's
385 * case being an early exit, a do-while (0) with a break, after which the
386 * event's check is the rest of the block.
387 */
389 Vec2 pos;
390 HiddenSpots *obj;
391 s32 pad;
392 s32 pressed;
393 s32 forced;
394
396 pad = (PAD.getHeld(0) >> PAD_UP) & 0xF;
397 pressed = (PAD.getPressed(0) & (1 << PAD_CROSS)) != 0;
399 if (pressed || forced) {
400 actor->getFacingTile(actor, &pos);
401 do {
402 if (FLAGS_00.checkCondition(FIELD_SEARCH_ITEM, 1) && !forced && (obj = FIELDSTG_findHiddenSpot(&pos, 1)) != NULL) {
404 actor->setSubstate(actor, ACTOR_SEARCH);
405 obj->setState(obj, TASK_DONE);
406 break;
407 }
408 if (FIELDSTG_talkToActorAt(actor, &pos) && forced) {
410 }
411 } while (0);
412 } else {
413 FIELDSTG_moveByPad(actor, pad);
414 }
415 }
416}
417
418/* The player's control on a wall: up and down climb, nothing held holds on */
420 s32 held = PAD.getHeld(0);
421
422 if (held & (1 << PAD_UP)) {
423 if (actor->substate != ACTOR_CLIMB_UP) {
424 actor->setSubstate(actor, ACTOR_CLIMB_UP);
425 }
426 } else if (held & (1 << PAD_DOWN)) {
427 if (actor->substate != ACTOR_CLIMB_DOWN) {
428 actor->setSubstate(actor, ACTOR_CLIMB_DOWN);
429 }
430 } else if (actor->substate != ACTOR_CLIMB) {
431 actor->setSubstate(actor, ACTOR_CLIMB);
432 }
433}
434
435/* A partner's control: records the leader's steps in the trail while it
436 moves, and follows them */
438 Trail *trail;
439 Actor *leader;
440
441 if (actor->trail->leader == NULL) {
443 }
444 leader = actor->trail->leader;
445 if (leader != NULL) {
446 trail = actor->trail;
447 switch (leader->substate) {
448 case ACTOR_WALK:
449 case ACTOR_RUN:
450 case ACTOR_WALK_OUT:
451 case ACTOR_SLIDE:
452 case ACTOR_STOP_SLIDE:
453 trail->steps[trail->head].x = leader->pos.x;
454 trail->steps[trail->head].y = leader->pos.y;
455 trail->steps[trail->head].dir = leader->dir;
456 trail->head = (trail->head + 1) & (TRAIL_STEPS - 1);
457 actor->pos.x = trail->steps[trail->tail].x;
458 actor->pos.y = trail->steps[trail->tail].y;
459 actor->dir = trail->steps[trail->tail].dir;
460 trail->tail = (trail->tail + 1) & (TRAIL_STEPS - 1);
461 break;
462 }
463 switch (leader->substate) {
464 case ACTOR_WALK:
465 case ACTOR_RUN:
466 case ACTOR_WALK_OUT:
467 if (actor->substate != ACTOR_RUN) {
468 actor->setSubstate(actor, ACTOR_RUN);
469 }
470 break;
471 case ACTOR_SLIDE:
472 if (actor->substate != ACTOR_STAND) {
473 actor->setSubstate(actor, ACTOR_STAND);
474 }
475 break;
476 default:
477 if (actor->substate == ACTOR_RUN) {
478 actor->setSubstate(actor, ACTOR_STOP);
479 }
480 break;
481 }
482 actor->depth = leader->depth;
483 }
484}
485
486/* A follower's update while its trail runs out: it finds the leader
487 (FIELD_TASK_ACTOR) if it has none, then each frame pushes two empty
488 steps at the trail's head and walks two steps from its tail. At x 0 it
489 clears the trail and drops this update. The match depends on the leader
490 being read into a variable before `trail` is set, which makes `trail` a
491 copy of the pointer the leader was loaded through. */
493 Trail *trail;
494 Actor *leader;
495 s32 i;
496
497 if (actor->trail->leader == NULL) {
499 }
500 leader = actor->trail->leader;
501 trail = actor->trail;
502 if (leader != NULL) {
503 for (i = 0; i < 2; i++) {
504 trail->steps[trail->head].x = 0;
505 trail->steps[trail->head].y = 0;
506 trail->steps[trail->head].dir = 0;
507 trail->head = (trail->head + 1) & (TRAIL_STEPS - 1);
508 actor->pos.x = trail->steps[trail->tail].x;
509 actor->pos.y = trail->steps[trail->tail].y;
510 actor->dir = trail->steps[trail->tail].dir;
511 trail->tail = (trail->tail + 1) & (TRAIL_STEPS - 1);
512 }
513 if (actor->substate != ACTOR_RUN) {
514 actor->setSubstate(actor, ACTOR_RUN);
515 }
516 if (actor->pos.x == 0) {
517 for (i = 0; i < TRAIL_STEPS; i++) {
518 trail->steps[i].dir = 0;
519 trail->steps[i].x = 0;
520 trail->steps[i].y = 0;
521 }
522 actor->control = NULL;
523 }
524 }
525}
526
527/* Walks an actor to its goal tile (FIELDSTG_setActorGoal) as the pad would,
528 then faces it the goal's way */
530 s32 x;
531 s32 y;
532 s32 tx;
533 s32 ty;
534 s32 pad;
535
536 if (actor->walking != 0) {
537 x = actor->pos.x >> 8;
538 y = actor->pos.y >> 8;
539 tx = actor->goalX;
540 ty = actor->goalY;
541 if (x >> 1 != tx >> 1 || y >> 1 != ty >> 1) {
542 pad = 0;
543 if (x < tx) {
544 pad = 1 << PAD_RIGHT;
545 } else if (x > tx) {
546 pad = 1 << PAD_LEFT;
547 }
548 if (y < ty) {
549 pad |= 1 << PAD_DOWN;
550 } else if (y > ty) {
551 pad |= 1 << PAD_UP;
552 }
553 actor->walks = 1;
554 FIELDSTG_moveByPad(actor, pad >> 4);
555 } else {
556 actor->pos.x = actor->goalX << 8;
557 actor->walking = 0;
558 actor->pos.y = actor->goalY << 8;
559 actor->dir = actor->goalDir;
560 actor->setSubstate(actor, ACTOR_STAND);
561 }
562 }
563}
564
565/* Sets the tile an actor walks to and the direction it ends facing
566 (FIELDSTG_walkToGoal) */
567void FIELDSTG_setActorGoal(Actor *actor, s32 x, s32 y, s32 dir) {
568 actor->walking = 1;
569 actor->goalX = x;
570 actor->goalY = y;
571 actor->goalDir = dir;
572}
573
574/* Whether an actor is still walking to its goal */
576 return actor->walking;
577}
578
579/* Starts an actor walking to its goal */
583
584/* Gives an actor its kind's control back: the pad for the player, none for
585 kind 1, the trail for the partners */
587 switch (actor->key2) {
588 case 0:
590 actor->walks = 0;
591 break;
592 case 1:
593 actor->control = NULL;
594 break;
595 case 2:
596 case 4:
597 case 8:
599 break;
600 }
601}
602
603/* Walks an actor out through an exit, in a direction (ACTOR_WALK_OUT) */
605 actor->control = NULL;
606 actor->setSubstate(actor, ACTOR_WALK_OUT);
607 actor->dir = dir;
608}
609
610/* Starts an actor sliding in a direction (SLOT_SLIDE) */
612 if (actor->substate != ACTOR_SLIDE) {
613 actor->control = NULL;
614 actor->setSubstate(actor, ACTOR_SLIDE);
615 actor->dir = dir;
616 }
617}
618
619/* Stops a sliding actor (SLOT_STOP_SLIDE) */
621 if (actor->substate == ACTOR_SLIDE) {
622 actor->setSubstate(actor, ACTOR_STOP_SLIDE);
623 }
624}
625
626/* The climbs (SLOT_CLIMB_UP and SLOT_CLIMB_DOWN) and the drop (SLOT_DROP):
627 the actor goes onto the wall at its foot (ACTOR_GET_ON_WALL) or its top
628 (ACTOR_GET_OVER_EDGE), climbs it with the pad (FIELDSTG_controlClimb) and
629 leaves it at the top or the foot; a drop (ACTOR_DROP) falls from height. */
630void FIELDSTG_startClimbUp(Actor *actor, s32 dir, s32 x, s32 y, s32 height) {
631 actor->control = NULL;
632 actor->setSubstate(actor, ACTOR_GET_ON_WALL);
633 actor->dir = dir;
634 actor->pos.x = x << 8;
635 actor->pos.y = y << 8;
636 actor->climbHeight = 0;
637 actor->wallHeight = height << 8;
638 if (dir != 5) {
639 actor->climbSide = 1;
640 } else {
641 actor->climbSide = 0;
642 }
645}
646
647/* Starts the climb down a wall of height from its top, at (x, y) */
648void FIELDSTG_startClimbDown(Actor *actor, s32 dir, s32 x, s32 y, s32 height) {
649 actor->control = NULL;
650 actor->setSubstate(actor, ACTOR_GET_OVER_EDGE);
651 actor->dir = dir;
652 actor->pos.x = x << 8;
653 actor->pos.y = y << 8;
654 actor->climbHeight = actor->wallHeight = height << 8;
655 if (dir != 5) {
656 actor->climbSide = 1;
657 } else {
658 actor->climbSide = 0;
659 }
660 actor->hasShadow = 0;
663}
664
665/* Starts a drop from a ledge of height */
666void FIELDSTG_startDrop(Actor *actor, s32 dir, Vec2 pos, s32 height) {
667 s32 value;
668
669 actor->control = NULL;
670 actor->setSubstate(actor, ACTOR_DROP);
671 actor->dir = dir;
672 if (dir != 7) {
673 actor->climbSide = 0;
674 } else {
675 actor->climbSide = 1;
676 }
677 value = height << 8;
678 actor->wallHeight = value;
679 actor->hasShadow = 0;
680 actor->climbHeight = value;
683}
684
685/* Starts the gauge game at an offset from an actor, turning the partners its
686 way */
687void FIELDSTG_startActorGauge(Actor *actor, s32 dir, Vec2 offset) {
688 void **children;
689 Actor *other;
690 Vec2 pos;
691 s32 i;
692
694 actor->control = NULL;
695 actor->setSubstate(actor, ACTOR_GAUGE);
696 actor->dir = dir;
697 for (i = 0; i < 3; i++) {
699 if (other != NULL) {
700 other->dir = dir;
701 }
702 }
703 children = actor->children;
704 pos.x = actor->tile.x + offset.x;
705 pos.y = actor->tile.y + offset.y;
706 children[2] = FIELDSTG_createGauge(pos);
707}
708
709/* Warps the player (SLOT_WARP0 and SLOT_WARP1): the field task plays the
710 warp's effect and cutscene of kind, then leaves for its mode
711 (FIELDSTG_startWarp) */
712void FIELDSTG_warpActor(Actor *actor, SlotDest *dest, s32 kind) {
713 actor->control = NULL;
714 actor->setSubstate(actor, ACTOR_STAND);
715 actor->dir = 0;
717 FIELDSTG_startWarp(kind, &actor->tile, dest);
718}
719
720/* Sends the player flying to the tile at dest from the nearest launcher
721 (FIELDSTG_createLaunch) */
723 void **children;
724
726 actor->setSubstate(actor, ACTOR_STAND);
727 actor->dir = 0;
729 children = actor->children;
730 children[2] = FIELDSTG_createLaunch(actor, dest);
731}
732
733/* Starts an actor's animation set from its first frame */
734void FIELDSTG_setActorAnim(Actor *actor, s32 set) {
735 actor->animSet = set;
736 actor->animPos = 0;
737 actor->animTime = 0;
738 actor->animDone = 0;
739}
740
741/* Puts an actor in an event's pose: an animation set and a direction
742 (ACTOR_POSED) */
743void FIELDSTG_setActorPose(Actor *actor, s32 set, s32 dir) {
744 actor->walking = 0;
745 actor->setSubstate(actor, ACTOR_POSED);
746 actor->dir = dir;
747 FIELDSTG_setActorAnim(actor, set);
748}
749
750/* Whether an actor's animation has played to its end */
752 return actor->animDone;
753}
754
755/* The layer's sorted callback that draws an actor: its frame from its image,
756 * mirrored for the directions 5 and up, and, when it has one, its shadow, a
757 * sprite with its own texture page. The match depends on the shadow's y offset
758 * cast to s16, and on the untyped parameters copied to typed locals. */
759void FIELDSTG_drawActor(void *data, void *drawLayer) {
760 Actor *actor = data;
761 Layer *layer = drawLayer;
762 ActorImage *image = actor->image;
763 Vec2 pos;
764 Vec2 scroll;
765 u_long *ot;
766 PrimPtr prim;
767 FieldImage *shadow;
768 s32 x;
769
770 if (actor->state == TASK_RUN) {
771 ot = layer->getOtEntry(layer, actor->depth);
772 pos = actor->tile;
773 layer->getScroll(layer, &scroll);
774 pos.x -= scroll.x;
775 pos.y -= scroll.y;
776 prim.any = GFX.funcs.getPrim();
777 pos.y -= actor->z >> 8;
778 setPolyFT4(prim.ft4);
779 setRGB0(prim.ft4, 0x80, 0x80, 0x80);
780 x = actor->frame[2];
781 if (actor->dir >= 5) {
782 x = -(actor->frameWidth + x);
783 }
784 prim.ft4->x0 = pos.x + x;
785 prim.ft4->x1 = actor->frameWidth + (pos.x + x);
786 prim.ft4->x2 = pos.x + x;
787 prim.ft4->x3 = actor->frameWidth + (pos.x + x);
788 prim.ft4->y0 = actor->frame[3] + pos.y;
789 prim.ft4->y1 = actor->frame[3] + pos.y;
790 prim.ft4->y2 = actor->frameHeight + (actor->frame[3] + pos.y);
791 prim.ft4->y3 = actor->frameHeight + (actor->frame[3] + pos.y);
792 if (actor->dir < 5) {
793 prim.ft4->u0 = image->u;
794 prim.ft4->u1 = actor->frameWidth + image->u;
795 prim.ft4->u2 = image->u;
796 prim.ft4->u3 = actor->frameWidth + image->u;
797 } else {
798 prim.ft4->x1--;
799 prim.ft4->x3--;
800 prim.ft4->u0 = actor->frameWidth + image->u - 1;
801 prim.ft4->u1 = image->u;
802 prim.ft4->u2 = actor->frameWidth + image->u - 1;
803 prim.ft4->u3 = image->u;
804 }
805 prim.ft4->v0 = image->v;
806 prim.ft4->v1 = image->v;
807 prim.ft4->v2 = actor->frameHeight + image->v;
808 prim.ft4->v3 = actor->frameHeight + image->v;
809 prim.ft4->clut = getClut(image->clutX, image->clutY);
810 prim.ft4->tpage = getTPage(0, 0, image->x, image->y);
811 addPrim(ot, prim.any);
812 pos.y += actor->z >> 8;
813 prim.ft4++;
814 if (actor->hasShadow != 0) {
815 ot = layer->getOtEntry(layer, actor->depth + 1);
816 shadow = actor->fieldImage;
817 setSprt(prim.sprt);
818 setRGB0(prim.sprt, 0x80, 0x80, 0x80);
819 prim.sprt->x0 = pos.x - 16;
820 prim.sprt->y0 = pos.y + (s16)((actor->climbHeight >> 8) - 8);
821 prim.sprt->u0 = shadow->shadow.u;
822 prim.sprt->v0 = shadow->shadow.v;
823 prim.sprt->w = 0x20;
824 prim.sprt->h = 0x10;
825 prim.sprt->clut = getClut(shadow->shadow.clutX, shadow->shadow.clutY);
826 addPrim(ot, prim.any);
827 prim.sprt++;
828 SetDrawTPage(prim.tpage, 0, 1, GetTPage(0, 0, shadow->shadow.x, shadow->shadow.y));
829 addPrim(ot, prim.any);
830 prim.tpage++;
831 }
832 GFX.funcs.setPrim(prim.any);
833 }
834}
835
836/* Turns an actor to a direction */
837void FIELDSTG_setActorDir(Actor *actor, s32 dir) {
838 actor->dir = dir;
839}
840
841#if VERSION_US || VERSION_JP
842#define SET_FILE_0 0x01790070
843#define SET_FILE_8 0x03BB001E
844#define SET_FILE_16 0x03B9000B
845#define SET_FILE_1A 0x03BC0017
846#define SET_FILE_OTHER 0x03BA0064
847#elif VERSION_EU
848#define SET_FILE_0 0x01870070
849#define SET_FILE_8 0x03CB001E
850#define SET_FILE_16 0x03C9000B
851#define SET_FILE_1A 0x03CC0017
852#define SET_FILE_OTHER 0x03CA0064
853#endif
854
855/*
856 * Plays an actor's animation: when its set (animSet) changes, it loads the
857 * set's animations for the five directions (character 2 picks the file by
858 * the set first), then steps the frames of the current direction's and
859 * loads a new frame's image into VRAM. The match depends on two early
860 * exits written as a do-while (0) with breaks, the pick of the file and
861 * the step of the frames: loop.c moves the end of the animation (-1) out
862 * of the second one, after the direction's barrier, and reorg fills the
863 * first one's < 0x16 branch from its fallthrough, as only a branch out of
864 * a loop is. It also depends on reloadImage being read twice, on the width cast
865 * to s16 and on reloadImage being cleared last.
866 */
868 TimLoader loader;
869 s16 *entry;
870 s32 *frames;
871 s32 set;
872 s32 file;
873 s32 dir;
874 s32 i;
875 ActorImage *image;
876
877 set = actor->animSet;
878 file = actor->animFile & 0xFFFF0000;
879 if (actor->loadedSet != set) {
880 if (actor->key1 == 2) {
881 do {
882 if (set < 8) {
883 actor->animFile = SET_FILE_0;
884 break;
885 }
886 if (set == 8) {
887 actor->animFile = SET_FILE_8;
888 break;
889 }
890 if (set < 0x16) {
891 actor->animFile = SET_FILE_OTHER;
892 break;
893 }
894 if (set < 0x1A) {
895 actor->animFile = SET_FILE_16;
896 break;
897 }
898 if (set < 0x25) {
899 actor->animFile = SET_FILE_1A;
900 break;
901 }
902 actor->animFile = SET_FILE_OTHER;
903 } while (0);
904 file = actor->animFile & 0xFFFF0000;
905 }
906 for (entry = FILE_CACHE.getEntry(actor->animFile); entry[0] != 0; entry += 6) {
907 if (entry[0] == set) {
908 break;
909 }
910 }
911 if (entry[0] == 0) {
912 entry = FILE_CACHE.getEntry(actor->animFile);
913 }
914 for (i = 0; i < 5; i++) {
915 actor->setAnims[i] = entry[i + 1] | file;
916 }
917 actor->loadedSet = set;
918 actor->animDone = 0;
919 }
920 if (actor->dir < 5) {
921 dir = actor->dir;
922 } else {
923 dir = 8 - actor->dir;
924 }
925 frames = FILE_CACHE.getEntry(actor->setAnims[dir]);
926 do {
927 if (actor->animTime > 0) {
928 break;
929 }
930 if (frames[actor->animPos] == -1) {
931 actor->animTime = 0x7FFFFF;
932 actor->animDone = 1;
933 break;
934 }
935 if (frames[actor->animPos] == 0) {
936 actor->animPos = 0;
937 }
938 actor->animTime = frames[actor->animPos++];
939 actor->frame[0] = frames[actor->animPos++] | file;
940 actor->frame[2] = frames[actor->animPos++];
941 actor->frame[3] = frames[actor->animPos++];
942 } while (0);
943 actor->animTime -= GFX.funcs.getFrameTime();
944 if (actor->reloadImage) {
945 actor->animTime = frames[actor->animPos - 4];
946 actor->frame[0] = frames[actor->animPos - 3] | file;
947 actor->frame[2] = frames[actor->animPos - 2];
948 actor->frame[3] = frames[actor->animPos - 1];
949 }
950 if (actor->reloadImage || actor->frame[1] != actor->frame[0]) {
951 image = actor->image;
952 initTimLoader(&loader);
953 loader.setImagePos(image->imageX, image->imageY);
954 loader.setClutPos(image->clutX, image->clutY);
955 loader.load(FILE_CACHE.getEntry(actor->frame[0]));
956 actor->frame[1] = actor->frame[0];
957 actor->frameWidth = (s16)loader.w * 4;
958 actor->frameHeight = loader.h;
959 actor->reloadImage = 0;
960 }
961}
962
963/* Gives the player its pad control back, off any wall */
966 actor->climbHeight = 0;
967}
968
969/* The player's footsteps, every 8 frames when it moves (every 32 for the
970 characters 0x146 and 0x147) or 32 when not; with canBattle each step can
971 start a battle (FIELDSTG_checkBattle) */
972void FIELDSTG_playStepSounds(Actor *actor, s32 moving, s32 canBattle) {
973 if (actor->key2 == 0) {
974 if (moving != 0) {
975 if ((actor->counter & 7) == 0) {
976 if (actor->key1 != 0x146) {
977 if (actor->key1 != 0x147) {
979 }
980 } else if ((actor->counter & 0x1F) == 0) {
982 }
983 if (canBattle != 0) {
985 }
986 }
987 } else if ((actor->counter & 0x1F) == 0) {
989 }
990 actor->counter++;
991 }
992}
993
994/* The player's climbing sound, every 16 frames */
996 if (actor->key2 == 0) {
997 if ((actor->counter & 0xF) == 0) {
999 }
1000 actor->counter++;
1001 }
1002}
1003
1004/* The first frame of an action: the actor gets its shadow and the action's
1005 animation */
1006static inline void beginActorAnim(Actor *actor, s32 anim) {
1007 switch (actor->step) {
1008 case 0:
1009 default:
1010 actor->hasShadow = 1;
1011 FIELDSTG_setActorAnim(actor, anim);
1012 actor->nextStep(actor);
1013 case 1:
1014 break;
1015 }
1016}
1017
1018/* Puts a character back to standing, under the player's control again */
1019static inline void standAgain(Actor *actor) {
1020 actor->setSubstate(actor, ACTOR_STAND);
1023}
1024
1025/* Gives the player that talked back its control, walking or flying */
1026static inline void giveControlBack(Actor *player) {
1027 if (player->flying == 0) {
1029 } else {
1031 }
1032}
1033
1034/* Sets the flag of the characters 0x148, 0x15F and 0x160 once they are used */
1035static inline void setUsedFlag(s32 character) {
1036 switch (character) {
1037 case 0x148:
1038 FLAGS_00.applyAction(8, 1);
1039 break;
1040 case 0x15F:
1041 FLAGS_00.applyAction(9, 1);
1042 break;
1043 case 0x160:
1044 FLAGS_00.applyAction(0xA, 1);
1045 break;
1046 }
1047}
1048
1049/* ACTOR_STOP: the stop after a run, then standing */
1050static inline void runStop(Actor *actor) {
1051 switch (actor->step) {
1052 case 0:
1053 default:
1055 actor->nextStep(actor);
1056 case 1:
1057 break;
1058 }
1059 if (actor->animDone != 0) {
1060 actor->setSubstate(actor, ACTOR_STAND);
1061 }
1062}
1063
1064/* ACTOR_SLIDE: the slide on ice, with its sound */
1065static inline void runSlide(Actor *actor) {
1066 Vec2 move;
1067
1068 switch (actor->step) {
1069 case 0:
1070 default:
1074 actor->nextStep(actor);
1075 case 1:
1076 break;
1077 }
1078 FIELDSTG_map.getWalkStep(&actor->tile, actor->speed, actor->dir, &move);
1079 actor->pos.x += move.x;
1080 actor->pos.y += move.y;
1081}
1082
1083/* ACTOR_STOP_SLIDE: the end of a slide, half a second before the player's
1084 control comes back */
1085static inline void runStopSlide(Actor *actor) {
1086 if (actor->step == 0) {
1088 }
1089 actor->step += GFX.funcs.getFrameTime();
1090 if (actor->step >= 0x1E) {
1092 actor->setSubstate(actor, ACTOR_STAND);
1094 }
1095}
1096
1097/* ACTOR_CLIMB_UP: up the wall, to its top */
1098static inline void runClimbUp(Actor *actor) {
1099 switch (actor->step) {
1100 case 0:
1101 default:
1103 actor->nextStep(actor);
1104 case 1:
1105 break;
1106 }
1107 actor->climbHeight += 0x100;
1108 if (actor->climbHeight >= actor->wallHeight) {
1109 actor->climbHeight = actor->wallHeight;
1110 actor->setSubstate(actor, ACTOR_CLIMB_OFF_TOP);
1111 actor->control = NULL;
1112 }
1114}
1115
1116/* ACTOR_CLIMB_DOWN: down the wall, to its foot */
1117static inline void runClimbDown(Actor *actor) {
1118 switch (actor->step) {
1119 case 0:
1120 default:
1122 actor->nextStep(actor);
1123 case 1:
1124 break;
1125 }
1126 actor->climbHeight -= 0x100;
1127 if (actor->climbHeight <= 0) {
1128 actor->climbHeight = 0;
1129 actor->setSubstate(actor, ACTOR_CLIMB_OFF_BOTTOM);
1130 actor->control = NULL;
1131 }
1133}
1134
1135/* ACTOR_GET_ON_WALL: from the ground onto the wall, to climb it */
1136static inline void runGetOnWall(Actor *actor) {
1137 switch (actor->step) {
1138 case 0:
1139 default:
1141 actor->nextStep(actor);
1142 case 1:
1143 break;
1144 }
1145 if (actor->animDone != 0) {
1146 actor->setSubstate(actor, ACTOR_CLIMB);
1148 }
1149}
1150
1151/* ACTOR_CLIMB_OFF_BOTTOM: from the wall's foot onto the ground */
1152static inline void runClimbOffBottom(Actor *actor) {
1153 switch (actor->step) {
1154 case 0:
1155 default:
1157 actor->nextStep(actor);
1158 case 1:
1159 break;
1160 }
1161 if (actor->animDone != 0) {
1162 actor->setSubstate(actor, ACTOR_STAND);
1165 actor->dir = 0;
1167 }
1168}
1169
1170/* ACTOR_CLIMB_OFF_TOP: from the wall's top onto the ground above */
1171static inline void runClimbOffTop(Actor *actor) {
1172 switch (actor->step) {
1173 case 0:
1174 default:
1175 actor->hasShadow = 0;
1177 actor->nextStep(actor);
1178 case 1:
1179 break;
1180 }
1181 if (actor->animDone != 0) {
1182 actor->setSubstate(actor, ACTOR_STAND);
1183 actor->hasShadow = 1;
1187 actor->pos.x += actor->climbSide != 0 ? -0x1000 : 0x1000;
1188 actor->pos.y -= 0x1800 + actor->wallHeight;
1191 }
1192}
1193
1194/* ACTOR_DROP: the drop off a wall's edge, the fall and the landing */
1195static inline void runDrop(Actor *actor) {
1196 switch (actor->step) {
1197 case 0:
1198 default:
1199 actor->hasShadow = 0;
1201 actor->pos.y += actor->wallHeight;
1202 actor->pos.x += actor->climbSide != 0 ? 0x1000 : -0x1000;
1203 actor->nextStep(actor);
1204 /* fallthrough */
1205 case 1:
1206 if (actor->animDone == 0) {
1207 break;
1208 }
1210 actor->nextStep(actor);
1211 /* fallthrough */
1212 case 2:
1213 actor->hasShadow = 1;
1214 actor->climbHeight -= 0x300;
1215 if (actor->animSet == ACTOR_ANIM_FALL && actor->wallHeight - actor->climbHeight > 0x1800) {
1217 }
1218 if (actor->climbHeight <= 0) {
1219 actor->climbHeight = 0;
1222 actor->nextStep(actor);
1223 }
1224 break;
1225 case 3:
1226 if (actor->animDone != 0) {
1227 standAgain(actor);
1230 }
1231 break;
1232 }
1233}
1234
1235/* ACTOR_GAUGE: the gauge game's poses, from its start to its result's balloon */
1236static inline void runGauge(Actor *actor, ActorChildren *children) {
1237 switch (actor->step) {
1238 case 0:
1239 default:
1241 actor->nextStep(actor);
1242 /* fallthrough */
1243 case 1:
1244 if (actor->animDone == 0) {
1245 break;
1246 }
1249 actor->nextStep(actor);
1250 /* fallthrough */
1251 case 2:
1252 if (actor->animDone == 0) {
1253 break;
1254 }
1257 actor->nextStep(actor);
1258 /* fallthrough */
1259 case 3:
1260 if (children->action != NULL) {
1261 break;
1262 }
1263 children->balloon = FIELDSTG_createBalloon(0, 1, 6);
1265 actor->nextStep(actor);
1266 /* fallthrough */
1267 case 4:
1268 actor->counter += GFX.funcs.getFrameTime();
1269 if (actor->counter < 0x3C) {
1270 break;
1271 }
1272 children->balloon->setState(children->balloon, TASK_DONE);
1274 actor->nextStep(actor);
1275 /* fallthrough */
1276 case 5:
1277 if (actor->animDone != 0) {
1278 standAgain(actor);
1279 FIELDSTG_state.busy = 0;
1280 }
1281 break;
1282 }
1283}
1284
1285/* ACTOR_SEARCH: the player searches a hidden spot */
1286static inline void runSearch(Actor *actor) {
1287 switch (actor->step) {
1288 case 0:
1289 default:
1290 actor->control = NULL;
1292 actor->nextStep(actor);
1293 case 1:
1294 break;
1295 }
1296 if (actor->animDone != 0) {
1297 standAgain(actor);
1299 }
1300}
1301
1302/* ACTOR_TALK: the character's first talk whose conditions hold, then the
1303 player's control back and the talk's flag actions */
1304static inline void runTalk(Actor *actor, ActorChildren *children) {
1305 FieldTalk *talk;
1306 s32 isTreasure;
1307
1308 isTreasure = 0;
1309 if (actor->key1 == 0x21 || (actor->key1 >= 0x4D && actor->key1 < 0x58) ||
1310 (actor->key1 >= 0x154 && actor->key1 < 0x159) || actor->key1 == 0x15B) {
1311 isTreasure = 1;
1312 }
1313 switch (actor->step) {
1314 case 0:
1315 default:
1316 talk = actor->entry->talks;
1317 while (1) {
1318 if (talk->conditions == NULL) {
1319 break;
1320 }
1321 if (FLAGS_00.checkConditions(talk->conditions) == 1) {
1322 break;
1323 }
1324 talk++;
1325 }
1326 actor->talkActions = talk->actions;
1327 if (!isTreasure && actor->keepsDir == 0) {
1328 actor->dir = (actor->talkPartner->dir + 4) & 7;
1329 }
1330 if (actor->animFile != 0 && !isTreasure) {
1331 children->speech = FIELDSTG_createTalk(actor, talk->entry);
1332 } else {
1333 children->speech = FIELDSTG_createTalk(actor->talkPartner, talk->entry);
1334 }
1335 if (isTreasure) {
1338 }
1339 actor->nextStep(actor);
1340 break;
1341 case 1:
1342 if (children->speech == NULL) {
1343 if (!isTreasure) {
1344 actor->setSubstate(actor, ACTOR_STAND);
1345 } else {
1346 actor->setState(actor, TASK_KILL);
1347 }
1349 if (actor->talkActions != NULL) {
1351 }
1353 }
1354 break;
1355 }
1356}
1357
1358/* ACTOR_USE: the player works one of the objects 0x148, 0x15F and 0x160 */
1359static inline void runUse(Actor *actor) {
1360 switch (actor->step) {
1361 case 0:
1362 default:
1363#if VERSION_EU || VERSION_JP
1365#endif
1366 actor->control = NULL;
1368 actor->nextStep(actor);
1369 case 1:
1370 break;
1371 }
1372 if (actor->animDone != 0) {
1373 standAgain(actor);
1374#if VERSION_EU || VERSION_JP
1376#endif
1377 }
1378}
1379
1380/* ACTOR_USED: the object the player worked, which plays its animation, sets its
1381 flag and goes away */
1382static inline void runUsed(Actor *actor) {
1383 switch (actor->step) {
1384 case 0:
1385 default:
1386 if (actor->counter < 0x14) {
1387 actor->counter += GFX.funcs.getFrameTime();
1388 break;
1389 }
1392#if VERSION_EU || VERSION_JP
1393 setUsedFlag(actor->key1);
1394#endif
1395 actor->nextStep(actor);
1396 /* fallthrough */
1397 case 1:
1398 if (actor->animDone != 0) {
1399#if VERSION_US
1400 setUsedFlag(actor->key1);
1401#endif
1402 actor->setState(actor, TASK_KILL);
1403 }
1404 break;
1405 }
1406}
1407
1408/*
1409 * Runs an actor's action, its substate (ACTOR_STAND...): the walks, the
1410 * climbs and the drop from ACTOR_GET_OVER_EDGE to ACTOR_DROP (which shift it
1411 * by a tile, left or right by climbSide), the talk of ACTOR_TALK (the first
1412 * of the character's talks whose conditions hold) and the others up to
1413 * ACTOR_STOP_SLIDE. A treasure (characters 0x21, 0x4D to 0x57, 0x154 to 0x158
1414 * and 0x15B, whose talks give an item) doesn't turn to its talker: it opens
1415 * with TRESUREB, and goes away when the talk ends. The match depends on the talks' loop testing both of its
1416 * ends with a break at its top, and on the moves of a tile adding a choice of
1417 * two steps.
1418 */
1420 Vec2 move2;
1421 Vec2 move3;
1422 Vec2 move4;
1423 Vec2 move5;
1424
1425 switch (actor->substate) {
1426 case ACTOR_STAND:
1428 break;
1429 case ACTOR_WALK:
1431 if (!(actor->key2 & 0xE)) {
1432 FIELDSTG_map.getWalkStep(&actor->tile, actor->speed >> 2, actor->dir, &move2);
1433 actor->pos.x += move2.x;
1434 actor->pos.y += move2.y;
1435 }
1436 FIELDSTG_playStepSounds(actor, 0, 0);
1437 break;
1438 case ACTOR_RUN:
1440 if (!(actor->key2 & 0xE)) {
1441 FIELDSTG_map.getWalkStep(&actor->tile, actor->speed, actor->dir, &move3);
1442 actor->pos.x += move3.x;
1443 actor->pos.y += move3.y;
1444 }
1445 FIELDSTG_playStepSounds(actor, 1, 1);
1446 if (GAME.funcs.getMode() != FIELD_MODE_WSTAG415 && actor->key2 == 0) {
1448 }
1449 break;
1450 case ACTOR_FLOAT:
1452 if (actor->speed != 0) {
1453 actor->speed -= 8;
1454 if (actor->speed < 0) {
1455 actor->speed = 0;
1456 }
1457 FIELDSTG_map.getFlyStep(&actor->tile, actor->speed, actor->dir, &move4);
1458 actor->pos.x += move4.x;
1459 actor->pos.y += move4.y;
1461 }
1462 break;
1463 case ACTOR_FLY:
1464 switch (actor->step) {
1465 case 0:
1466 default:
1467 actor->hasShadow = 1;
1469 actor->speed = 0;
1470 actor->nextStep(actor);
1471 case 1:
1472 break;
1473 }
1474 actor->speed += 8;
1475#if PAL_VIDEO
1476 if (NTSC_MODE != 0) {
1477 if (actor->speed > FLIGHT_SPEED_MAX) {
1478 actor->speed = FLIGHT_SPEED_MAX;
1479 }
1480 } else if (actor->speed > FLIGHT_SPEED_MAX_PAL) {
1481 actor->speed = FLIGHT_SPEED_MAX_PAL;
1482 }
1483#else
1484 if (actor->speed > FLIGHT_SPEED_MAX) {
1485 actor->speed = FLIGHT_SPEED_MAX;
1486 }
1487#endif
1488 FIELDSTG_map.getFlyStep(&actor->tile, actor->speed, actor->dir, &move4);
1489 actor->pos.x += move4.x;
1490 actor->pos.y += move4.y;
1491 FIELDSTG_playStepSounds(actor, 1, 1);
1493 break;
1494 case ACTOR_STOP:
1495 runStop(actor);
1496 break;
1497 case ACTOR_WALK_OUT:
1498 switch (actor->step) {
1499 case 0:
1500 default:
1502 if (actor->flying == 0) {
1504 }
1505 actor->nextStep(actor);
1506 case 1:
1507 break;
1508 }
1509 FIELDSTG_map.getWalkStep(&actor->tile, actor->speed, actor->dir, &move5);
1510 actor->pos.x += move5.x;
1511 actor->pos.y += move5.y;
1512 if (actor->flying == 0) {
1513 FIELDSTG_playStepSounds(actor, 1, 0);
1514 }
1515 break;
1516 case ACTOR_SLIDE:
1517 runSlide(actor);
1518 break;
1519 case ACTOR_STOP_SLIDE:
1520 runStopSlide(actor);
1521 break;
1522 case ACTOR_CLIMB:
1523 switch (actor->step) {
1524 case 0:
1525 default:
1527 actor->nextStep(actor);
1528 case 1:
1529 break;
1530 }
1531 break;
1532 case ACTOR_CLIMB_UP:
1533 runClimbUp(actor);
1534 break;
1535 case ACTOR_CLIMB_DOWN:
1536 runClimbDown(actor);
1537 break;
1538 case ACTOR_GET_ON_WALL:
1539 runGetOnWall(actor);
1540 break;
1542 switch (actor->step) {
1543 case 0:
1544 default:
1545 actor->hasShadow = 0;
1547 actor->pos.x += actor->climbSide != 0 ? 0x1000 : -0x1000;
1548 actor->pos.y += 0x1800 + actor->wallHeight;
1550 actor->nextStep(actor);
1551 case 1:
1552 break;
1553 }
1554 if (actor->animDone == 0) {
1555 break;
1556 }
1557 actor->setSubstate(actor, ACTOR_CLIMB);
1559 /* fallthrough */
1560 case ACTOR_POSED:
1561 default:
1562 actor->hasShadow = 1;
1563 break;
1565 runClimbOffBottom(actor);
1566 break;
1568 runClimbOffTop(actor);
1569 break;
1570 case ACTOR_DROP:
1571 runDrop(actor);
1572 break;
1573 case ACTOR_GAUGE:
1574 runGauge(actor, children);
1575 break;
1576 case ACTOR_SEARCH:
1577 runSearch(actor);
1578 break;
1579 case ACTOR_TALK:
1580 runTalk(actor, children);
1581 break;
1582 case ACTOR_USE:
1583 runUse(actor);
1584 break;
1585 case ACTOR_USED:
1586 runUsed(actor);
1587 break;
1588 }
1589}
static void runGetOnWall(Actor *actor)
ACTOR_GET_ON_WALL: from the ground onto the wall, to climb it.
void FIELDSTG_followLeader(Actor *actor)
A partner's control: records the leader's steps in the trail while it moves, and follows them.
void FIELDSTG_warpActor(Actor *actor, SlotDest *dest, s32 kind)
Warps the player (SLOT_WARP0 and SLOT_WARP1): the field task plays the warp's effect and cutscene of ...
static void runUsed(Actor *actor)
ACTOR_USED: the object the player worked, which plays its animation, sets its flag and goes away.
static void setUsedFlag(s32 character)
Sets the flag of the characters 0x148, 0x15F and 0x160 once they are used.
void FIELDSTG_controlFlight(Actor *actor)
The player's flight: it rises unless triangle is held (ACTOR_FLY), left and right turn,...
void FIELDSTG_drawActor(void *data, void *drawLayer)
The layer's sorted callback that draws an actor: its frame from its image, mirrored for the direction...
static void turnInFlight(Actor *actor, s32 held)
Held RIGHT or LEFT turns the actor one direction every 8 frames.
void FIELDSTG_startActorGauge(Actor *actor, s32 dir, Vec2 offset)
Starts the gauge game at an offset from an actor, turning the partners its way.
void FIELDSTG_setActorPose(Actor *actor, s32 set, s32 dir)
Puts an actor in an event's pose: an animation set and a direction (ACTOR_POSED)
void FIELDSTG_startDrop(Actor *actor, s32 dir, Vec2 pos, s32 height)
Starts a drop from a ledge of height.
void FIELDSTG_walkToGoal(Actor *actor)
Walks an actor to its goal tile (FIELDSTG_setActorGoal) as the pad would, then faces it the goal's wa...
void FIELDSTG_playClimbSounds(Actor *actor)
The player's climbing sound, every 16 frames.
static void beginActorAnim(Actor *actor, s32 anim)
The first frame of an action: the actor gets its shadow and the action's animation.
static void stopFlightSound(Actor *actor)
Stops the sound of the flight, if it plays.
static void runSearch(Actor *actor)
ACTOR_SEARCH: the player searches a hidden spot.
void FIELDSTG_moveByPad(Actor *actor, s32 pad)
Walks or runs an actor in the direction of the pad's arrows (an index of FIELDSTG_padDirs),...
static void runSlide(Actor *actor)
ACTOR_SLIDE: the slide on ice, with its sound.
static void runClimbUp(Actor *actor)
ACTOR_CLIMB_UP: up the wall, to its top.
static void runClimbOffBottom(Actor *actor)
ACTOR_CLIMB_OFF_BOTTOM: from the wall's foot onto the ground.
#define SET_FILE_8
void FIELDSTG_runActorAction(Actor *actor, ActorChildren *children)
Runs an actor's action, its substate (ACTOR_STAND...): the walks, the climbs and the drop from ACTOR_...
s32 FIELDSTG_checkFlightProbes(Actor *actor)
Whether a flying actor runs into the map at any of the five probes ahead of it (FIELDSTG_checkFlightP...
void FIELDSTG_drainTrail(Actor *actor)
A follower's update while its trail runs out: it finds the leader (FIELD_TASK_ACTOR) if it has none,...
void FIELDSTG_launchActor(Actor *actor, SlotDest *dest)
Sends the player flying to the tile at dest from the nearest launcher (FIELDSTG_createLaunch)
#define SET_FILE_16
static void runStop(Actor *actor)
ACTOR_STOP: the stop after a run, then standing.
#define SET_FILE_1A
static void flyOrFloat(Actor *actor, s32 held)
Held TRIANGLE flies (ACTOR_FLY, with its sound), else the actor floats and the sound stops.
static void runUse(Actor *actor)
ACTOR_USE: the player works one of the objects 0x148, 0x15F and 0x160.
static void runClimbDown(Actor *actor)
ACTOR_CLIMB_DOWN: down the wall, to its foot.
void FIELDSTG_playStepSounds(Actor *actor, s32 moving, s32 canBattle)
The player's footsteps, every 8 frames when it moves (every 32 for the characters 0x146 and 0x147) or...
void FIELDSTG_resetActorControl(Actor *actor)
Gives an actor its kind's control back: the pad for the player, none for kind 1, the trail for the pa...
void FIELDSTG_walkActorInDir(Actor *actor, s32 dir)
Walks an actor out through an exit, in a direction (ACTOR_WALK_OUT)
static void standAgain(Actor *actor)
Puts a character back to standing, under the player's control again.
void FIELDSTG_startActorSlide(Actor *actor, s32 dir)
Starts an actor sliding in a direction (SLOT_SLIDE)
void FIELDSTG_controlClimb(Actor *actor)
The player's control on a wall: up and down climb, nothing held holds on.
static void runDrop(Actor *actor)
ACTOR_DROP: the drop off a wall's edge, the fall and the landing.
static void giveControlBack(Actor *player)
Gives the player that talked back its control, walking or flying.
#define SET_FILE_0
s32 FIELDSTG_checkFlightProbe(Actor *actor, s32 x, s32 y, Vec2 offset)
Whether a flying actor runs into the map at an offset from it: a cell that isn't free,...
s32 FIELDSTG_isActorWalking(Actor *actor)
Whether an actor is still walking to its goal.
static void runGauge(Actor *actor, ActorChildren *children)
ACTOR_GAUGE: the gauge game's poses, from its start to its result's balloon.
void FIELDSTG_startClimbDown(Actor *actor, s32 dir, s32 x, s32 y, s32 height)
Starts the climb down a wall of height from its top, at (x, y)
void FIELDSTG_startActorWalk(Actor *actor)
Starts an actor walking to its goal.
static void runClimbOffTop(Actor *actor)
ACTOR_CLIMB_OFF_TOP: from the wall's top onto the ground above.
static void runStopSlide(Actor *actor)
ACTOR_STOP_SLIDE: the end of a slide, half a second before the player's control comes back.
static void runTalk(Actor *actor, ActorChildren *children)
ACTOR_TALK: the character's first talk whose conditions hold, then the player's control back and the ...
void FIELDSTG_setActorAnim(Actor *actor, s32 set)
Starts an actor's animation set from its first frame.
static void accelerateFlight(Actor *actor)
Changes the flight's height speed (zSpeed) by 4 a frame, down to -0xC0 while the player flies (ACTOR_...
#define SET_FILE_OTHER
void FIELDSTG_controlPlayer(Actor *actor)
The player's update while it walks (Actor.control) when no menu, event or transition is running: the ...
Actor * FIELDSTG_findActorAt(Vec2 *pos)
The first actor (task id 5) whose box holds the tile pos: halfWidth to each side of it,...
void FIELDSTG_setActorDir(Actor *actor, s32 dir)
Turns an actor to a direction.
void FIELDSTG_animateActor(Actor *actor)
Plays an actor's animation: when its set (animSet) changes, it loads the set's animations for the fiv...
s32 FIELDSTG_isActorAnimDone(Actor *actor)
Whether an actor's animation has played to its end.
void FIELDSTG_startClimbUp(Actor *actor, s32 dir, s32 x, s32 y, s32 height)
The climbs (SLOT_CLIMB_UP and SLOT_CLIMB_DOWN) and the drop (SLOT_DROP): the actor goes onto the wall...
s32 FIELDSTG_talkToActorAt(Actor *actor, Vec2 *pos)
Talks to the character standing at pos, or to the one it stands in for (FIELDSTG_standIns): it answer...
void FIELDSTG_stopActorSlide(Actor *actor)
Stops a sliding actor (SLOT_STOP_SLIDE)
void FIELDSTG_setActorGoal(Actor *actor, s32 x, s32 y, s32 dir)
Sets the tile an actor walks to and the direction it ends facing (FIELDSTG_walkToGoal)
void FIELDSTG_restorePlayerControl(Actor *actor)
Gives the player its pad control back, off any wall.
Balloon * FIELDSTG_createBalloon(s32 kind, s32 anim, s32 id)
Creates a balloon of a kind (its sprites) with an animation, under a task id.
Definition balloon.c:99
void FIELDSTG_followWithCamera(s32 snap, s32 id)
Points the camera at the actor id, at once if snap.
Definition camera.c:147
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
unsigned int u32
Definition common.h:12
signed short s16
Definition common.h:9
unsigned char u8
Definition common.h:8
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
GameFlags FLAGS_00
The flag bitset FLAGS_00 and the event functions.
Definition events.c:701
GameState GAME
The save data, the game mode and the methods.
Definition state.c:64
#define TASK_RUN
Definition task.h:35
#define TASK_KILL
Definition task.h:37
#define TASK_DONE
Definition task.h:36
s32 NTSC_MODE
The European version runs at 50 Hz (PAL) unless NTSC_MODE is set; its clocks then advance 0x133,...
Definition eu_settings.c:14
void FIELDSTG_resumePartners(void)
Makes the partners follow the player again (FIELDSTG_followLeader)
Definition actor.c:20
void FIELDSTG_haltPartners(void)
Makes the partners stop following: each walks out the rest of its trail (FIELDSTG_drainTrail)
Definition actor.c:7
void FIELDSTG_startWarp(s32 kind, Vec2 *pos, SlotDest *dest)
Starts a warp from pos: the field task plays the effect and the cutscene of kind, then leaves for the...
Definition field.c:1039
#define ACTOR_WALK_OUT
walks off through an exit (FIELDSTG_walkActorInDir)
Definition field_map.h:310
#define ACTOR_RUN
Definition field_map.h:308
#define ACTOR_WALK
Definition field_map.h:307
#define ACTOR_CLIMB_OFF_BOTTOM
Definition field_map.h:317
#define ACTOR_SEARCH
searches a hidden spot
Definition field_map.h:320
#define ACTOR_USE
works one of the objects 0x148, 0x15F and 0x160
Definition field_map.h:324
#define ACTOR_FLOAT
slows down in the air
Definition field_map.h:323
#define ACTOR_CLIMB_OFF_TOP
Definition field_map.h:316
#define ACTOR_CLIMB
holds on to a wall (FIELDSTG_controlClimb)
Definition field_map.h:311
#define ACTOR_STOP_SLIDE
Definition field_map.h:327
#define ACTOR_DROP
FIELDSTG_startDrop.
Definition field_map.h:318
#define ACTOR_CLIMB_UP
Definition field_map.h:312
#define ACTOR_GET_OVER_EDGE
onto the wall from above (FIELDSTG_startClimbDown)
Definition field_map.h:315
#define ACTOR_POSED
What an actor is doing, its substate (FIELDSTG_runActorAction)
Definition field_map.h:305
#define ACTOR_CLIMB_DOWN
Definition field_map.h:313
#define FIELD_TASK_ACTOR
every character (FIELDSTG_createActor)
Definition field_map.h:26
#define ACTOR_SLIDE
FIELDSTG_startActorSlide.
Definition field_map.h:326
#define ACTOR_GET_ON_WALL
from below (FIELDSTG_startClimbUp)
Definition field_map.h:314
#define ACTOR_STOP
stops after a run
Definition field_map.h:309
#define ACTOR_FLY
flies on, triangle held (FIELDSTG_controlFlight)
Definition field_map.h:322
#define ACTOR_TALK
answers the actor that talks to it (talkPartner)
Definition field_map.h:321
#define ACTOR_GAUGE
plays the gauge game (FIELDSTG_startActorGauge)
Definition field_map.h:319
#define ACTOR_USED
that object
Definition field_map.h:325
#define ACTOR_STAND
Definition field_map.h:306
FIELDSTG.PRO: the field mode, where the player walks around the map.
#define FLIGHT_OPEN
Flight (FIELDSTG_controlFlight, FIELDSTG_checkFlightProbe): an actor's z against the floor map's cell...
Definition field_mode.h:111
#define ACTOR_ANIM_FALL
Definition field_mode.h:91
#define FLIGHT_SPEED_MAX
Definition field_mode.h:118
#define SOUND_TRESUREB
Definition field_mode.h:63
#define ACTOR_ANIM_FALL_FAR
once the fall is more than 0x1800
Definition field_mode.h:92
#define ACTOR_ANIM_OPEN
a treasure's, when it is talked to
Definition field_mode.h:101
#define FLIGHT_Z_MIN
Definition field_mode.h:116
#define ACTOR_ANIM_STAND
The animation sets that the actions play (FIELDSTG_setActorAnim), by the substate that plays them.
Definition field_mode.h:80
#define ACTOR_ANIM_GAUGE_PLAY
with PLAYER09
Definition field_mode.h:87
#define ACTOR_ANIM_WALK
Definition field_mode.h:81
#define SOUND_PLAYER01
Definition field_mode.h:58
#define ACTOR_ANIM_GAUGE_END
Definition field_mode.h:89
#define ACTOR_ANIM_USED
the object's
Definition field_mode.h:103
#define TRAIL_STEPS
The last TRAIL_STEPS steps of the actor that another one follows (Actor.trail), a ring from tail to h...
Definition field_mode.h:125
#define ACTOR_ANIM_RUN
Definition field_mode.h:82
#define SOUND_DIG_MOVE
Definition field_mode.h:64
#define SOUND_PLAYER10
Definition field_mode.h:62
#define ACTOR_ANIM_LAND
Definition field_mode.h:93
#define ACTOR_ANIM_STOP
Definition field_mode.h:83
#define FIELD_SEARCH_ITEM
item 4, which the player needs to search the hidden spots
Definition field_mode.h:656
#define SOUND_TRAP_ICE
held
Definition field_mode.h:73
#define ACTOR_ANIM_SEARCH
Definition field_mode.h:84
#define FLIGHT_LEVEL(n)
n * 16 pixels, in z's 1/256 pixels
Definition field_mode.h:114
#define ACTOR_ANIM_GAUGE_WAIT
with PLAYER10, until the game ends
Definition field_mode.h:88
#define ACTOR_ANIM_CLIMB
Definition field_mode.h:100
#define FLIGHT_WALL(n)
Definition field_mode.h:112
#define ACTOR_ANIM_DROP_OFF
Definition field_mode.h:90
#define FIELD_FLAG_TALK_AHEAD
The player's FLAGS_00 codes (FIELDSTG_controlPlayer)
Definition field_mode.h:655
#define FLIGHT_Z_MAX
Definition field_mode.h:117
#define ACTOR_ANIM_CLIMB_UP
Definition field_mode.h:94
#define SOUND_PLAYER09
Definition field_mode.h:61
#define FIELD_MODE_WSTAG415
The modes of two fields that keep the file cache (FIELDSTG_keepsFileCache)
Definition field_mode.h:663
#define SOUND_PLAYER00
Definition field_mode.h:57
#define FLIGHT_LANDING
how far above a wall's top a descent stops
Definition field_mode.h:115
#define ACTOR_ANIM_USE
Definition field_mode.h:102
#define ACTOR_ANIM_GAUGE_RESULT
after the game, with a balloon
Definition field_mode.h:86
#define ACTOR_ANIM_GAUGE_START
Definition field_mode.h:85
#define FLIGHT_CEILING(n)
Definition field_mode.h:113
#define ACTOR_ANIM_CLIMB_OFF_BOTTOM
Definition field_mode.h:99
#define SOUND_PLAYER02
Definition field_mode.h:59
#define ACTOR_ANIM_CLIMB_OFF_TOP
Definition field_mode.h:97
#define ACTOR_ANIM_CLIMB_DOWN
Definition field_mode.h:95
#define ACTOR_ANIM_GET_OVER_EDGE
Definition field_mode.h:98
#define SOUND_SUB_MOVE
held
Definition field_mode.h:71
#define FLIGHT_SPEED_MAX_PAL
FLIGHT_SPEED_MAX * 6 / 5, for 50 frames a second.
Definition field_mode.h:119
#define ACTOR_ANIM_GET_ON_WALL
Definition field_mode.h:96
FieldMap FIELDSTG_map
Definition fieldstg.c:3660
s16 FIELDSTG_slideVoice
the voice of the slide's sound (ACTOR_SLIDE, SOUND_TRAP_ICE)
Definition fieldstg.c:3762
void(* FIELDSTG_checkBattle)()
FIELDSTG_countBattleSteps.
Definition fieldstg.c:3652
s32 FIELDSTG_turnedPartners[]
the partners' kinds (Actor.key2): the ones FIELDSTG_startActorGauge turns, FIELDSTG_haltPartners stop...
Definition fieldstg.c:2104
u8 FIELDSTG_probeSteps[][2]
a probe's offset: bit 0 set, bit 7 negative
Definition fieldstg.c:2062
StandIn FIELDSTG_standIns[]
up to character 0
Definition fieldstg.c:2086
u8 FIELDSTG_probes[][5]
the probes of each direction (FIELDSTG_checkFlightProbes)
Definition fieldstg.c:2034
Vec2 FIELDSTG_probePos[]
a probe's position
Definition fieldstg.c:2044
FieldState FIELDSTG_state
Definition fieldstg.c:2641
s32 FIELDSTG_padDirs[]
the direction of each combination of the pad directions
Definition fieldstg.c:2080
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
GaugeGame * FIELDSTG_createGauge(Vec2 pos)
Creates the gauge game at a tile.
Definition gauge.c:158
HiddenSpots * FIELDSTG_findHiddenSpot(Vec2 *pos, s32 select)
The hidden spots, when one is within 10 pixels of pos (selecting it if select), or NULL.
Launch * FIELDSTG_createLaunch(Actor *actor, SlotDest *dest)
Creates the flight of an actor to the tile at dest; two stages' modes (0x26C, 0x2D4) set theirs up.
Definition launch.c:166
PadState PAD
Controller input: cleared by initPad, then the methods.
Definition pad.c:168
#define PAD_CROSS
Definition pad.h:31
#define PAD_DOWN
Definition pad.h:24
#define PAD_RIGHT
Definition pad.h:23
#define PAD_TRIANGLE
Definition pad.h:32
#define PAD_UP
Definition pad.h:22
#define PAD_LEFT
Definition pad.h:25
TaskRegistry TASK_REGISTRY
Definition registry.c:122
SoundState SOUND
rsin and rcos (libgte) read rsin_tbl[a - 0x800] and the like: their addresses before the table fall i...
Definition sound.c:180
#define SOUND_COMEX113
Definition sound.h:55
Speech * FIELDSTG_createTalk(Actor *actor, s32 entry)
Creates the talk box of an actor's text entry, on the side of the screen away from where it faces and...
Definition speech.c:77
The children of an actor (FIELDSTG_updateActor)
Definition field_mode.h:141
struct Balloon * balloon
FIELDSTG_createBalloon's.
Definition field_mode.h:143
void * action
a gauge game or a launch
Definition field_mode.h:144
struct Speech * speech
FIELDSTG_createTalk's.
Definition field_mode.h:145
Where an actor's frames go in VRAM: one of the records after the FieldImage (Actor....
Definition field_map.h:114
s16 x
the texture page
Definition field_map.h:115
s16 imageX
where FIELDSTG_animateActor loads each frame
Definition field_map.h:117
A character on the field (FIELDSTG_createActor): the player (kind 0) and the other characters.
Definition field_map.h:334
s16 frameHeight
and its height
Definition field_map.h:366
s32 keepsDir
doesn't turn to the one who talks to it (characters 0x28-0x2A, 0x3E and 0x11A)
Definition field_map.h:373
s32 goalX
the tile it walks to
Definition field_map.h:369
s32 goalY
Definition field_map.h:370
u16 * talkActions
the talk's flag actions, applied when it ends, or NULL
Definition field_map.h:372
s32 animSet
the animation set it plays (setAnim)
Definition field_map.h:354
s32 climbSide
a climb shifts it a tile right (1) or left (0)
Definition field_map.h:349
s32 animTime
the frame's time left
Definition field_map.h:363
s32 z
how high it is off the ground, in 1/256 pixels (drawn that much higher)
Definition field_map.h:339
s32 walks
the pad walks it (ACTOR_WALK) instead of running
Definition field_map.h:357
s32 loadedSet
the set setAnims was loaded for
Definition field_map.h:355
s32 setAnims[5]
the set's animations, for the directions 0 to 4
Definition field_map.h:356
s32 wallHeight
the top of the climb
Definition field_map.h:351
struct ActorImage * image
Definition field_map.h:341
s32 goalDir
the direction it then faces
Definition field_map.h:371
s32 depth
the layer's ordering table entry
Definition field_map.h:344
struct Trail * trail
a follower's: the leader's steps
Definition field_map.h:375
void(* getFacingTile)(struct Actor *, Vec2 *out)
Definition field_map.h:394
s16 voice
a sound voice, or -1
Definition field_map.h:360
s32 frame[4]
the frame's image, the one loaded, and two values
Definition field_map.h:364
s32 flying
the flying player (FIELDSTG_controlFlight)
Definition field_map.h:347
Vec2 pos
Definition field_map.h:336
s32 animDone
the animation ended (isAnimDone)
Definition field_map.h:367
s32 substate
Definition field_map.h:335
s32 climbHeight
how high it has climbed, in 1/256 pixels (its shadow stays below)
Definition field_map.h:350
void(* setSubstate)(struct Actor *task, s32 substate)
Definition field_map.h:335
s16 frameWidth
the loaded image's width in pixels
Definition field_map.h:365
Vec2 tile
Definition field_map.h:337
s32 walking
walking to the goal (setGoal, FIELDSTG_walkToGoal)
Definition field_map.h:368
s32 animFile
its animations' file and index (FIELDSTG_fileEntries), or 0
Definition field_map.h:353
struct FieldImage * fieldImage
the field's image, for the shadow
Definition field_map.h:342
void(* setState)(struct Actor *task, s32 state)
Definition field_map.h:335
s32 halfWidth
half its width (FIELDSTG_actorWidths): its box's half width, and half that its half height
Definition field_map.h:346
s32 animPos
the next word of the direction's frames
Definition field_map.h:362
s32 dir
Definition field_map.h:338
void(* nextStep)(struct Actor *task)
Definition field_map.h:335
s32 key2
Definition field_map.h:335
void(* control)(struct Actor *)
its update by kind, or NULL (resetControl)
Definition field_map.h:376
s32 reloadImage
set to reload the frame's image
Definition field_map.h:358
s32 key1
Definition field_map.h:335
s32 hasShadow
drawn with a shadow
Definition field_map.h:343
void * children
Definition field_map.h:335
s32 state
Definition field_map.h:335
s32 counter
Definition field_map.h:335
s32 speed
0x400, 0x4CC in PAL's 50 Hz
Definition field_map.h:340
struct Actor * talkPartner
the actor that talks to it
Definition field_map.h:348
s32 zSpeed
added to z each frame
Definition field_map.h:359
s32 step
Definition field_map.h:335
struct FieldActorEntry * entry
what created it, or NULL
Definition field_map.h:345
void(* setState)(struct Balloon *task, s32 state)
Definition field_mode.h:174
struct FieldTalk * talks
up to the first without conditions
Definition field_map.h:196
The image of the field's effects (FieldState.images), then the actors' ActorImages.
Definition field_map.h:127
ActorImage shadow
the actors' shadow (FIELDSTG_drawActor)
Definition field_map.h:128
void(* getWalkStep)(Vec2 *pos, s32 scale, s32 dir, Vec2 *out)
FIELDSTG_getWalkStep.
Definition field_map.h:102
s32(* getCell)(s32 index, Vec2 *pos)
FIELDSTG_getMapCell.
Definition field_map.h:101
void(* getFlyStep)(Vec2 *pos, s32 scale, s32 dir, Vec2 *out)
FIELDSTG_getFlyStep.
Definition field_map.h:103
s32(* isTileFree)(Vec2 *pos)
FIELDSTG_isTileFree: 0 where a character or an object stands.
Definition field_map.h:107
s32 busy
an event, a warp, a launch or a battle has the player
Definition field_map.h:468
s32 battleStarting
an encounter started (FIELDSTG_startEncounter)
Definition field_map.h:469
s32 menuOpen
the field menu (START) or the inn (FIELDSTG_openInn) is open: the pad doesn't move the player
Definition field_map.h:464
s32 acting
the player talks, climbs, slides or searches
Definition field_map.h:470
What a character says (FIELDSTG_runActorAction): the first whose conditions hold, or the last,...
Definition field_map.h:176
s32 entry
its text's entry in the field's text file (FIELDSTG_createTalk)
Definition field_map.h:179
u16 * actions
FLAGS_00.applyActions's when it ends, or NULL.
Definition field_map.h:178
u16 * conditions
FLAGS_00.checkConditions's.
Definition field_map.h:177
void *(* getEntry)(u32 fileAndIndex)
Definition file.h:96
void(* applyActions)(u16 *list)
Definition game_state.h:54
void(* applyAction)(s32 code, s32 value)
Definition game_state.h:52
s32(* checkCondition)(u16 code, u16 value)
Definition game_state.h:53
s32(* checkConditions)(u16 *list)
Definition game_state.h:51
s32(* getMode)(void)
Definition game_state.h:19
GameFuncs funcs
Definition game_state.h:582
void *(* getPrim)(void)
Definition gfx.h:19
s32(* getFrameTime)(void)
Definition gfx.h:32
s32(* getFrameCount)(void)
Definition gfx.h:30
void(* setPrim)(void *next)
Definition gfx.h:20
GfxFuncs funcs
Definition gfx.h:77
The map's hidden spots (FIELD_TASK_HIDDEN_SPOTS, FIELDSTG_createHiddenSpots): one of them,...
Definition field_mode.h:558
A drawing layer (GFX.funcs.createLayer): a DRAWENV with a pair of ordering tables,...
Definition gfx.h:128
void(* getScroll)()
Definition gfx.h:148
u_long *(* getOtEntry)(struct Layer *, s32 depth)
Definition gfx.h:155
s32(* getHeld)(s32 pad)
Definition pad.h:126
s32(* getPressed)(s32 pad)
Definition pad.h:125
Where a slot leads: a StageSlot from its arg on, as the warps (FieldTask.warp) and the launches (Laun...
Definition field_map.h:291
short(* playSound)(s32 id)
returns the voice of a key-on
Definition sound.h:187
void(* keyOff)(s32 id, s16 voice)
Definition sound.h:189
s16 character
Actor.key1.
Definition field_mode.h:187
void *(* findNext)(void)
Definition task.h:19
void *(* find)(s32 id, s32 key1, s32 key2)
Definition task.h:18
Tasks created with an id, so that other code can find them.
Definition task.h:70
TaskFuncs funcs
Definition task.h:76
Uploads TIM images to VRAM (initTimLoader); acts on TIM_LOADER.
Definition gfx.h:325
void(* setClutPos)()
(x, y)
Definition gfx.h:337
void(* setImagePos)()
(x, y)
Definition gfx.h:336
void(* load)()
(TIM)
Definition gfx.h:335
u16 w
size of the last image
Definition gfx.h:326
u16 h
Definition gfx.h:327
TrailStep steps[64]
Definition field_mode.h:137
Actor * leader
Definition field_mode.h:134
s32 head
Definition field_mode.h:135
s32 tail
Definition field_mode.h:136
Definition gfx.h:352
s32 y
Definition gfx.h:354
s32 x
Definition gfx.h:353
void initTimLoader(TimLoader *obj)
Clears a TIM loader, gives it its methods and binds it.
Definition tim_loader.c:119
The next free primitive of the packet buffer (getPrim), written as the kind that is drawn next.
Definition gfx.h:344
POLY_FT4 * ft4
Definition gfx.h:348
DR_TPAGE * tpage
Definition gfx.h:349
void * any
Definition gfx.h:345
SPRT * sprt
Definition gfx.h:346