sprite loading fix in win demo
svn-id: r16119
This commit is contained in:
parent
c195ae0e74
commit
1724d00962
8 changed files with 60 additions and 44 deletions
|
@ -70,13 +70,13 @@ Actor::Actor(SagaEngine *vm) : _vm(vm) {
|
||||||
|
|
||||||
for (i = 0; i < ACTORCOUNT; i++) {
|
for (i = 0; i < ACTORCOUNT; i++) {
|
||||||
actor = &_actors[i];
|
actor = &_actors[i];
|
||||||
actor->actorId = ACTOR_INDEX_TO_ID(i);
|
actor->_actorId = ACTOR_INDEX_TO_ID(i);
|
||||||
actor->index = i;
|
actor->_index = i;
|
||||||
debug(0, "init actorId=0x%X index=0x%X", actor->actorId, actor->index);
|
debug(0, "init actorId=0x%X index=0x%X", actor->_actorId, actor->_index);
|
||||||
actor->spriteListResourceId = ActorTable[i].spriteListResourceId;
|
actor->spriteListResourceId = ActorTable[i].spriteListResourceId;
|
||||||
actor->frameListResourceId = ActorTable[i].frameListResourceId;
|
actor->frameListResourceId = ActorTable[i].frameListResourceId;
|
||||||
actor->flags = ActorTable[i].flags;
|
actor->flags = ActorTable[i].flags;
|
||||||
actor->speechColor = ActorTable[actor->index].speechColor;
|
actor->speechColor = ActorTable[i].speechColor;
|
||||||
actor->orient = ACTOR_DEFAULT_ORIENT;
|
actor->orient = ACTOR_DEFAULT_ORIENT;
|
||||||
actor->def_action = 0;
|
actor->def_action = 0;
|
||||||
actor->def_action_flags = 0;
|
actor->def_action_flags = 0;
|
||||||
|
@ -84,9 +84,13 @@ Actor::Actor(SagaEngine *vm) : _vm(vm) {
|
||||||
actor->action_flags = 0;
|
actor->action_flags = 0;
|
||||||
actor->action_time = 0;
|
actor->action_time = 0;
|
||||||
actor->action_frame = 0;
|
actor->action_frame = 0;
|
||||||
if (loadActorResources(actor) != SUCCESS)
|
actor->_disabled = !loadActorResources(actor);
|
||||||
error("Error while loading actors resource actorId=0x%X index=0x%X", actor->actorId, actor->index);
|
if (actor->_disabled) {
|
||||||
_orderList.push_back(actor);
|
warning("Disabling actorId=0x%X index=0x%X", actor->_actorId, actor->_index);
|
||||||
|
} else {
|
||||||
|
_orderList.push_back(actor);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +107,7 @@ Actor::~Actor() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Actor::loadActorResources(ActorData * actor) {
|
bool Actor::loadActorResources(ActorData * actor) {
|
||||||
byte *resourcePointer;
|
byte *resourcePointer;
|
||||||
size_t resourceLength;
|
size_t resourceLength;
|
||||||
int frameCount;
|
int frameCount;
|
||||||
|
@ -112,20 +116,19 @@ int Actor::loadActorResources(ActorData * actor) {
|
||||||
int i, orient;
|
int i, orient;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
debug(0, "Loading frame resource id 0x%X", actor->frameListResourceId);
|
||||||
result = RSC_LoadResource(_actorContext, actor->frameListResourceId, &resourcePointer, &resourceLength);
|
result = RSC_LoadResource(_actorContext, actor->frameListResourceId, &resourcePointer, &resourceLength);
|
||||||
if (result != SUCCESS) {
|
if (result != SUCCESS) {
|
||||||
warning("Couldn't load sprite action index resource");
|
warning("Couldn't load sprite action index resource");
|
||||||
return FAILURE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
frameCount = resourceLength / 16;
|
frameCount = resourceLength / 16;
|
||||||
debug(0, "Sprite resource contains %d frames", frameCount);
|
debug(0, "Frame resource contains %d frames", frameCount);
|
||||||
|
|
||||||
framesPointer = (ActorFrame *)malloc(sizeof(ActorFrame) * frameCount);
|
framesPointer = (ActorFrame *)malloc(sizeof(ActorFrame) * frameCount);
|
||||||
if (framesPointer == NULL) {
|
if (framesPointer == NULL) {
|
||||||
warning("Couldn't allocate memory for sprite frames");
|
error("Couldn't allocate memory for sprite frames");
|
||||||
RSC_FreeResource(resourcePointer);
|
|
||||||
return MEM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryReadStreamEndian readS(resourcePointer, resourceLength, IS_BIG_ENDIAN);
|
MemoryReadStreamEndian readS(resourcePointer, resourceLength, IS_BIG_ENDIAN);
|
||||||
|
@ -149,27 +152,37 @@ int Actor::loadActorResources(ActorData * actor) {
|
||||||
actor->frameCount = frameCount;
|
actor->frameCount = frameCount;
|
||||||
|
|
||||||
|
|
||||||
|
debug(0, "Loading sprite resource id 0x%X", actor->spriteListResourceId);
|
||||||
if (_vm->_sprite->loadList(actor->spriteListResourceId, &actor->spriteList) != SUCCESS) {
|
if (_vm->_sprite->loadList(actor->spriteListResourceId, &actor->spriteList) != SUCCESS) {
|
||||||
warning("Unable to load sprite list");
|
warning("Unable to load sprite list");
|
||||||
return FAILURE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastFrame >= _vm->_sprite->getListLen(actor->spriteList)) {
|
i = _vm->_sprite->getListLen(actor->spriteList);
|
||||||
|
|
||||||
|
if ( (lastFrame >= i)) {
|
||||||
debug(0, "Appending to sprite list 0x%X", actor->spriteListResourceId);
|
debug(0, "Appending to sprite list 0x%X", actor->spriteListResourceId);
|
||||||
if (_vm->_sprite->appendList(actor->spriteListResourceId + 1, actor->spriteList) != SUCCESS) {
|
if (_vm->_sprite->appendList(actor->spriteListResourceId + 1, actor->spriteList) != SUCCESS) {
|
||||||
warning("Unable append sprite list");
|
warning("Unable append sprite list");
|
||||||
return FAILURE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SUCCESS;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActorData *Actor::getActor(uint16 actorId) {
|
ActorData *Actor::getActor(uint16 actorId) {
|
||||||
if(!IS_VALID_ACTOR_ID(actorId))
|
ActorData *actor;
|
||||||
|
|
||||||
|
if (!IS_VALID_ACTOR_ID(actorId))
|
||||||
error("Actor::getActor Wrong actorId 0x%X", actorId);
|
error("Actor::getActor Wrong actorId 0x%X", actorId);
|
||||||
|
|
||||||
return &_actors[ACTOR_ID_TO_INDEX(actorId)];
|
actor = &_actors[ACTOR_ID_TO_INDEX(actorId)];
|
||||||
|
|
||||||
|
if (actor->_disabled)
|
||||||
|
error("Actor::getActor disabled actorId 0x%X", actorId);
|
||||||
|
|
||||||
|
return actor;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActorOrderList::iterator Actor::getActorOrderIterator(const ActorData *actor) {
|
ActorOrderList::iterator Actor::getActorOrderIterator(const ActorData *actor) {
|
||||||
|
@ -297,9 +310,12 @@ int Actor::drawList() {
|
||||||
|
|
||||||
for (actorOrderIterator = _orderList.begin(); actorOrderIterator != _orderList.end(); ++actorOrderIterator) {
|
for (actorOrderIterator = _orderList.begin(); actorOrderIterator != _orderList.end(); ++actorOrderIterator) {
|
||||||
actor = actorOrderIterator.operator*();
|
actor = actorOrderIterator.operator*();
|
||||||
|
if(actor->frameCount == 0) continue;
|
||||||
|
|
||||||
o_idx = ActorOrientationLUT[actor->orient];
|
o_idx = ActorOrientationLUT[actor->orient];
|
||||||
sprite_num = actor->frames[actor->action].dir[o_idx].frameIndex;
|
sprite_num = actor->frames[actor->action].dir[o_idx].frameIndex;
|
||||||
sprite_num += actor->action_frame;
|
sprite_num += actor->action_frame;
|
||||||
|
if(actor->spriteList->sprite_count <= sprite_num) continue;
|
||||||
_vm->_sprite->drawOccluded(back_buf, actor->spriteList, sprite_num, actor->s_pt.x, actor->s_pt.y);
|
_vm->_sprite->drawOccluded(back_buf, actor->spriteList, sprite_num, actor->s_pt.x, actor->s_pt.y);
|
||||||
|
|
||||||
// If actor's current intent is to speak, oblige him by
|
// If actor's current intent is to speak, oblige him by
|
||||||
|
@ -604,7 +620,7 @@ int Actor::handleWalkIntent(ActorData *actor, WALKINTENT *a_walkint, int *comple
|
||||||
// Initialize walk intent
|
// Initialize walk intent
|
||||||
if (!a_walkint->wi_init) {
|
if (!a_walkint->wi_init) {
|
||||||
setPathNode(a_walkint, &actor->a_pt, &a_walkint->dst_pt, a_walkint->sem);
|
setPathNode(a_walkint, &actor->a_pt, &a_walkint->dst_pt, a_walkint->sem);
|
||||||
setDefaultAction(actor->actorId, ACTION_IDLE, ACTION_NONE);
|
setDefaultAction(actor->_actorId, ACTION_IDLE, ACTION_NONE);
|
||||||
a_walkint->wi_init = 1;
|
a_walkint->wi_init = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
saga/actor.h
12
saga/actor.h
|
@ -177,8 +177,9 @@ struct ACTORINTENT {
|
||||||
typedef Common::List<ACTORINTENT> ActorIntentList;
|
typedef Common::List<ACTORINTENT> ActorIntentList;
|
||||||
|
|
||||||
struct ActorData {
|
struct ActorData {
|
||||||
int index; // Actor index
|
bool _disabled;
|
||||||
uint16 actorId; // Actor id
|
int _index; // Actor index
|
||||||
|
uint16 _actorId; // Actor id
|
||||||
|
|
||||||
int name_i; // Actor's index in actor name string list
|
int name_i; // Actor's index in actor name string list
|
||||||
uint16 flags;
|
uint16 flags;
|
||||||
|
@ -219,8 +220,9 @@ struct ActorData {
|
||||||
|
|
||||||
|
|
||||||
ActorData() {
|
ActorData() {
|
||||||
index = 0;
|
_disabled = false;
|
||||||
actorId = 0;
|
_index = 0;
|
||||||
|
_actorId = 0;
|
||||||
name_i = 0;
|
name_i = 0;
|
||||||
flags = 0;
|
flags = 0;
|
||||||
frames = NULL;
|
frames = NULL;
|
||||||
|
@ -288,7 +290,7 @@ private:
|
||||||
|
|
||||||
ActorData *getActor(uint16 actorId);
|
ActorData *getActor(uint16 actorId);
|
||||||
|
|
||||||
int loadActorResources(ActorData * actor);
|
bool loadActorResources(ActorData * actor);
|
||||||
|
|
||||||
ActorOrderList::iterator getActorOrderIterator(const ActorData *actor);
|
ActorOrderList::iterator getActorOrderIterator(const ActorData *actor);
|
||||||
void reorderActorUp(ActorData *actor);
|
void reorderActorUp(ActorData *actor);
|
||||||
|
|
|
@ -112,12 +112,6 @@ GAME_RESOURCEDESC ITE_Resources = {
|
||||||
ITE_DIALOGUE_PANEL
|
ITE_DIALOGUE_PANEL
|
||||||
};
|
};
|
||||||
|
|
||||||
GAME_RESOURCEDESC ITEMACDEMO_Resources = {
|
|
||||||
ITEMACDEMO_SCENE_LUT, // Scene lookup table RN
|
|
||||||
ITE_SCRIPT_LUT, // Script lookup table RN
|
|
||||||
ITE_COMMAND_PANEL,
|
|
||||||
ITE_DIALOGUE_PANEL
|
|
||||||
};
|
|
||||||
|
|
||||||
GAME_SOUNDINFO ITE_GameSound = {
|
GAME_SOUNDINFO ITE_GameSound = {
|
||||||
GAME_SOUND_VOC, 0, 0, 0
|
GAME_SOUND_VOC, 0, 0, 0
|
||||||
|
@ -218,7 +212,7 @@ GAMEDESC GameDescs[] = {
|
||||||
320, 200,
|
320, 200,
|
||||||
137,
|
137,
|
||||||
ITE_DEFAULT_SCENE,
|
ITE_DEFAULT_SCENE,
|
||||||
&ITEMACDEMO_Resources,
|
&ITE_Resources,
|
||||||
ARRAYSIZE(ITEMACDEMO_GameFiles),
|
ARRAYSIZE(ITEMACDEMO_GameFiles),
|
||||||
ITEMACDEMO_GameFiles,
|
ITEMACDEMO_GameFiles,
|
||||||
ARRAYSIZE(ITEMACDEMO_GameFonts),
|
ARRAYSIZE(ITEMACDEMO_GameFonts),
|
||||||
|
@ -593,7 +587,7 @@ int GAME_GetSceneInfo(GAME_SCENEDESC *gs_desc) {
|
||||||
assert(gs_desc != NULL);
|
assert(gs_desc != NULL);
|
||||||
|
|
||||||
gs_desc->first_scene = GameModule.gamedesc->gd_startscene;
|
gs_desc->first_scene = GameModule.gamedesc->gd_startscene;
|
||||||
gs_desc->scene_lut_rn = GameModule.gamedesc->gd_resource_desc->scene_lut_rn;
|
gs_desc->scene_lut_rn = RSC_ConvertID(GameModule.gamedesc->gd_resource_desc->scene_lut_rn);
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -574,7 +574,7 @@ int Interface::handlePlayfieldClick(SURFACE *ds, const Point& imousePt) {
|
||||||
if (objectNum == -1) {
|
if (objectNum == -1) {
|
||||||
// Player clicked on empty spot - walk here regardless of verb
|
// Player clicked on empty spot - walk here regardless of verb
|
||||||
_vm->_actor->StoA(iactor_pt, imousePt);
|
_vm->_actor->StoA(iactor_pt, imousePt);
|
||||||
_vm->_actor->walkTo(0, &iactor_pt, 0, NULL);
|
_vm->_actor->walkTo(1, &iactor_pt, 0, NULL);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -593,7 +593,7 @@ int Interface::handlePlayfieldClick(SURFACE *ds, const Point& imousePt) {
|
||||||
} else {
|
} else {
|
||||||
// Not a normal scene object - walk to it as if it weren't there
|
// Not a normal scene object - walk to it as if it weren't there
|
||||||
_vm->_actor->StoA(iactor_pt, imousePt);
|
_vm->_actor->StoA(iactor_pt, imousePt);
|
||||||
_vm->_actor->walkTo(0, &iactor_pt, 0, NULL);
|
_vm->_actor->walkTo(1, &iactor_pt, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
|
|
|
@ -126,12 +126,15 @@ int Scene::ITEStartProc() {
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
SCENE_QUEUE first_scene;
|
SCENE_QUEUE first_scene;
|
||||||
|
SCENE_QUEUE tempScene;
|
||||||
GAME_SCENEDESC gs_desc;
|
GAME_SCENEDESC gs_desc;
|
||||||
|
|
||||||
n_introscenes = ARRAYSIZE(ITE_IntroList);
|
n_introscenes = ARRAYSIZE(ITE_IntroList);
|
||||||
|
|
||||||
for (i = 0; i < n_introscenes; i++) {
|
for (i = 0; i < n_introscenes; i++) {
|
||||||
_vm->_scene->queueScene(&ITE_IntroList[i]);
|
tempScene = ITE_IntroList[i];
|
||||||
|
tempScene.scene_n = RSC_ConvertID(tempScene.scene_n);
|
||||||
|
_vm->_scene->queueScene(&tempScene);
|
||||||
}
|
}
|
||||||
|
|
||||||
GAME_GetSceneInfo(&gs_desc);
|
GAME_GetSceneInfo(&gs_desc);
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
namespace Saga {
|
namespace Saga {
|
||||||
|
|
||||||
// Lookup tables
|
// Lookup tables
|
||||||
#define ITEMACDEMO_SCENE_LUT 1804
|
|
||||||
#define ITE_SCENE_LUT 1806
|
#define ITE_SCENE_LUT 1806
|
||||||
#define ITE_SCRIPT_LUT 216
|
#define ITE_SCRIPT_LUT 216
|
||||||
|
|
||||||
|
@ -58,7 +57,6 @@ namespace Saga {
|
||||||
#define ITE_DEFAULT_PORTRAITS 125
|
#define ITE_DEFAULT_PORTRAITS 125
|
||||||
|
|
||||||
// ITE Scene resource numbers
|
// ITE Scene resource numbers
|
||||||
#define ITEMACDEMO_INTRO_ANIM_SCENE 1536
|
|
||||||
#define ITE_INTRO_ANIM_SCENE 1538
|
#define ITE_INTRO_ANIM_SCENE 1538
|
||||||
#define ITE_CAVE_SCENE_1 1542
|
#define ITE_CAVE_SCENE_1 1542
|
||||||
#define ITE_CAVE_SCENE_2 1545
|
#define ITE_CAVE_SCENE_2 1545
|
||||||
|
|
|
@ -232,7 +232,7 @@ int Scene::nextScene() {
|
||||||
scene_qdat = queueIterator.operator->();
|
scene_qdat = queueIterator.operator->();
|
||||||
assert(scene_qdat != NULL);
|
assert(scene_qdat != NULL);
|
||||||
|
|
||||||
loadScene(RSC_ConvertID(scene_qdat->scene_n), scene_qdat->load_flag, scene_qdat->scene_proc, scene_qdat->scene_desc, scene_qdat->fadeType);
|
loadScene(scene_qdat->scene_n, scene_qdat->load_flag, scene_qdat->scene_proc, scene_qdat->scene_desc, scene_qdat->fadeType);
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,19 +73,22 @@ int Sprite::loadList(int resource_num, SPRITELIST **sprite_list_p) {
|
||||||
uint16 sprite_count;
|
uint16 sprite_count;
|
||||||
uint16 i;
|
uint16 i;
|
||||||
|
|
||||||
new_slist = (SPRITELIST *)malloc(sizeof *new_slist);
|
|
||||||
if (new_slist == NULL) {
|
|
||||||
return MEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (RSC_LoadResource(_spriteContext, resource_num, &spritelist_data, &spritelist_len) != SUCCESS) {
|
if (RSC_LoadResource(_spriteContext, resource_num, &spritelist_data, &spritelist_len) != SUCCESS) {
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (spritelist_len == 0)
|
||||||
|
return FAILURE;
|
||||||
|
|
||||||
MemoryReadStreamEndian readS(spritelist_data, spritelist_len, IS_BIG_ENDIAN);
|
MemoryReadStreamEndian readS(spritelist_data, spritelist_len, IS_BIG_ENDIAN);
|
||||||
|
|
||||||
sprite_count = readS.readUint16();
|
sprite_count = readS.readUint16();
|
||||||
|
|
||||||
|
new_slist = (SPRITELIST *)malloc(sizeof *new_slist);
|
||||||
|
if (new_slist == NULL) {
|
||||||
|
return MEM;
|
||||||
|
}
|
||||||
|
|
||||||
new_slist->sprite_count = sprite_count;
|
new_slist->sprite_count = sprite_count;
|
||||||
|
|
||||||
new_slist->offset_list = (SPRITELIST_OFFSET *)malloc(sprite_count * sizeof *new_slist->offset_list);
|
new_slist->offset_list = (SPRITELIST_OFFSET *)malloc(sprite_count * sizeof *new_slist->offset_list);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue