Rename animation sad

This commit is contained in:
Alexander Batalov 2022-07-07 11:28:21 +03:00
parent 158826ed63
commit c562d83020
5 changed files with 206 additions and 205 deletions

View File

@ -31,8 +31,9 @@
#include <stdio.h>
#include <string.h>
#define ANIMATION_SEQUENCE_LIST_CAPACITY (32)
#define ANIMATION_DESCRIPTION_LIST_CAPACITY (55)
#define ANIMATION_SEQUENCE_LIST_CAPACITY 32
#define ANIMATION_DESCRIPTION_LIST_CAPACITY 55
#define ANIMATION_SAD_LIST_CAPACITY 24
typedef struct AnimationDescription {
int type;
@ -84,13 +85,21 @@ typedef struct PathNode {
int field_10;
} PathNode;
typedef struct STRUCT_530014 {
// TODO: I don't know what `sad` means, but it's definitely better than
// `STRUCT_530014`. Find a better name.
typedef struct AnimationSad {
int flags; // flags
Object* obj;
int fid; // fid
int field_C;
unsigned int field_10;
unsigned int field_14; // animation speed?
int anim;
// Timestamp (in game ticks) when animation last occurred.
unsigned int animationTimestamp;
// Number of ticks per frame (taking art's fps and overall animation speed
// settings into account).
unsigned int ticksPerFrame;
int animationSequenceIndex;
int field_1C; // length of field_28
int field_20; // current index in field_28
@ -99,7 +108,7 @@ typedef struct STRUCT_530014 {
unsigned char rotations[3200];
STRUCT_530014_28 field_28[200];
};
} STRUCT_530014;
} AnimationSad;
static int _anim_free_slot(int a1);
static void _anim_cleanup();
@ -123,19 +132,19 @@ static void _object_anim_compact();
static int actionRotate(Object* obj, int delta, int animationSequenceIndex);
static int _anim_change_fid(Object* obj, int animationSequenceIndex, int fid);
static int _check_gravity(int tile, int elevation);
static unsigned int _compute_tpf(Object* object, int fid);
static unsigned int animationComputeTicksPerFrame(Object* object, int fid);
// 0x510718
static int _curr_sad = 0;
static int gAnimationCurrentSad = 0;
// 0x51071C
static int gAnimationSequenceCurrentIndex = -1;
// 0x510720
static int _anim_in_init = 0;
static bool gAnimationInInit = false;
// 0x510724
static bool _anim_in_anim_stop = false;
static bool gAnimationInStop = false;
// 0x510728
static bool _anim_in_bk = false;
@ -150,7 +159,7 @@ static unsigned int _last_time_ = 0;
static unsigned int _next_time = 0;
// 0x530014
static STRUCT_530014 _sad[24];
static AnimationSad gAnimationSads[ANIMATION_SAD_LIST_CAPACITY];
// 0x542FD4
static PathNode gClosedPathNodeList[2000];
@ -174,20 +183,20 @@ static Object* dword_56C7E0[100];
// 0x413A20
void animationInit()
{
_anim_in_init = 1;
gAnimationInInit = true;
animationReset();
_anim_in_init = 0;
gAnimationInInit = false;
}
// 0x413A40
void animationReset()
{
if (!_anim_in_init) {
if (!gAnimationInInit) {
// NOTE: Uninline.
_anim_stop();
animationStop();
}
_curr_sad = 0;
gAnimationCurrentSad = 0;
gAnimationSequenceCurrentIndex = -1;
for (int index = 0; index < ANIMATION_SEQUENCE_LIST_CAPACITY; index++) {
@ -200,7 +209,7 @@ void animationReset()
void animationExit()
{
// NOTE: Uninline.
_anim_stop();
animationStop();
}
// 0x413AF4
@ -210,7 +219,7 @@ int reg_anim_begin(int flags)
return -1;
}
if (_anim_in_anim_stop) {
if (gAnimationInStop) {
return -1;
}
@ -1390,7 +1399,6 @@ static int _anim_set_end(int animationSequenceIndex)
{
AnimationSequence* animationSequence;
AnimationDescription* animationDescription;
STRUCT_530014* ptr_530014;
int i;
Rect v27;
@ -1403,10 +1411,10 @@ static int _anim_set_end(int animationSequenceIndex)
return -1;
}
for (i = 0; i < _curr_sad; i++) {
ptr_530014 = &(_sad[i]);
if (ptr_530014->animationSequenceIndex == animationSequenceIndex) {
ptr_530014->field_20 = -1000;
for (i = 0; i < gAnimationCurrentSad; i++) {
AnimationSad* sad = &(gAnimationSads[i]);
if (sad->animationSequenceIndex == animationSequenceIndex) {
sad->field_20 = -1000;
}
}
@ -1449,9 +1457,9 @@ static int _anim_set_end(int animationSequenceIndex)
}
if (k == animationSequence->animationIndex) {
for (int m = 0; m < _curr_sad; m++) {
if (_sad[m].obj == owner) {
_sad[m].field_20 = -1000;
for (int m = 0; m < gAnimationCurrentSad; m++) {
if (gAnimationSads[m].obj == owner) {
gAnimationSads[m].field_20 = -1000;
break;
}
}
@ -1975,25 +1983,25 @@ static int animateMoveObjectToObject(Object* from, Object* to, int a3, int anim,
return -1;
}
STRUCT_530014* ptr = &(_sad[moveSadIndex]);
AnimationSad* sad = &(gAnimationSads[moveSadIndex]);
// NOTE: Original code is somewhat different. Due to some kind of
// optimization this value is either 1 or 2, which is later used in
// subsequent calculations and rotations array lookup.
bool isMultihex = (from->flags & OBJECT_MULTIHEX);
ptr->field_1C -= (isMultihex ? 2 : 1);
if (ptr->field_1C <= 0) {
ptr->field_20 = -1000;
sad->field_1C -= (isMultihex ? 2 : 1);
if (sad->field_1C <= 0) {
sad->field_20 = -1000;
_anim_set_continue(animationSequenceIndex, 0);
}
ptr->field_24 = tileGetTileInDirection(to->tile, ptr->rotations[isMultihex ? ptr->field_1C + 1 : ptr->field_1C], 1);
sad->field_24 = tileGetTileInDirection(to->tile, sad->rotations[isMultihex ? sad->field_1C + 1 : sad->field_1C], 1);
if (isMultihex) {
ptr->field_24 = tileGetTileInDirection(ptr->field_24, ptr->rotations[ptr->field_1C], 1);
sad->field_24 = tileGetTileInDirection(sad->field_24, sad->rotations[sad->field_1C], 1);
}
if (a3 != -1 && a3 < ptr->field_1C) {
ptr->field_1C = a3;
if (a3 != -1 && a3 < sad->field_1C) {
sad->field_1C = a3;
}
return 0;
@ -2002,7 +2010,6 @@ static int animateMoveObjectToObject(Object* from, Object* to, int a3, int anim,
// 0x416CFC
static int animateMoveObjectToTile(Object* obj, int tile, int elev, int a4, int anim, int animationSequenceIndex)
{
STRUCT_530014* ptr;
int v1;
v1 = _anim_move(obj, tile, elev, -1, anim, 0, animationSequenceIndex);
@ -2011,16 +2018,16 @@ static int animateMoveObjectToTile(Object* obj, int tile, int elev, int a4, int
}
if (_obj_blocking_at(obj, tile, elev)) {
ptr = &(_sad[v1]);
ptr->field_1C--;
if (ptr->field_1C <= 0) {
ptr->field_20 = -1000;
AnimationSad* sad = &(gAnimationSads[v1]);
sad->field_1C--;
if (sad->field_1C <= 0) {
sad->field_20 = -1000;
_anim_set_continue(animationSequenceIndex, 0);
}
ptr->field_24 = tileGetTileInDirection(tile, ptr->rotations[ptr->field_1C], 1);
if (a4 != -1 && a4 < ptr->field_1C) {
ptr->field_1C = a4;
sad->field_24 = tileGetTileInDirection(tile, sad->rotations[sad->field_1C], 1);
if (a4 != -1 && a4 < sad->field_1C) {
sad->field_1C = a4;
}
}
@ -2030,62 +2037,60 @@ static int animateMoveObjectToTile(Object* obj, int tile, int elev, int a4, int
// 0x416DFC
static int _anim_move(Object* obj, int tile, int elev, int a3, int anim, int a5, int animationSequenceIndex)
{
STRUCT_530014* ptr;
if (_curr_sad == 24) {
if (gAnimationCurrentSad == ANIMATION_SAD_LIST_CAPACITY) {
return -1;
}
ptr = &(_sad[_curr_sad]);
ptr->obj = obj;
AnimationSad* sad = &(gAnimationSads[gAnimationCurrentSad]);
sad->obj = obj;
if (a5) {
ptr->flags = 0x20;
sad->flags = 0x20;
} else {
ptr->flags = 0;
sad->flags = 0;
}
ptr->field_20 = -2000;
ptr->fid = buildFid((obj->fid & 0xF000000) >> 24, obj->fid & 0xFFF, anim, (obj->fid & 0xF000) >> 12, obj->rotation + 1);
ptr->field_10 = 0;
ptr->field_14 = _compute_tpf(obj, ptr->fid);
ptr->field_24 = tile;
ptr->animationSequenceIndex = animationSequenceIndex;
ptr->field_C = anim;
sad->field_20 = -2000;
sad->fid = buildFid((obj->fid & 0xF000000) >> 24, obj->fid & 0xFFF, anim, (obj->fid & 0xF000) >> 12, obj->rotation + 1);
sad->animationTimestamp = 0;
sad->ticksPerFrame = animationComputeTicksPerFrame(obj, sad->fid);
sad->field_24 = tile;
sad->animationSequenceIndex = animationSequenceIndex;
sad->anim = anim;
ptr->field_1C = _make_path(obj, obj->tile, tile, ptr->rotations, a5);
if (ptr->field_1C == 0) {
ptr->field_20 = -1000;
sad->field_1C = _make_path(obj, obj->tile, tile, sad->rotations, a5);
if (sad->field_1C == 0) {
sad->field_20 = -1000;
return -1;
}
if (a3 != -1 && ptr->field_1C > a3) {
ptr->field_1C = a3;
if (a3 != -1 && sad->field_1C > a3) {
sad->field_1C = a3;
}
return _curr_sad++;
return gAnimationCurrentSad++;
}
// 0x416F54
static int _anim_move_straight_to_tile(Object* obj, int tile, int elevation, int anim, int animationSequenceIndex, int flags)
{
if (_curr_sad == 24) {
if (gAnimationCurrentSad == ANIMATION_SAD_LIST_CAPACITY) {
return -1;
}
STRUCT_530014* ptr = &(_sad[_curr_sad]);
ptr->obj = obj;
ptr->flags = flags | 0x02;
AnimationSad* sad = &(gAnimationSads[gAnimationCurrentSad]);
sad->obj = obj;
sad->flags = flags | 0x02;
if (anim == -1) {
ptr->fid = obj->fid;
ptr->flags |= 0x04;
sad->fid = obj->fid;
sad->flags |= 0x04;
} else {
ptr->fid = buildFid((obj->fid & 0xF000000) >> 24, obj->fid & 0xFFF, anim, (obj->fid & 0xF000) >> 12, obj->rotation + 1);
sad->fid = buildFid((obj->fid & 0xF000000) >> 24, obj->fid & 0xFFF, anim, (obj->fid & 0xF000) >> 12, obj->rotation + 1);
}
ptr->field_20 = -2000;
ptr->field_10 = 0;
ptr->field_14 = _compute_tpf(obj, ptr->fid);
ptr->animationSequenceIndex = animationSequenceIndex;
sad->field_20 = -2000;
sad->animationTimestamp = 0;
sad->ticksPerFrame = animationComputeTicksPerFrame(obj, sad->fid);
sad->animationSequenceIndex = animationSequenceIndex;
int v15;
if (((obj->fid & 0xF000000) >> 24) == OBJ_TYPE_CRITTER) {
@ -2097,13 +2102,13 @@ static int _anim_move_straight_to_tile(Object* obj, int tile, int elevation, int
v15 = 32;
}
ptr->field_1C = _make_straight_path(obj, obj->tile, tile, ptr->field_28, NULL, v15);
if (ptr->field_1C == 0) {
ptr->field_20 = -1000;
sad->field_1C = _make_straight_path(obj, obj->tile, tile, sad->field_28, NULL, v15);
if (sad->field_1C == 0) {
sad->field_20 = -1000;
return -1;
}
_curr_sad++;
gAnimationCurrentSad++;
return 0;
}
@ -2111,33 +2116,31 @@ static int _anim_move_straight_to_tile(Object* obj, int tile, int elevation, int
// 0x41712C
static int _anim_move_on_stairs(Object* obj, int tile, int elevation, int anim, int animationSequenceIndex)
{
STRUCT_530014* ptr;
if (_curr_sad == 24) {
if (gAnimationCurrentSad == ANIMATION_SAD_LIST_CAPACITY) {
return -1;
}
ptr = &(_sad[_curr_sad]);
ptr->flags = 0x02;
ptr->obj = obj;
AnimationSad* sad = &(gAnimationSads[gAnimationCurrentSad]);
sad->flags = 0x02;
sad->obj = obj;
if (anim == -1) {
ptr->fid = obj->fid;
ptr->flags |= 0x04;
sad->fid = obj->fid;
sad->flags |= 0x04;
} else {
ptr->fid = buildFid((obj->fid & 0xF000000) >> 24, obj->fid & 0xFFF, anim, (obj->fid & 0xF000) >> 12, obj->rotation + 1);
sad->fid = buildFid((obj->fid & 0xF000000) >> 24, obj->fid & 0xFFF, anim, (obj->fid & 0xF000) >> 12, obj->rotation + 1);
}
ptr->field_20 = -2000;
ptr->field_10 = 0;
ptr->field_14 = _compute_tpf(obj, ptr->fid);
ptr->animationSequenceIndex = animationSequenceIndex;
sad->field_20 = -2000;
sad->animationTimestamp = 0;
sad->ticksPerFrame = animationComputeTicksPerFrame(obj, sad->fid);
sad->animationSequenceIndex = animationSequenceIndex;
// TODO: Incomplete.
// ptr->field_1C = _make_stair_path(obj, obj->tile_index, obj->elevation, tile, elevation, ptr->field_28, 0);
if (ptr->field_1C == 0) {
ptr->field_20 = -1000;
if (sad->field_1C == 0) {
sad->field_20 = -1000;
return -1;
}
_curr_sad++;
gAnimationCurrentSad++;
return 0;
}
@ -2145,9 +2148,7 @@ static int _anim_move_on_stairs(Object* obj, int tile, int elevation, int anim,
// 0x417248
static int _check_for_falling(Object* obj, int anim, int a3)
{
STRUCT_530014* ptr;
if (_curr_sad == 24) {
if (gAnimationCurrentSad == ANIMATION_SAD_LIST_CAPACITY) {
return -1;
}
@ -2155,26 +2156,26 @@ static int _check_for_falling(Object* obj, int anim, int a3)
return -1;
}
ptr = &(_sad[_curr_sad]);
ptr->flags = 0x02;
ptr->obj = obj;
AnimationSad* sad = &(gAnimationSads[gAnimationCurrentSad]);
sad->flags = 0x02;
sad->obj = obj;
if (anim == -1) {
ptr->fid = obj->fid;
ptr->flags |= 0x04;
sad->fid = obj->fid;
sad->flags |= 0x04;
} else {
ptr->fid = buildFid((obj->fid & 0xF000000) >> 24, obj->fid & 0xFFF, anim, (obj->fid & 0xF000) >> 12, obj->rotation + 1);
sad->fid = buildFid((obj->fid & 0xF000000) >> 24, obj->fid & 0xFFF, anim, (obj->fid & 0xF000) >> 12, obj->rotation + 1);
}
ptr->field_20 = -2000;
ptr->field_10 = 0;
ptr->field_14 = _compute_tpf(obj, ptr->fid);
ptr->animationSequenceIndex = a3;
ptr->field_1C = _make_straight_path_func(obj, obj->tile, obj->tile, ptr->field_28, 0, 16, _obj_blocking_at);
if (ptr->field_1C == 0) {
ptr->field_20 = -1000;
sad->field_20 = -2000;
sad->animationTimestamp = 0;
sad->ticksPerFrame = animationComputeTicksPerFrame(obj, sad->fid);
sad->animationSequenceIndex = a3;
sad->field_1C = _make_straight_path_func(obj, obj->tile, obj->tile, sad->field_28, 0, 16, _obj_blocking_at);
if (sad->field_1C == 0) {
sad->field_20 = -1000;
return -1;
}
_curr_sad++;
gAnimationCurrentSad++;
return 0;
}
@ -2182,26 +2183,26 @@ static int _check_for_falling(Object* obj, int anim, int a3)
// 0x417360
static void _object_move(int index)
{
STRUCT_530014* p530014 = &(_sad[index]);
Object* object = p530014->obj;
AnimationSad* sad = &(gAnimationSads[index]);
Object* object = sad->obj;
Rect dirty;
Rect temp;
if (p530014->field_20 == -2000) {
if (sad->field_20 == -2000) {
objectSetLocation(object, object->tile, object->elevation, &dirty);
objectSetFrame(object, 0, &temp);
rectUnion(&dirty, &temp, &dirty);
objectSetRotation(object, p530014->rotations[0], &temp);
objectSetRotation(object, sad->rotations[0], &temp);
rectUnion(&dirty, &temp, &dirty);
int fid = buildFid((object->fid & 0xF000000) >> 24, object->fid & 0xFFF, p530014->field_C, (object->fid & 0xF000) >> 12, object->rotation + 1);
int fid = buildFid((object->fid & 0xF000000) >> 24, object->fid & 0xFFF, sad->anim, (object->fid & 0xF000) >> 12, object->rotation + 1);
objectSetFid(object, fid, &temp);
rectUnion(&dirty, &temp, &dirty);
p530014->field_20 = 0;
sad->field_20 = 0;
} else {
objectSetNextFrame(object, &dirty);
}
@ -2222,7 +2223,7 @@ static void _object_move(int index)
_obj_offset(object, frameX, frameY, &temp);
rectUnion(&dirty, &temp, &dirty);
int rotation = p530014->rotations[p530014->field_20];
int rotation = sad->rotations[sad->field_20];
int y = dword_51D984[rotation];
int x = _off_tile[rotation];
if (x > 0 && x <= object->x || x < 0 && x >= object->x || y > 0 && y <= object->y || y < 0 && y >= object->y) {
@ -2233,20 +2234,20 @@ static void _object_move(int index)
Object* v12 = _obj_blocking_at(object, v10, object->elevation);
if (v12 != NULL) {
if (!canUseDoor(object, v12)) {
p530014->field_1C = _make_path(object, object->tile, p530014->field_24, p530014->rotations, 1);
if (p530014->field_1C != 0) {
sad->field_1C = _make_path(object, object->tile, sad->field_24, sad->rotations, 1);
if (sad->field_1C != 0) {
objectSetLocation(object, object->tile, object->elevation, &temp);
rectUnion(&dirty, &temp, &dirty);
objectSetFrame(object, 0, &temp);
rectUnion(&dirty, &temp, &dirty);
objectSetRotation(object, p530014->rotations[0], &temp);
objectSetRotation(object, sad->rotations[0], &temp);
rectUnion(&dirty, &temp, &dirty);
p530014->field_20 = 0;
sad->field_20 = 0;
} else {
p530014->field_20 = -1000;
sad->field_20 = -1000;
}
v10 = -1;
} else {
@ -2281,12 +2282,12 @@ static void _object_move(int index)
v17 = (object->data.critter.combat.ap + _combat_free_move) <= 0;
}
p530014->field_20 += 1;
sad->field_20 += 1;
if (p530014->field_20 == p530014->field_1C || v17) {
p530014->field_20 = -1000;
if (sad->field_20 == sad->field_1C || v17) {
sad->field_20 = -1000;
} else {
objectSetRotation(object, p530014->rotations[p530014->field_20], &temp);
objectSetRotation(object, sad->rotations[sad->field_20], &temp);
rectUnion(&dirty, &temp, &dirty);
_obj_offset(object, x, y, &temp);
@ -2296,23 +2297,23 @@ static void _object_move(int index)
}
tileWindowRefreshRect(&dirty, object->elevation);
if (p530014->field_20 == -1000) {
_anim_set_continue(p530014->animationSequenceIndex, 1);
if (sad->field_20 == -1000) {
_anim_set_continue(sad->animationSequenceIndex, 1);
}
}
// 0x4177C0
static void _object_straight_move(int index)
{
STRUCT_530014* p530014 = &(_sad[index]);
Object* object = p530014->obj;
AnimationSad* sad = &(gAnimationSads[index]);
Object* object = sad->obj;
Rect dirtyRect;
Rect temp;
if (p530014->field_20 == -2000) {
objectSetFid(object, p530014->fid, &dirtyRect);
p530014->field_20 = 0;
if (sad->field_20 == -2000) {
objectSetFid(object, sad->fid, &dirtyRect);
sad->field_20 = 0;
} else {
objectGetRect(object, &dirtyRect);
}
@ -2323,13 +2324,13 @@ static void _object_straight_move(int index)
int lastFrame = artGetFrameCount(art) - 1;
artUnlock(cacheHandle);
if ((p530014->flags & 0x04) == 0 && ((p530014->flags & 0x10) == 0 || lastFrame > object->frame)) {
if ((sad->flags & 0x04) == 0 && ((sad->flags & 0x10) == 0 || lastFrame > object->frame)) {
objectSetNextFrame(object, &temp);
rectUnion(&dirtyRect, &temp, &dirtyRect);
}
if (p530014->field_20 < p530014->field_1C) {
STRUCT_530014_28* v12 = &(p530014->field_28[p530014->field_20]);
if (sad->field_20 < sad->field_1C) {
STRUCT_530014_28* v12 = &(sad->field_28[sad->field_20]);
objectSetLocation(object, v12->tile, v12->elevation, &temp);
rectUnion(&dirtyRect, &temp, &dirtyRect);
@ -2337,17 +2338,17 @@ static void _object_straight_move(int index)
_obj_offset(object, v12->x, v12->y, &temp);
rectUnion(&dirtyRect, &temp, &dirtyRect);
p530014->field_20++;
sad->field_20++;
}
if (p530014->field_20 == p530014->field_1C && ((p530014->flags & 0x10) == 0 || object->frame == lastFrame)) {
p530014->field_20 = -1000;
if (sad->field_20 == sad->field_1C && ((sad->flags & 0x10) == 0 || object->frame == lastFrame)) {
sad->field_20 = -1000;
}
tileWindowRefreshRect(&dirtyRect, p530014->obj->elevation);
tileWindowRefreshRect(&dirtyRect, sad->obj->elevation);
if (p530014->field_20 == -1000) {
_anim_set_continue(p530014->animationSequenceIndex, 1);
if (sad->field_20 == -1000) {
_anim_set_continue(sad->animationSequenceIndex, 1);
}
}
}
@ -2355,18 +2356,18 @@ static void _object_straight_move(int index)
// 0x4179B8
static int _anim_animate(Object* obj, int anim, int animationSequenceIndex, int flags)
{
if (_curr_sad == 24) {
if (gAnimationCurrentSad == ANIMATION_SAD_LIST_CAPACITY) {
return -1;
}
STRUCT_530014* ptr = &(_sad[_curr_sad]);
AnimationSad* sad = &(gAnimationSads[gAnimationCurrentSad]);
int fid;
if (anim == ANIM_TAKE_OUT) {
ptr->flags = 0;
sad->flags = 0;
fid = buildFid((obj->fid & 0xF000000) >> 24, obj->fid & 0xFFF, ANIM_TAKE_OUT, flags, obj->rotation + 1);
} else {
ptr->flags = flags;
sad->flags = flags;
fid = buildFid((obj->fid & 0xF000000) >> 24, obj->fid & 0xFFF, anim, (obj->fid & 0xF000) >> 12, obj->rotation + 1);
}
@ -2374,15 +2375,15 @@ static int _anim_animate(Object* obj, int anim, int animationSequenceIndex, int
return -1;
}
ptr->obj = obj;
ptr->fid = fid;
ptr->animationSequenceIndex = animationSequenceIndex;
ptr->field_10 = 0;
ptr->field_14 = _compute_tpf(obj, ptr->fid);
ptr->field_20 = 0;
ptr->field_1C = 0;
sad->obj = obj;
sad->fid = fid;
sad->animationSequenceIndex = animationSequenceIndex;
sad->animationTimestamp = 0;
sad->ticksPerFrame = animationComputeTicksPerFrame(obj, sad->fid);
sad->field_20 = 0;
sad->field_1C = 0;
_curr_sad++;
gAnimationCurrentSad++;
return 0;
}
@ -2390,33 +2391,33 @@ static int _anim_animate(Object* obj, int anim, int animationSequenceIndex, int
// 0x417B30
void _object_animate()
{
if (_curr_sad == 0) {
if (gAnimationCurrentSad == 0) {
return;
}
_anim_in_bk = 1;
for (int index = 0; index < _curr_sad; index++) {
STRUCT_530014* p530014 = &(_sad[index]);
if (p530014->field_20 == -1000) {
for (int index = 0; index < gAnimationCurrentSad; index++) {
AnimationSad* sad = &(gAnimationSads[index]);
if (sad->field_20 == -1000) {
continue;
}
Object* object = p530014->obj;
Object* object = sad->obj;
unsigned int time = _get_time();
if (getTicksBetween(time, p530014->field_10) < p530014->field_14) {
if (getTicksBetween(time, sad->animationTimestamp) < sad->ticksPerFrame) {
continue;
}
p530014->field_10 = time;
sad->animationTimestamp = time;
if (animationRunSequence(p530014->animationSequenceIndex) == -1) {
if (animationRunSequence(sad->animationSequenceIndex) == -1) {
continue;
}
if (p530014->field_1C > 0) {
if ((p530014->flags & 0x02) != 0) {
if (sad->field_1C > 0) {
if ((sad->flags & 0x02) != 0) {
_object_straight_move(index);
} else {
int savedTile = object->tile;
@ -2428,15 +2429,15 @@ void _object_animate()
continue;
}
if (p530014->field_20 == 0) {
for (int index = 0; index < _curr_sad; index++) {
STRUCT_530014* other530014 = &(_sad[index]);
if (object == other530014->obj && other530014->field_20 == -2000) {
other530014->field_20 = -1000;
_anim_set_continue(other530014->animationSequenceIndex, 1);
if (sad->field_20 == 0) {
for (int index = 0; index < gAnimationCurrentSad; index++) {
AnimationSad* otherSad = &(gAnimationSads[index]);
if (object == otherSad->obj && otherSad->field_20 == -2000) {
otherSad->field_20 = -1000;
_anim_set_continue(otherSad->animationSequenceIndex, 1);
}
}
p530014->field_20 = -2000;
sad->field_20 = -2000;
}
Rect dirtyRect;
@ -2444,20 +2445,20 @@ void _object_animate()
objectGetRect(object, &dirtyRect);
if (object->fid == p530014->fid) {
if ((p530014->flags & 0x01) == 0) {
if (object->fid == sad->fid) {
if ((sad->flags & 0x01) == 0) {
CacheEntry* cacheHandle;
Art* art = artLock(object->fid, &cacheHandle);
if (art != NULL) {
if ((p530014->flags & 0x80) == 0 && object->frame == artGetFrameCount(art) - 1) {
p530014->field_20 = -1000;
if ((sad->flags & 0x80) == 0 && object->frame == artGetFrameCount(art) - 1) {
sad->field_20 = -1000;
artUnlock(cacheHandle);
if ((p530014->flags & 0x40) != 0 && objectHide(object, &tempRect) == 0) {
if ((sad->flags & 0x40) != 0 && objectHide(object, &tempRect) == 0) {
tileWindowRefreshRect(&tempRect, object->elevation);
}
_anim_set_continue(p530014->animationSequenceIndex, 1);
_anim_set_continue(sad->animationSequenceIndex, 1);
continue;
} else {
objectSetNextFrame(object, &tempRect);
@ -2479,7 +2480,7 @@ void _object_animate()
continue;
}
if ((p530014->flags & 0x80) != 0 || object->frame != 0) {
if ((sad->flags & 0x80) != 0 || object->frame != 0) {
int x;
int y;
@ -2500,8 +2501,8 @@ void _object_animate()
continue;
}
p530014->field_20 = -1000;
_anim_set_continue(p530014->animationSequenceIndex, 1);
sad->field_20 = -1000;
_anim_set_continue(sad->animationSequenceIndex, 1);
} else {
int x;
int y;
@ -2517,13 +2518,13 @@ void _object_animate()
}
Rect v29;
objectSetFid(object, p530014->fid, &v29);
objectSetFid(object, sad->fid, &v29);
rectUnion(&dirtyRect, &v29, &dirtyRect);
art = artLock(object->fid, &cacheHandle);
if (art != NULL) {
int frame;
if ((p530014->flags & 0x01) != 0) {
if ((sad->flags & 0x01) != 0) {
frame = artGetFrameCount(art) - 1;
} else {
frame = 0;
@ -2566,27 +2567,27 @@ static void _object_anim_compact()
}
int index = 0;
for (; index < _curr_sad; index++) {
if (_sad[index].field_20 == -1000) {
for (; index < gAnimationCurrentSad; index++) {
if (gAnimationSads[index].field_20 == -1000) {
int v2 = index + 1;
for (; v2 < _curr_sad; v2++) {
if (_sad[v2].field_20 != -1000) {
for (; v2 < gAnimationCurrentSad; v2++) {
if (gAnimationSads[v2].field_20 != -1000) {
break;
}
}
if (v2 == _curr_sad) {
if (v2 == gAnimationCurrentSad) {
break;
}
if (index != v2) {
memcpy(&(_sad[index]), &(_sad[v2]), sizeof(STRUCT_530014));
_sad[v2].field_20 = -1000;
_sad[v2].flags = 0;
memcpy(&(gAnimationSads[index]), &(gAnimationSads[v2]), sizeof(AnimationSad));
gAnimationSads[v2].field_20 = -1000;
gAnimationSads[v2].flags = 0;
}
}
}
_curr_sad = index;
gAnimationCurrentSad = index;
}
// 0x417FFC
@ -2886,17 +2887,17 @@ static int _anim_change_fid(Object* obj, int animationSequenceIndex, int fid)
}
// 0x4186CC
void _anim_stop()
void animationStop()
{
_anim_in_anim_stop = 1;
gAnimationInStop = true;
gAnimationSequenceCurrentIndex = -1;
for (int index = 0; index < ANIMATION_SEQUENCE_LIST_CAPACITY; index++) {
_anim_set_end(index);
}
_anim_in_anim_stop = 0;
_curr_sad = 0;
gAnimationInStop = false;
gAnimationCurrentSad = 0;
}
// 0x418708
@ -2917,7 +2918,7 @@ static int _check_gravity(int tile, int elevation)
}
// 0x418794
static unsigned int _compute_tpf(Object* object, int fid)
static unsigned int animationComputeTicksPerFrame(Object* object, int fid)
{
int fps;

View File

@ -167,6 +167,6 @@ int _dude_run(int a1);
void _dude_fidget();
void _dude_stand(Object* obj, int rotation, int fid);
void _dude_standup(Object* a1);
void _anim_stop();
void animationStop();
#endif /* ANIMATION_H */

View File

@ -2435,7 +2435,7 @@ int _combatAIInfoSetLastItem(Object* obj, Object* a2)
static void _combat_begin(Object* a1)
{
_combat_turn_running = 0;
_anim_stop();
animationStop();
tickersRemove(_dude_fidget);
_combat_elev = gElevation;

View File

@ -909,7 +909,7 @@ int _gdialogInitFromScript(int headFid, int reaction)
return 0;
}
_anim_stop();
animationStop();
_boxesWereDisabled = indicatorBarHide();
gGameDialogSpeakerIsPartyMember = objectIsPartyMember(gGameDialogSpeaker);

View File

@ -693,7 +693,7 @@ void _map_new_map()
gMapHeader.name[0] = '\0';
gMapHeader.enteringTile = 20100;
_obj_remove_all();
_anim_stop();
animationStop();
if (gMapGlobalVars != NULL) {
internal_free(gMapGlobalVars);
@ -792,7 +792,7 @@ static int mapLoad(File* stream)
windowFill(gIsoWindow, 0, 0, _scr_size.right - _scr_size.left + 1, _scr_size.bottom - _scr_size.top - 99, _colorTable[0]);
windowRefresh(gIsoWindow);
_anim_stop();
animationStop();
scriptsDisable();
gMapSid = -1;
@ -1215,13 +1215,13 @@ int mapHandleTransition()
if (gMapTransition.map == -1) {
if (!isInCombat()) {
_anim_stop();
animationStop();
_wmTownMap();
memset(&gMapTransition, 0, sizeof(gMapTransition));
}
} else if (gMapTransition.map == -2) {
if (!isInCombat()) {
_anim_stop();
animationStop();
_wmWorldMap();
memset(&gMapTransition, 0, sizeof(gMapTransition));
}
@ -1405,7 +1405,7 @@ int _map_save_in_game(bool a1)
return 0;
}
_anim_stop();
animationStop();
_partyMemberSaveProtos();
if (a1) {