aboutsummaryrefslogtreecommitdiff
path: root/saga
diff options
context:
space:
mode:
authorPaweł Kołodziejski2004-05-01 06:16:57 +0000
committerPaweł Kołodziejski2004-05-01 06:16:57 +0000
commit1ac5aef6474a7b83294d793690cc1694a5e795f5 (patch)
treeeeec58eb5ef83bdcfe4f66c4d93912e02a1b9c2b /saga
parent1353e2d2dc8cf794279f4bc8f9ae12eb31accc35 (diff)
downloadscummvm-rg350-1ac5aef6474a7b83294d793690cc1694a5e795f5.tar.gz
scummvm-rg350-1ac5aef6474a7b83294d793690cc1694a5e795f5.tar.bz2
scummvm-rg350-1ac5aef6474a7b83294d793690cc1694a5e795f5.zip
indent
svn-id: r13688
Diffstat (limited to 'saga')
-rw-r--r--saga/actionmap.cpp278
-rw-r--r--saga/actionmap.h17
-rw-r--r--saga/actionmap_mod.h15
-rw-r--r--saga/actor.cpp543
-rw-r--r--saga/actor.h109
-rw-r--r--saga/actor_mod.h36
-rw-r--r--saga/actordata.cpp17
-rw-r--r--saga/actordata.h13
-rw-r--r--saga/animation.cpp510
-rw-r--r--saga/animation.h51
-rw-r--r--saga/animation_mod.h26
11 files changed, 431 insertions, 1184 deletions
diff --git a/saga/actionmap.cpp b/saga/actionmap.cpp
index 474d62ba6a..12d841a586 100644
--- a/saga/actionmap.cpp
+++ b/saga/actionmap.cpp
@@ -22,231 +22,183 @@
*/
/*
- Description:
-
- Action map module
-
- Notes:
-*/
+/* Action map module */
#include "reinherit.h"
#include "yslib.h"
-
-/*
- * Uses the following modules:
-\*--------------------------------------------------------------------------*/
#include "cvar_mod.h"
#include "console_mod.h"
#include "gfx_mod.h"
-/*
- * Begin module component
-\*--------------------------------------------------------------------------*/
#include "actionmap_mod.h"
#include "actionmap.h"
namespace Saga {
+ static R_ACTIONMAP_INFO ActmapModule;
-static R_ACTIONMAP_INFO ActmapModule;
-
-int ACTIONMAP_Register(void)
-{
-
- CVAR_RegisterFunc(CF_action_info,
- "action_info", NULL, R_CVAR_NONE, 0, 0);
-
- return R_SUCCESS;
-}
-
-int ACTIONMAP_Init(void)
-{
- R_printf(R_STDOUT, "ACTIONMAP Module: Initializing...\n");
-
- ActmapModule.init = 1;
- return R_SUCCESS;
-}
-
-int ACTIONMAP_Load(const byte * exmap_res, size_t exmap_res_len)
-/*--------------------------------------------------------------------------*\
- * Loads exit map data from specified exit map resource
-\*--------------------------------------------------------------------------*/
-{
-
- R_ACTIONMAP_ENTRY *exmap_entry;
- R_POINT *exmap_pt_tbl;
-
- int exit_ct;
- int i, pt;
-
- const byte *read_p = exmap_res;
- size_t read_len = exmap_res_len;
-
- assert(ActmapModule.init);
- assert(exmap_res != NULL);
-
- (void)read_len;
+ int ACTIONMAP_Register(void) {
+ CVAR_RegisterFunc(CF_action_info,
+ "action_info", NULL, R_CVAR_NONE, 0, 0);
+ return R_SUCCESS;
+ }
- /* Load exits
- * \*------------------------------------------------------------- */
- exit_ct = ys_read_s16_le(read_p, &read_p);
- if (exit_ct < 0) {
- return R_FAILURE;
+ int ACTIONMAP_Init(void) {
+ R_printf(R_STDOUT, "ACTIONMAP Module: Initializing...\n");
+ ActmapModule.init = 1;
+ return R_SUCCESS;
}
- exmap_entry = (R_ACTIONMAP_ENTRY *)malloc(exit_ct * sizeof *exmap_entry);
- if (exmap_entry == NULL) {
+ int ACTIONMAP_Load(const byte * exmap_res, size_t exmap_res_len) {
+ //Loads exit map data from specified exit map resource
+ R_ACTIONMAP_ENTRY *exmap_entry;
+ R_POINT *exmap_pt_tbl;
- R_printf(R_STDERR, "Memory allocation failure.\n");
- return R_MEM;
- }
+ int exit_ct;
+ int i, pt;
- for (i = 0; i < exit_ct; i++) {
+ const byte *read_p = exmap_res;
+ size_t read_len = exmap_res_len;
- exmap_entry[i].unknown00 = ys_read_s16_le(read_p, &read_p);
- exmap_entry[i].unknown02 = ys_read_s16_le(read_p, &read_p);
- exmap_entry[i].exit_scene = ys_read_s16_le(read_p, &read_p);
- exmap_entry[i].unknown06 = ys_read_s16_le(read_p, &read_p);
+ assert(ActmapModule.init);
+ assert(exmap_res != NULL);
- exmap_entry[i].pt_count = ys_read_s16_le(read_p, &read_p);
- if (exmap_entry[i].pt_count < 0) {
+ (void)read_len;
- free(exmap_entry);
+ // Load exits
+ exit_ct = ys_read_s16_le(read_p, &read_p);
+ if (exit_ct < 0) {
return R_FAILURE;
}
- exmap_pt_tbl =
- (R_POINT *)malloc(exmap_entry[i].pt_count * sizeof *exmap_pt_tbl);
- if (exmap_pt_tbl == NULL) {
-
+ exmap_entry = (R_ACTIONMAP_ENTRY *)malloc(exit_ct * sizeof *exmap_entry);
+ if (exmap_entry == NULL) {
R_printf(R_STDERR, "Memory allocation failure.\n");
return R_MEM;
}
- for (pt = 0; pt < exmap_entry[i].pt_count; pt++) {
-
- exmap_pt_tbl[pt].x = ys_read_s16_le(read_p, &read_p);
- exmap_pt_tbl[pt].y = ys_read_s16_le(read_p, &read_p);
+ for (i = 0; i < exit_ct; i++) {
+ exmap_entry[i].unknown00 = ys_read_s16_le(read_p, &read_p);
+ exmap_entry[i].unknown02 = ys_read_s16_le(read_p, &read_p);
+ exmap_entry[i].exit_scene = ys_read_s16_le(read_p, &read_p);
+ exmap_entry[i].unknown06 = ys_read_s16_le(read_p, &read_p);
+
+ exmap_entry[i].pt_count = ys_read_s16_le(read_p, &read_p);
+ if (exmap_entry[i].pt_count < 0) {
+ free(exmap_entry);
+ return R_FAILURE;
+ }
+
+ exmap_pt_tbl = (R_POINT *)malloc(exmap_entry[i].pt_count * sizeof *exmap_pt_tbl);
+ if (exmap_pt_tbl == NULL) {
+ R_printf(R_STDERR, "Memory allocation failure.\n");
+ return R_MEM;
+ }
+
+ for (pt = 0; pt < exmap_entry[i].pt_count; pt++) {
+ exmap_pt_tbl[pt].x = ys_read_s16_le(read_p, &read_p);
+ exmap_pt_tbl[pt].y = ys_read_s16_le(read_p, &read_p);
+ }
+
+ exmap_entry[i].pt_tbl = exmap_pt_tbl;
}
- exmap_entry[i].pt_tbl = exmap_pt_tbl;
- }
-
- ActmapModule.exits_loaded = 1;
- ActmapModule.n_exits = exit_ct;
- ActmapModule.exits_tbl = exmap_entry;
-
- ActmapModule.exmap_res = exmap_res;
- ActmapModule.exmap_res_len = exmap_res_len;
-
- return R_SUCCESS;
-}
+ ActmapModule.exits_loaded = 1;
+ ActmapModule.n_exits = exit_ct;
+ ActmapModule.exits_tbl = exmap_entry;
-int ACTIONMAP_Free(void)
-/*--------------------------------------------------------------------------*\
- * Frees the currently loaded exit map data
-\*--------------------------------------------------------------------------*/
-{
+ ActmapModule.exmap_res = exmap_res;
+ ActmapModule.exmap_res_len = exmap_res_len;
- R_ACTIONMAP_ENTRY *exmap_entry;
- int i;
-
- if (!ActmapModule.exits_loaded) {
return R_SUCCESS;
}
- for (i = 0; i < ActmapModule.n_exits; i++) {
-
- exmap_entry = &ActmapModule.exits_tbl[i];
-
- free(exmap_entry->pt_tbl);
- }
+ int ACTIONMAP_Free(void) {
+ // Frees the currently loaded exit map data
+ R_ACTIONMAP_ENTRY *exmap_entry;
+ int i;
- free(ActmapModule.exits_tbl);
-
- ActmapModule.exits_loaded = 0;
- ActmapModule.exits_tbl = NULL;
- ActmapModule.n_exits = 0;
-
- return R_SUCCESS;
-}
+ if (!ActmapModule.exits_loaded) {
+ return R_SUCCESS;
+ }
-int ACTIONMAP_Shutdown(void)
-/*--------------------------------------------------------------------------*\
-\*--------------------------------------------------------------------------*/
-{
+ for (i = 0; i < ActmapModule.n_exits; i++) {
+ exmap_entry = &ActmapModule.exits_tbl[i];
- return R_SUCCESS;
-}
+ free(exmap_entry->pt_tbl);
+ }
-int ACTIONMAP_Draw(R_SURFACE * ds, int color)
-{
+ free(ActmapModule.exits_tbl);
- int i;
+ ActmapModule.exits_loaded = 0;
+ ActmapModule.exits_tbl = NULL;
+ ActmapModule.n_exits = 0;
- assert(ActmapModule.init);
+ return R_SUCCESS;
+ }
- if (!ActmapModule.exits_loaded) {
- return R_FAILURE;
+ int ACTIONMAP_Shutdown(void) {
+ return R_SUCCESS;
}
- for (i = 0; i < ActmapModule.n_exits; i++) {
+ int ACTIONMAP_Draw(R_SURFACE * ds, int color) {
+ int i;
- if (ActmapModule.exits_tbl[i].pt_count == 2) {
+ assert(ActmapModule.init);
- GFX_DrawFrame(ds,
- &ActmapModule.exits_tbl[i].pt_tbl[0],
- &ActmapModule.exits_tbl[i].pt_tbl[1], color);
+ if (!ActmapModule.exits_loaded) {
+ return R_FAILURE;
+ }
- } else if (ActmapModule.exits_tbl[i].pt_count > 2) {
+ for (i = 0; i < ActmapModule.n_exits; i++) {
- GFX_DrawPolyLine(ds,
- ActmapModule.exits_tbl[i].pt_tbl,
- ActmapModule.exits_tbl[i].pt_count, color);
+ if (ActmapModule.exits_tbl[i].pt_count == 2) {
+ GFX_DrawFrame(ds,
+ &ActmapModule.exits_tbl[i].pt_tbl[0],
+ &ActmapModule.exits_tbl[i].pt_tbl[1], color);
+ } else if (ActmapModule.exits_tbl[i].pt_count > 2) {
+ GFX_DrawPolyLine(ds, ActmapModule.exits_tbl[i].pt_tbl,
+ ActmapModule.exits_tbl[i].pt_count, color);
+ }
}
- }
- return R_SUCCESS;
-}
-
-void CF_action_info(int argc, char *argv[])
-{
- R_POINT *pt;
+ return R_SUCCESS;
+ }
- int i;
- int pt_i;
+ void CF_action_info(int argc, char *argv[]) {
+ R_POINT *pt;
- YS_IGNORE_PARAM(argc);
- YS_IGNORE_PARAM(argv);
+ int i;
+ int pt_i;
- if (!ActmapModule.exits_loaded) {
- return;
- }
+ YS_IGNORE_PARAM(argc);
+ YS_IGNORE_PARAM(argv);
- CON_Print("%d exits loaded.\n", ActmapModule.n_exits);
+ if (!ActmapModule.exits_loaded) {
+ return;
+ }
- for (i = 0; i < ActmapModule.n_exits; i++) {
+ CON_Print("%d exits loaded.\n", ActmapModule.n_exits);
- CON_Print
- ("Action %d: Exit to: %d; Pts: %d; Unk0: %d Unk2: %d Scr_N: %d",
- i, ActmapModule.exits_tbl[i].exit_scene,
- ActmapModule.exits_tbl[i].pt_count,
- ActmapModule.exits_tbl[i].unknown00,
- ActmapModule.exits_tbl[i].unknown02,
- ActmapModule.exits_tbl[i].unknown06);
+ for (i = 0; i < ActmapModule.n_exits; i++) {
- for (pt_i = 0; pt_i < ActmapModule.exits_tbl[i].pt_count;
- pt_i++) {
+ CON_Print ("Action %d: Exit to: %d; Pts: %d; Unk0: %d Unk2: %d Scr_N: %d",
+ i, ActmapModule.exits_tbl[i].exit_scene,
+ ActmapModule.exits_tbl[i].pt_count,
+ ActmapModule.exits_tbl[i].unknown00,
+ ActmapModule.exits_tbl[i].unknown02,
+ ActmapModule.exits_tbl[i].unknown06);
- pt = &ActmapModule.exits_tbl[i].pt_tbl[pt_i];
+ for (pt_i = 0; pt_i < ActmapModule.exits_tbl[i].pt_count; pt_i++) {
+ pt = &ActmapModule.exits_tbl[i].pt_tbl[pt_i];
- CON_Print(" pt: %d (%d, %d)", pt_i, pt->x, pt->y);
+ CON_Print(" pt: %d (%d, %d)", pt_i, pt->x, pt->y);
+ }
}
- }
- return;
-}
+ return;
+ }
} // End of namespace Saga
diff --git a/saga/actionmap.h b/saga/actionmap.h
index 920484bd4f..aaf1b033cc 100644
--- a/saga/actionmap.h
+++ b/saga/actionmap.h
@@ -20,14 +20,8 @@
* $Header$
*
*/
-/*
- Description:
-
- Action map module - private header
-
- Notes:
-*/
+// Action map module - private header
#ifndef SAGA_ACTIONMAP_H_
#define SAGA_ACTIONMAP_H_
@@ -35,7 +29,6 @@
namespace Saga {
struct R_ACTIONMAP_ENTRY {
-
int unknown00;
int unknown02;
int exit_scene;
@@ -43,25 +36,19 @@ struct R_ACTIONMAP_ENTRY {
int pt_count;
R_POINT *pt_tbl;
-
};
struct R_ACTIONMAP_INFO {
-
int init;
-
int exits_loaded;
int n_exits;
R_ACTIONMAP_ENTRY *exits_tbl;
-
const byte *exmap_res;
size_t exmap_res_len;
-
};
void CF_action_info(int argc, char *argv[]);
} // End of namespace Saga
-#endif /* R_ACTIONMAP_H_ */
-/* end "r_actionmap.h" */
+#endif
diff --git a/saga/actionmap_mod.h b/saga/actionmap_mod.h
index a051cbbcaa..fe0f0a8655 100644
--- a/saga/actionmap_mod.h
+++ b/saga/actionmap_mod.h
@@ -20,14 +20,8 @@
* $Header$
*
*/
-/*
- Description:
-
- Action map module - public module header
-
- Notes:
-*/
+// Action map module - public module header
#ifndef SAGA_ACTIONMAP_MOD_H_
#define SAGA_ACTIONMAP_MOD_H_
@@ -37,13 +31,12 @@ namespace Saga {
int ACTIONMAP_Register(void);
int ACTIONMAP_Init(void);
-int ACTIONMAP_Load(const byte * exmap_res, size_t exmap_res_len);
-int ACTIONMAP_Draw(R_SURFACE * ds, int color);
+int ACTIONMAP_Load(const byte *exmap_res, size_t exmap_res_len);
+int ACTIONMAP_Draw(R_SURFACE *ds, int color);
int ACTIONMAP_Free(void);
int ACTIONMAP_Shutdown(void);
} // End of namespace Saga
-#endif /* R_ACTIONMAP_MOD_H_ */
-/* end "r_actionmap_mod.h" */
+#endif
diff --git a/saga/actor.cpp b/saga/actor.cpp
index 7e849f54e6..339c14fe2d 100644
--- a/saga/actor.cpp
+++ b/saga/actor.cpp
@@ -20,24 +20,12 @@
* $Header$
*
*/
-/*
- Description:
-
- Actor management module
-
- Notes:
-
- Hardcoded actor table present in r_actordata.c
-*/
#include "saga.h"
#include "reinherit.h"
#include "yslib.h"
-/*
- * Uses the following modules:
-\*--------------------------------------------------------------------------*/
#include "game_mod.h"
#include "cvar_mod.h"
#include "console_mod.h"
@@ -49,9 +37,6 @@
#include "text_mod.h"
#include "sound.h"
-/*
- * Begin module component
-\*--------------------------------------------------------------------------*/
#include "actor_mod.h"
#include "actor.h"
#include "actordata.h"
@@ -61,67 +46,42 @@ namespace Saga {
static R_ACTOR_MODULE ActorModule;
R_ACTIONTIMES ActionTDeltas[] = {
-
- {ACTION_IDLE, 80},
- {ACTION_WALK, 80},
- {ACTION_SPEAK, 200}
+ { ACTION_IDLE, 80 },
+ { ACTION_WALK, 80 },
+ { ACTION_SPEAK, 200 }
};
-int ACTOR_Register(void)
-{
-
- CVAR_RegisterFunc(CF_actor_add, "actor_add",
- "<Actor id> <lx> <ly>", R_CVAR_NONE, 3, 3);
-
- CVAR_RegisterFunc(CF_actor_del, "actor_del",
- "<Actor id>", R_CVAR_NONE, 1, 1);
-
- CVAR_RegisterFunc(CF_actor_move, "actor_move",
- "<Actor id> <lx> <ly>", R_CVAR_NONE, 3, 3);
-
- CVAR_RegisterFunc(CF_actor_moverel, "actor_moverel",
- "<Actor id> <lx> <ly>", R_CVAR_NONE, 3, 3);
-
- CVAR_RegisterFunc(CF_actor_seto, "actor_seto",
- "<Actor id> <Orientation>", R_CVAR_NONE, 2, 2);
-
- CVAR_RegisterFunc(CF_actor_setact, "actor_setact",
- "<Actor id> <Action #>", R_CVAR_NONE, 2, 2);
+int ACTOR_Register() {
+ CVAR_RegisterFunc(CF_actor_add, "actor_add", "<Actor id> <lx> <ly>", R_CVAR_NONE, 3, 3);
+ CVAR_RegisterFunc(CF_actor_del, "actor_del", "<Actor id>", R_CVAR_NONE, 1, 1);
+ CVAR_RegisterFunc(CF_actor_move, "actor_move", "<Actor id> <lx> <ly>", R_CVAR_NONE, 3, 3);
+ CVAR_RegisterFunc(CF_actor_moverel, "actor_moverel", "<Actor id> <lx> <ly>", R_CVAR_NONE, 3, 3);
+ CVAR_RegisterFunc(CF_actor_seto, "actor_seto", "<Actor id> <Orientation>", R_CVAR_NONE, 2, 2);
+ CVAR_RegisterFunc(CF_actor_setact, "actor_setact", "<Actor id> <Action #>", R_CVAR_NONE, 2, 2);
return R_SUCCESS;
}
-int ACTOR_Init(void)
-{
+int ACTOR_Init() {
int result;
int i;
if (ActorModule.init) {
-
ActorModule.err_str = "Actor module already initialized.";
-
return R_FAILURE;
}
- /* Get actor resource file context
- * \*------------------------------------------------------------- */
- result = GAME_GetFileContext(&ActorModule.actor_ctxt,
- R_GAME_RESOURCEFILE, 0);
+ // Get actor resource file context
+ result = GAME_GetFileContext(&ActorModule.actor_ctxt, R_GAME_RESOURCEFILE, 0);
if (result != R_SUCCESS) {
-
- ActorModule.err_str =
- "Couldn't load actor module resource context.";
-
+ ActorModule.err_str = "Couldn't load actor module resource context.";
return R_FAILURE;
}
- /* Create actor lookup table
- * \*------------------------------------------------------------- */
+ // Create actor lookup table
ActorModule.tbl = (YS_DL_NODE **)malloc(R_ACTORCOUNT * sizeof *ActorModule.tbl);
if (ActorModule.tbl == NULL) {
-
ActorModule.err_str = R_MEMFAIL_MSG;
-
return R_MEM;
}
@@ -129,36 +89,27 @@ int ACTOR_Init(void)
ActorModule.tbl[i] = NULL;
}
- /* Create actor alias table
- * \*------------------------------------------------------------- */
- ActorModule.alias_tbl = (int *)malloc(R_ACTORCOUNT *
- sizeof *ActorModule.alias_tbl);
+ // Create actor alias table
+ ActorModule.alias_tbl = (int *)malloc(R_ACTORCOUNT * sizeof *ActorModule.alias_tbl);
if (ActorModule.alias_tbl == NULL) {
free(ActorModule.tbl);
-
ActorModule.err_str = R_MEMFAIL_MSG;
-
return R_MEM;
}
- /* Initialize alias table so each index contains itself */
+ // Initialize alias table so each index contains itself
for (i = 0; i < R_ACTORCOUNT; i++) {
-
ActorModule.alias_tbl[i] = i;
}
- /* Create actor list
- * \*------------------------------------------------------------- */
+ // Create actor list
ActorModule.list = ys_dll_create();
-
ActorModule.init = 1;
return R_SUCCESS;
}
-int ACTOR_Shutdown(void)
-{
-
+int ACTOR_Shutdown() {
if (!ActorModule.init) {
return R_FAILURE;
}
@@ -168,12 +119,9 @@ int ACTOR_Shutdown(void)
}
return R_SUCCESS;
-
}
-int ACTOR_Direct(int msec)
-{
-
+int ACTOR_Direct(int msec) {
YS_DL_NODE *walk_p;
R_ACTOR *actor;
@@ -183,75 +131,52 @@ int ACTOR_Direct(int msec)
int o_idx;
int action_tdelta;
- /* Walk down the actor list and direct each actor
- * \*------------------------------------------------------------- */
- for (walk_p = ys_dll_head(ActorModule.list);
- walk_p != NULL; walk_p = ys_dll_next(walk_p)) {
-
+ // Walk down the actor list and direct each actor
+ for (walk_p = ys_dll_head(ActorModule.list); walk_p != NULL; walk_p = ys_dll_next(walk_p)) {
actor = (R_ACTOR *)ys_dll_get_data(walk_p);
-
- /* Process the actor intent list
- * \*--------------------------------------------------------- */
+ // Process the actor intent list
a_inode = ys_dll_head(actor->a_intentlist);
-
if (a_inode != NULL) {
-
a_intent = (R_ACTORINTENT *)ys_dll_get_data(a_inode);
-
switch (a_intent->a_itype) {
-
case INTENT_NONE:
- /* Actor doesn't really feel like doing anything at all */
+ // Actor doesn't really feel like doing anything at all
break;
-
case INTENT_PATH:
- /* Actor intends to go somewhere. Well good for him */
+ // Actor intends to go somewhere. Well good for him
{
R_WALKINTENT *a_walkint;
-
a_walkint = (R_WALKINTENT *)a_intent->a_data;
-
- HandleWalkIntent(actor,
- a_walkint,
- &a_intent->a_idone, msec);
+ HandleWalkIntent(actor, a_walkint, &a_intent->a_idone, msec);
}
break;
-
case INTENT_SPEAK:
- /* Actor wants to blab */
+ // Actor wants to blab
{
R_SPEAKINTENT *a_speakint;
-
a_speakint = (R_SPEAKINTENT *)a_intent->a_data;
-
- HandleSpeakIntent(actor,
- a_speakint,
- &a_intent->a_idone, msec);
+ HandleSpeakIntent(actor, a_speakint, &a_intent->a_idone, msec);
}
break;
default:
break;
- } /* end switch() */
+ }
- /* If this actor intent was flagged as completed, remove it. */
+ // If this actor intent was flagged as completed, remove it.
if (a_intent->a_idone) {
-
free(a_intent->a_data);
ys_dll_delete(a_inode);
-
actor->action = actor->def_action;
actor->action_flags = actor->def_action_flags;
actor->action_frame = 0;
actor->action_time = 0;
}
-
} else {
- /* Actor has no intent, idle? */
+ // Actor has no intent, idle?
}
- /* Process actor actions
- * \*--------------------------------------------------------- */
+ // Process actor actions
actor->action_time += msec;
if (actor->action >= ACTION_COUNT) {
@@ -261,32 +186,24 @@ int ACTOR_Direct(int msec)
}
if (actor->action_time >= action_tdelta) {
-
actor->action_time -= action_tdelta;
actor->action_frame++;
o_idx = ActorOrientationLUT[actor->orient];
-
- if (actor->act_tbl[actor->action].dir[o_idx].
- frame_count <= actor->action_frame) {
-
+ if (actor->act_tbl[actor->action].dir[o_idx].frame_count <= actor->action_frame) {
if (actor->action_flags & ACTION_LOOP) {
-
actor->action_frame = 0;
} else {
actor->action_frame--;
}
}
}
-
- } /* end for () */
+ }
return R_SUCCESS;
}
-int ACTOR_DrawList(void)
-{
-
+int ACTOR_DrawList() {
YS_DL_NODE *walk_p;
R_ACTOR *actor;
@@ -297,59 +214,37 @@ int ACTOR_DrawList(void)
YS_DL_NODE *a_dnode;
R_ACTORDIALOGUE *a_dialogue;
- int o_idx; /* Orientation index */
+ int o_idx; //Orientation index
int sprite_num;
- int diag_x, diag_y; /* dialog coordinates */
+ int diag_x, diag_y; // dialog coordinates
R_SURFACE *back_buf;
back_buf = SYSGFX_GetBackBuffer();
- for (walk_p = ys_dll_head(ActorModule.list);
- walk_p != NULL; walk_p = ys_dll_next(walk_p)) {
-
+ for (walk_p = ys_dll_head(ActorModule.list); walk_p != NULL; walk_p = ys_dll_next(walk_p)) {
actor = (R_ACTOR *)ys_dll_get_data(walk_p);
-
o_idx = ActorOrientationLUT[actor->orient];
-
- sprite_num =
- actor->act_tbl[actor->action].dir[o_idx].frame_index;
+ sprite_num = actor->act_tbl[actor->action].dir[o_idx].frame_index;
sprite_num += actor->action_frame;
+ SPRITE_DrawOccluded(back_buf, actor->sl_p, sprite_num, actor->s_pt.x, actor->s_pt.y);
- SPRITE_DrawOccluded(back_buf,
- actor->sl_p, sprite_num, actor->s_pt.x, actor->s_pt.y);
-
- /* If actor's current intent is to speak, oblige him by
- * displaying his dialogue
- \*---------------------------------------------------------*/
+ // If actor's current intent is to speak, oblige him by
+ // displaying his dialogue
a_inode = ys_dll_head(actor->a_intentlist);
-
if (a_inode != NULL) {
-
a_intent = (R_ACTORINTENT *)ys_dll_get_data(a_inode);
-
if (a_intent->a_itype == INTENT_SPEAK) {
-
a_speakint = (R_SPEAKINTENT *)a_intent->a_data;
-
a_dnode = ys_dll_head(a_speakint->si_diaglist);
-
if (a_dnode != NULL) {
-
a_dialogue = (R_ACTORDIALOGUE *)ys_dll_get_data(a_dnode);
-
diag_x = actor->s_pt.x;
diag_y = actor->s_pt.y;
-
diag_y -= ACTOR_DIALOGUE_HEIGHT;
-
- TEXT_Draw(MEDIUM_FONT_ID,
- back_buf,
- a_dialogue->d_string,
- diag_x, diag_y,
- actor->a_dcolor, 0,
- FONT_OUTLINE | FONT_CENTERED);
+ TEXT_Draw(MEDIUM_FONT_ID, back_buf, a_dialogue->d_string, diag_x, diag_y, actor->a_dcolor, 0,
+ FONT_OUTLINE | FONT_CENTERED);
}
}
}
@@ -358,14 +253,11 @@ int ACTOR_DrawList(void)
return R_SUCCESS;
}
-int ACTOR_SkipDialogue(void)
-/*--------------------------------------------------------------------------*\
- * Called if the user wishes to skip a line of dialogue (spacebar in the
- * original game). Will find all actors currently talking and remove one
- * dialogue entry if there is a current speak intent present.
-\*--------------------------------------------------------------------------*/
-{
+// Called if the user wishes to skip a line of dialogue (spacebar in the
+// original game). Will find all actors currently talking and remove one
+// dialogue entry if there is a current speak intent present.
+int ACTOR_SkipDialogue() {
YS_DL_NODE *walk_p;
R_ACTOR *actor;
@@ -380,41 +272,24 @@ int ACTOR_SkipDialogue(void)
return R_FAILURE;
}
- for (walk_p = ys_dll_head(ActorModule.list);
- walk_p != NULL; walk_p = ys_dll_next(walk_p)) {
-
+ for (walk_p = ys_dll_head(ActorModule.list); walk_p != NULL; walk_p = ys_dll_next(walk_p)) {
actor = (R_ACTOR *)ys_dll_get_data(walk_p);
-
- /* Check the actor's current intent for a speak intent
- * \*--------------------------------------------------------- */
+ // Check the actor's current intent for a speak intent
a_inode = ys_dll_head(actor->a_intentlist);
-
if (a_inode != NULL) {
-
a_intent = (R_ACTORINTENT *)ys_dll_get_data(a_inode);
-
if (a_intent->a_itype == INTENT_SPEAK) {
-
- /* Okay, found a speak intent. Remove one dialogue entry
- * from it, releasing any semaphore */
-
+ // Okay, found a speak intent. Remove one dialogue entry
+ // from it, releasing any semaphore */
a_speakint = (R_SPEAKINTENT *)a_intent->a_data;
-
a_dnode = ys_dll_head(a_speakint->si_diaglist);
-
if (a_dnode != NULL) {
-
a_dialogue = (R_ACTORDIALOGUE *)ys_dll_get_data(a_dnode);
-
if (a_dialogue->d_sem != NULL) {
-
- STHREAD_ReleaseSem(a_dialogue->
- d_sem);
+ STHREAD_ReleaseSem(a_dialogue->d_sem);
}
-
ys_dll_delete(a_dnode);
-
- /* And stop any currently playing voices */
+ // And stop any currently playing voices
_vm->_sound->stopVoice();
}
}
@@ -424,8 +299,7 @@ int ACTOR_SkipDialogue(void)
return R_SUCCESS;
}
-int ACTOR_Create(int actor_id, int x, int y)
-{
+int ACTOR_Create(int actor_id, int x, int y) {
R_ACTOR actor;
if (actor_id == 1) {
@@ -446,11 +320,8 @@ int ACTOR_Create(int actor_id, int x, int y)
return R_SUCCESS;
}
-int AddActor(R_ACTOR * actor)
-{
-
+int AddActor(R_ACTOR * actor) {
YS_DL_NODE *new_node;
-
int last_frame;
int i;
@@ -476,15 +347,11 @@ int AddActor(R_ACTOR * actor)
LoadActorSpriteIndex(actor, actor->si_rn, &last_frame);
if (SPRITE_LoadList(actor->sl_rn, &actor->sl_p) != R_SUCCESS) {
-
return R_FAILURE;
}
if (last_frame >= SPRITE_GetListLen(actor->sl_p)) {
-
- R_printf(R_STDOUT,
- "Appending to sprite list %d.\n", actor->sl_rn);
-
+ R_printf(R_STDOUT, "Appending to sprite list %d.\n", actor->sl_rn);
if (SPRITE_AppendList(actor->sl_rn + 1,
actor->sl_p) != R_SUCCESS) {
return R_FAILURE;
@@ -492,21 +359,16 @@ int AddActor(R_ACTOR * actor)
}
actor->a_dcolor = ActorTable[i].color;
-
actor->orient = ACTOR_DEFAULT_ORIENT;
-
actor->a_intentlist = ys_dll_create();
-
actor->def_action = 0;
actor->def_action_flags = 0;
-
actor->action = 0;
actor->action_flags = 0;
actor->action_time = 0;
actor->action_frame = 0;
- new_node = ys_dll_insert(ActorModule.list,
- actor, sizeof *actor, Z_Compare);
+ new_node = ys_dll_insert(ActorModule.list, actor, sizeof *actor, Z_Compare);
if (new_node == NULL) {
return R_FAILURE;
@@ -516,14 +378,12 @@ int AddActor(R_ACTOR * actor)
actor->node = new_node;
ActorModule.tbl[i] = new_node;
-
ActorModule.count++;
return R_SUCCESS;
}
-int ACTOR_GetActorIndex(uint16 actor_id)
-{
+int ACTOR_GetActorIndex(uint16 actor_id) {
uint16 actor_idx;
if (actor_id == 1) {
@@ -539,8 +399,7 @@ int ACTOR_GetActorIndex(uint16 actor_id)
return actor_idx;
}
-int ACTOR_ActorExists(uint16 actor_id)
-{
+int ACTOR_ActorExists(uint16 actor_id) {
uint16 actor_idx;
if (actor_id == 1) {
@@ -556,20 +415,14 @@ int ACTOR_ActorExists(uint16 actor_id)
return 1;
}
-int ACTOR_Speak(int index, const char *d_string, uint16 d_voice_rn, R_SEMAPHORE * sem)
-{
-
+int ACTOR_Speak(int index, const char *d_string, uint16 d_voice_rn, R_SEMAPHORE *sem) {
YS_DL_NODE *node;
R_ACTOR *actor;
-
YS_DL_NODE *a_inode;
R_ACTORINTENT *a_intent_p = NULL;
R_SPEAKINTENT *a_speakint;
-
R_ACTORINTENT a_intent;
-
int use_existing_ai = 0;
-
R_ACTORDIALOGUE a_dialogue;
a_dialogue.d_string = d_string;
@@ -585,55 +438,40 @@ int ACTOR_Speak(int index, const char *d_string, uint16 d_voice_rn, R_SEMAPHORE
actor = (R_ACTOR *)ys_dll_get_data(node);
- /* If actor's last registered intent is to speak, we can queue the
- * requested dialogue on that intent context; so examine the last
- * intent */
+ // If actor's last registered intent is to speak, we can queue the
+ // requested dialogue on that intent context; so examine the last
+ // intent
a_inode = ys_dll_tail(actor->a_intentlist);
-
if (a_inode != NULL) {
-
a_intent_p = (R_ACTORINTENT *)ys_dll_get_data(a_inode);
-
if (a_intent_p->a_itype == INTENT_SPEAK) {
-
use_existing_ai = 1;
}
}
if (use_existing_ai) {
-
- /* Store the current dialogue off the existing actor intent */
+ // Store the current dialogue off the existing actor intent
a_speakint = (R_SPEAKINTENT *)a_intent_p->a_data;
-
- ys_dll_add_tail(a_speakint->si_diaglist,
- &a_dialogue, sizeof a_dialogue);
-
+ ys_dll_add_tail(a_speakint->si_diaglist, &a_dialogue, sizeof a_dialogue);
} else {
-
- /* Create a new actor intent */
-
+ // Create a new actor intent
a_intent.a_itype = INTENT_SPEAK;
a_intent.a_idone = 0;
a_intent.a_iflags = 0;
a_speakint = (R_SPEAKINTENT *)malloc(sizeof *a_speakint);
if (a_speakint == NULL) {
-
return R_FAILURE;
}
a_speakint->si_init = 0;
a_speakint->si_diaglist = ys_dll_create();
a_speakint->si_last_action = actor->action;
-
a_intent.a_data = a_speakint;
- ys_dll_add_tail(a_speakint->si_diaglist,
- &a_dialogue, sizeof a_dialogue);
-
- ys_dll_add_tail(actor->a_intentlist,
- &a_intent, sizeof a_intent);
+ ys_dll_add_tail(a_speakint->si_diaglist, &a_dialogue, sizeof a_dialogue);
+ ys_dll_add_tail(actor->a_intentlist, &a_intent, sizeof a_intent);
}
if (sem != NULL) {
@@ -643,56 +481,40 @@ int ACTOR_Speak(int index, const char *d_string, uint16 d_voice_rn, R_SEMAPHORE
return R_SUCCESS;
}
-int
-HandleSpeakIntent(R_ACTOR * actor,
- R_SPEAKINTENT * a_speakint, int *complete_p, int msec)
-{
-
+int HandleSpeakIntent(R_ACTOR *actor, R_SPEAKINTENT *a_speakint, int *complete_p, int msec) {
YS_DL_NODE *a_dnode;
YS_DL_NODE *a_dnext;
-
R_ACTORDIALOGUE *a_dialogue;
R_ACTORDIALOGUE *a_dialogue2;
-
long carry_time;
int intent_complete = 0;
if (!a_speakint->si_init) {
-
- /* Initialize speak intent by setting up action */
-
+ // Initialize speak intent by setting up action
actor->action = ACTION_SPEAK;
actor->action_frame = 0;
actor->action_time = 0;
actor->action_flags = ACTION_LOOP;
-
a_speakint->si_init = 1;
}
- /* Process actor dialogue list
- * \*--------------------------------------------------------- */
+ // Process actor dialogue list
a_dnode = ys_dll_head(a_speakint->si_diaglist);
-
if (a_dnode != NULL) {
-
a_dialogue = (R_ACTORDIALOGUE *)ys_dll_get_data(a_dnode);
-
if (!a_dialogue->d_playing) {
- /* Dialogue voice hasn't played yet - play it now */
-
+ // Dialogue voice hasn't played yet - play it now
_vm->_sndRes->playVoice(a_dialogue->d_voice_rn);
a_dialogue->d_playing = 1;
}
a_dialogue->d_time -= msec;
-
if (a_dialogue->d_time <= 0) {
+ // Dialogue time has expired; carry negative time to next
+ // dialogue entry if present, release any semaphores and
+ // delete the expired entry
- /* Dialogue time has expired; carry negative time to next
- * dialogue entry if present, release any semaphores and
- * delete the expired entry */
-
- /*actor->action = ACTION_IDLE; */
+ //actor->action = ACTION_IDLE;
if (a_dialogue->d_sem != NULL) {
STHREAD_ReleaseSem(a_dialogue->d_sem);
@@ -702,36 +524,32 @@ HandleSpeakIntent(R_ACTOR * actor,
a_dnext = ys_dll_next(a_dnode);
if (a_dnext != NULL) {
-
a_dialogue2 = (R_ACTORDIALOGUE *)ys_dll_get_data(a_dnode);
a_dialogue2->d_time -= carry_time;
}
ys_dll_delete(a_dnode);
- /* Check if there are any dialogue nodes left. If not,
- * flag this speech intent as complete */
+ // Check if there are any dialogue nodes left. If not,
+ // flag this speech intent as complete
a_dnode = ys_dll_head(a_speakint->si_diaglist);
if (a_dnode == NULL) {
intent_complete = 1;
}
-
}
} else {
intent_complete = 1;
}
if (intent_complete) {
-
*complete_p = 1;
}
return R_SUCCESS;
}
-int ACTOR_GetSpeechTime(const char *d_string, uint16 d_voice_rn)
-{
+int ACTOR_GetSpeechTime(const char *d_string, uint16 d_voice_rn) {
int voice_len;
voice_len = _vm->_sndRes->getVoiceLength(d_voice_rn);
@@ -743,9 +561,7 @@ int ACTOR_GetSpeechTime(const char *d_string, uint16 d_voice_rn)
return voice_len;
}
-int ACTOR_SetOrientation(int index, int orient)
-{
-
+int ACTOR_SetOrientation(int index, int orient) {
R_ACTOR *actor;
if (!ActorModule.init) {
@@ -767,23 +583,19 @@ int ACTOR_SetOrientation(int index, int orient)
return R_SUCCESS;
}
-int ACTOR_SetAction(int index, int action_n, uint16 action_flags)
-{
+int ACTOR_SetAction(int index, int action_n, uint16 action_flags) {
R_ACTOR *actor;
if (!ActorModule.init) {
-
return R_FAILURE;
}
actor = LookupActor(index);
if (actor == NULL) {
-
return R_FAILURE;
}
if ((action_n < 0) || (action_n >= actor->action_ct)) {
-
return R_FAILURE;
}
@@ -795,23 +607,19 @@ int ACTOR_SetAction(int index, int action_n, uint16 action_flags)
return R_SUCCESS;
}
-int ACTOR_SetDefaultAction(int index, int action_n, uint16 action_flags)
-{
+int ACTOR_SetDefaultAction(int index, int action_n, uint16 action_flags) {
R_ACTOR *actor;
if (!ActorModule.init) {
-
return R_FAILURE;
}
actor = LookupActor(index);
if (actor == NULL) {
-
return R_FAILURE;
}
if ((action_n < 0) || (action_n >= actor->action_ct)) {
-
return R_FAILURE;
}
@@ -821,8 +629,7 @@ int ACTOR_SetDefaultAction(int index, int action_n, uint16 action_flags)
return R_SUCCESS;
}
-R_ACTOR *LookupActor(int index)
-{
+R_ACTOR *LookupActor(int index) {
YS_DL_NODE *node;
R_ACTOR *actor;
@@ -844,66 +651,42 @@ R_ACTOR *LookupActor(int index)
return actor;
}
-int LoadActorSpriteIndex(R_ACTOR * actor, int si_rn, int *last_frame_p)
-{
-
+int LoadActorSpriteIndex(R_ACTOR * actor, int si_rn, int *last_frame_p) {
byte *res_p;
size_t res_len;
-
const byte *read_p;
-
int s_action_ct;
R_ACTORACTION *action_p;
int last_frame;
-
int i, orient;
int result;
- result = RSC_LoadResource(ActorModule.actor_ctxt,
- si_rn, &res_p, &res_len);
+ result = RSC_LoadResource(ActorModule.actor_ctxt, si_rn, &res_p, &res_len);
if (result != R_SUCCESS) {
-
- R_printf(R_STDERR,
- "Couldn't load sprite action index resource.\n");
-
+ R_printf(R_STDERR, "Couldn't load sprite action index resource.\n");
return R_FAILURE;
}
read_p = res_p;
-
s_action_ct = res_len / 16;
-
- R_printf(R_STDOUT,
- "Sprite resource contains %d sprite actions.\n", s_action_ct);
-
+ R_printf(R_STDOUT, "Sprite resource contains %d sprite actions.\n", s_action_ct);
action_p = (R_ACTORACTION *)malloc(sizeof(R_ACTORACTION) * s_action_ct);
if (action_p == NULL) {
-
- R_printf(R_STDERR,
- "Couldn't allocate memory for sprite actions.\n");
-
+ R_printf(R_STDERR, "Couldn't allocate memory for sprite actions.\n");
RSC_FreeResource(res_p);
-
return R_MEM;
}
last_frame = 0;
for (i = 0; i < s_action_ct; i++) {
-
for (orient = 0; orient < 4; orient++) {
-
- /* Load all four orientations */
- action_p[i].dir[orient].frame_index =
- ys_read_u16_le(read_p, &read_p);
-
- action_p[i].dir[orient].frame_count =
- ys_read_u16_le(read_p, &read_p);
-
+ // Load all four orientations
+ action_p[i].dir[orient].frame_index = ys_read_u16_le(read_p, &read_p);
+ action_p[i].dir[orient].frame_count = ys_read_u16_le(read_p, &read_p);
if (action_p[i].dir[orient].frame_index > last_frame) {
- last_frame =
- action_p[i].dir[orient].frame_index;
+ last_frame = action_p[i].dir[orient].frame_index;
}
}
}
@@ -920,9 +703,7 @@ int LoadActorSpriteIndex(R_ACTOR * actor, int si_rn, int *last_frame_p)
return R_SUCCESS;
}
-int DeleteActor(int index)
-{
-
+int DeleteActor(int index) {
YS_DL_NODE *node;
R_ACTOR *actor;
@@ -950,15 +731,10 @@ int DeleteActor(int index)
return R_SUCCESS;
}
-int ACTOR_WalkTo(int id, R_POINT * walk_pt, uint16 flags, R_SEMAPHORE * sem)
-/*--------------------------------------------------------------------------*\
-\*--------------------------------------------------------------------------*/
-{
+int ACTOR_WalkTo(int id, R_POINT *walk_pt, uint16 flags, R_SEMAPHORE *sem) {
R_ACTORINTENT actor_intent;
-
R_WALKINTENT *walk_intent;
R_WALKINTENT zero_intent;
-
YS_DL_NODE *node;
R_ACTOR *actor;
@@ -978,7 +754,6 @@ int ACTOR_WalkTo(int id, R_POINT * walk_pt, uint16 flags, R_SEMAPHORE * sem)
walk_intent = (R_WALKINTENT *)malloc(sizeof *walk_intent);
if (walk_intent == NULL) {
-
return R_MEM;
}
@@ -988,7 +763,7 @@ int ACTOR_WalkTo(int id, R_POINT * walk_pt, uint16 flags, R_SEMAPHORE * sem)
walk_intent->sem_held = 1;
walk_intent->sem = sem;
- /* HandleWalkIntent() will create path on initialization */
+ // HandleWalkIntent() will create path on initialization
walk_intent->wi_init = 0;
walk_intent->dst_pt = *walk_pt;
@@ -996,8 +771,7 @@ int ACTOR_WalkTo(int id, R_POINT * walk_pt, uint16 flags, R_SEMAPHORE * sem)
actor_intent.a_iflags = 0;
actor_intent.a_data = walk_intent;
- ys_dll_add_tail(actor->a_intentlist,
- &actor_intent, sizeof actor_intent);
+ ys_dll_add_tail(actor->a_intentlist, &actor_intent, sizeof actor_intent);
if (sem != NULL) {
STHREAD_HoldSem(sem);
@@ -1006,11 +780,7 @@ int ACTOR_WalkTo(int id, R_POINT * walk_pt, uint16 flags, R_SEMAPHORE * sem)
return R_SUCCESS;
}
-int
-ACTOR_SetPathNode(R_WALKINTENT * walk_int,
- R_POINT * src_pt, R_POINT * dst_pt, R_SEMAPHORE * sem)
-{
-
+int ACTOR_SetPathNode(R_WALKINTENT *walk_int, R_POINT *src_pt, R_POINT *dst_pt, R_SEMAPHORE *sem) {
R_WALKNODE new_node;
walk_int->wi_active = 1;
@@ -1027,11 +797,7 @@ ACTOR_SetPathNode(R_WALKINTENT * walk_int,
return R_SUCCESS;
}
-int
-HandleWalkIntent(R_ACTOR * actor,
- R_WALKINTENT * a_walkint, int *complete_p, int delta_time)
-{
-
+int HandleWalkIntent(R_ACTOR *actor, R_WALKINTENT *a_walkint, int *complete_p, int delta_time) {
YS_DL_NODE *walk_p;
YS_DL_NODE *next_p;
@@ -1055,17 +821,11 @@ HandleWalkIntent(R_ACTOR * actor,
char buf[100];
- /* Initialize walk intent
- * \*------------------------------------------------------------- */
+ // Initialize walk intent
if (!a_walkint->wi_init) {
-
a_walkint->nodelist = ys_dll_create();
-
- ACTOR_SetPathNode(a_walkint,
- &actor->a_pt, &a_walkint->dst_pt, a_walkint->sem);
-
+ ACTOR_SetPathNode(a_walkint, &actor->a_pt, &a_walkint->dst_pt, a_walkint->sem);
ACTOR_SetDefaultAction(actor->id, ACTION_IDLE, ACTION_NONE);
-
a_walkint->wi_init = 1;
}
@@ -1078,42 +838,34 @@ HandleWalkIntent(R_ACTOR * actor,
if (node_p->calc_flag == 0) {
-# if 0
- R_printf(R_STDOUT,
- "Calculating new path vector to point (%d, %d)\n",
- node_p->node_pt.x, node_p->node_pt.y);
-# endif
+#if 0
+ R_printf(R_STDOUT, "Calculating new path vector to point (%d, %d)\n", node_p->node_pt.x, node_p->node_pt.y);
+#endif
dx = a_walkint->org.x - node_p->node_pt.x;
dy = a_walkint->org.y - node_p->node_pt.y;
if (dx == 0) {
- R_printf(R_STDOUT,
- "Vertical paths not implemented.\n");
+ R_printf(R_STDOUT, "Vertical paths not implemented.\n");
ys_dll_delete(walk_p);
a_walkint->wi_active = 0;
- /* Release path semaphore... */
+ // Release path semaphore
if ((a_walkint->sem != NULL) && a_walkint->sem_held) {
-
STHREAD_ReleaseSem(a_walkint->sem);
}
*complete_p = 1;
-
return R_FAILURE;
}
a_walkint->slope = (float)dy / dx;
if (dx > 0) {
-
a_walkint->x_dir = -1;
-
if (!(a_walkint->wi_flags & WALK_NOREORIENT)) {
-
if (a_walkint->slope > 1.0) {
actor->orient = ORIENT_N;
} else if (a_walkint->slope < -1.0) {
@@ -1123,11 +875,8 @@ HandleWalkIntent(R_ACTOR * actor,
}
}
} else {
-
a_walkint->x_dir = 1;
-
if (!(a_walkint->wi_flags & WALK_NOREORIENT)) {
-
if (a_walkint->slope > 1.0) {
actor->orient = ORIENT_S;
} else if (a_walkint->slope < -1.0) {
@@ -1140,9 +889,9 @@ HandleWalkIntent(R_ACTOR * actor,
sprintf(buf, "%f", a_walkint->slope);
-# if 0
+#if 0
R_printf(R_STDOUT, "Path slope: %s.\n", buf);
-# endif
+#endif
actor->action = ACTION_WALK;
actor->action_flags = ACTION_LOOP;
@@ -1157,9 +906,7 @@ HandleWalkIntent(R_ACTOR * actor,
path_b = ACTOR_BASE_SPEED * path_time * ACTOR_BASE_ZMOD;
path_slope = a_walkint->slope * a_walkint->x_dir;
- path_x = (path_a * path_b) /
- sqrt((path_a * path_a) *
- (path_slope * path_slope) + (path_b * path_b));
+ path_x = (path_a * path_b) / sqrt((path_a * path_a) * (path_slope * path_slope) + (path_b * path_b));
path_y = path_slope * path_x;
path_x = path_x * a_walkint->x_dir;
@@ -1170,51 +917,40 @@ HandleWalkIntent(R_ACTOR * actor,
if (a_walkint->x_dir == 1) {
if (new_a_x >= node_p->node_pt.x) {
-
-# if 0
+#if 0
R_printf(R_STDOUT, "Path complete.\n");
-# endif
-
+#endif
ys_dll_delete(walk_p);
-
a_walkint->wi_active = 0;
- /* Release path semaphore... */
+ // Release path semaphore
if (a_walkint->sem != NULL) {
STHREAD_ReleaseSem(a_walkint->sem);
}
actor->action_frame = 0;
actor->action = ACTION_IDLE;
-
*complete_p = 1;
-
return R_FAILURE;
}
} else {
-
if (new_a_x <= node_p->node_pt.x) {
-# if 0
+#if 0
R_printf(R_STDOUT, "Path complete.\n");
-# endif
-
+#endif
ys_dll_delete(walk_p);
-
a_walkint->wi_active = 0;
- /* Release path semaphore... */
+ // Release path semaphore
if (a_walkint->sem != NULL) {
STHREAD_ReleaseSem(a_walkint->sem);
}
actor->action_frame = 0;
actor->action = ACTION_IDLE;
-
*complete_p = 1;
-
return R_FAILURE;
-
}
}
@@ -1237,9 +973,7 @@ HandleWalkIntent(R_ACTOR * actor,
return R_SUCCESS;
}
-int ACTOR_Move(int index, R_POINT * move_pt)
-{
-
+int ACTOR_Move(int index, R_POINT *move_pt) {
YS_DL_NODE *node;
R_ACTOR *actor;
@@ -1271,9 +1005,7 @@ int ACTOR_Move(int index, R_POINT * move_pt)
return R_SUCCESS;
}
-int ACTOR_MoveRelative(int index, R_POINT * move_pt)
-{
-
+int ACTOR_MoveRelative(int index, R_POINT *move_pt) {
YS_DL_NODE *node;
R_ACTOR *actor;
@@ -1301,9 +1033,7 @@ int ACTOR_MoveRelative(int index, R_POINT * move_pt)
return R_SUCCESS;
}
-int Z_Compare(const void *elem1, const void *elem2)
-{
-
+int Z_Compare(const void *elem1, const void *elem2) {
const R_ACTOR *actor1 = (const R_ACTOR *) elem1;
const R_ACTOR *actor2 = (const R_ACTOR *) elem2;
@@ -1316,26 +1046,21 @@ int Z_Compare(const void *elem1, const void *elem2)
}
}
-int ACTOR_AtoS(R_POINT * screen, const R_POINT * actor)
-{
-
+int ACTOR_AtoS(R_POINT *screen, const R_POINT *actor) {
screen->x = (actor->x / R_ACTOR_LMULT);
screen->y = (actor->y / R_ACTOR_LMULT);
return R_SUCCESS;
}
-int ACTOR_StoA(R_POINT * actor, const R_POINT * screen)
-{
-
+int ACTOR_StoA(R_POINT *actor, const R_POINT *screen) {
actor->x = (screen->x * R_ACTOR_LMULT);
actor->y = (screen->y * R_ACTOR_LMULT);
return R_SUCCESS;
}
-static void CF_actor_add(int argc, char *argv[])
-{
+static void CF_actor_add(int argc, char *argv[]) {
R_ACTOR actor;
if (argc < 3)
@@ -1351,8 +1076,7 @@ static void CF_actor_add(int argc, char *argv[])
return;
}
-static void CF_actor_del(int argc, char *argv[])
-{
+static void CF_actor_del(int argc, char *argv[]) {
int id;
if (argc < 0)
@@ -1365,8 +1089,7 @@ static void CF_actor_del(int argc, char *argv[])
return;
}
-static void CF_actor_move(int argc, char *argv[])
-{
+static void CF_actor_move(int argc, char *argv[]) {
int id;
R_POINT move_pt;
@@ -1383,8 +1106,7 @@ static void CF_actor_move(int argc, char *argv[])
return;
}
-static void CF_actor_moverel(int argc, char *argv[])
-{
+static void CF_actor_moverel(int argc, char *argv[]) {
int id;
R_POINT move_pt;
@@ -1401,9 +1123,7 @@ static void CF_actor_moverel(int argc, char *argv[])
return;
}
-static void CF_actor_seto(int argc, char *argv[])
-{
-
+static void CF_actor_seto(int argc, char *argv[]) {
int id;
int orient;
@@ -1418,8 +1138,7 @@ static void CF_actor_seto(int argc, char *argv[])
return;
}
-static void CF_actor_setact(int argc, char *argv[])
-{
+static void CF_actor_setact(int argc, char *argv[]) {
int index = 0;
int action_n = 0;
@@ -1445,10 +1164,10 @@ static void CF_actor_setact(int argc, char *argv[])
}
CON_Print("Action frame counts: %d %d %d %d.",
- actor->act_tbl[action_n].dir[0].frame_count,
- actor->act_tbl[action_n].dir[1].frame_count,
- actor->act_tbl[action_n].dir[2].frame_count,
- actor->act_tbl[action_n].dir[3].frame_count);
+ actor->act_tbl[action_n].dir[0].frame_count,
+ actor->act_tbl[action_n].dir[1].frame_count,
+ actor->act_tbl[action_n].dir[2].frame_count,
+ actor->act_tbl[action_n].dir[3].frame_count);
ACTOR_SetAction(index, action_n, ACTION_LOOP);
diff --git a/saga/actor.h b/saga/actor.h
index 29fa8c9c85..2b7d70d6a2 100644
--- a/saga/actor.h
+++ b/saga/actor.h
@@ -20,15 +20,8 @@
* $Header$
*
*/
-/*
- Description:
-
- Actor management module header file
- Notes:
-
- Hardcoded actor table present in r_actordata.c
-*/
+// Actor management module header file
#ifndef SAGA_ACTOR_H__
#define SAGA_ACTOR_H__
@@ -49,27 +42,21 @@ namespace Saga {
#define R_ACTOR_LMULT 4
enum R_ACTOR_INTENTS {
-
INTENT_NONE = 0,
INTENT_PATH = 1,
INTENT_SPEAK = 2
};
struct R_ACTORACTIONITEM {
-
int frame_index;
int frame_count;
-
};
struct R_ACTORACTION {
-
R_ACTORACTIONITEM dir[4];
-
};
struct R_WALKINTENT {
-
int wi_active;
uint16 wi_flags;
int wi_init;
@@ -85,158 +72,112 @@ struct R_WALKINTENT {
int sem_held;
R_SEMAPHORE *sem;
-
- R_WALKINTENT() { memset(this, 0, sizeof(*this)); }
+ R_WALKINTENT() { memset(this, 0, sizeof(*this)); }
};
struct R_WALKNODE {
-
int calc_flag;
R_POINT node_pt;
-
};
struct R_SPEAKINTENT {
-
int si_init;
uint16 si_flags;
int si_last_action;
-
YS_DL_LIST *si_diaglist; /* Actor dialogue list */
-
};
struct R_ACTORINTENT {
-
int a_itype;
uint16 a_iflags;
int a_idone;
-
void *a_data;
-
- R_ACTORINTENT() { memset(this, 0, sizeof(*this)); }
+ R_ACTORINTENT() { memset(this, 0, sizeof(*this)); }
};
struct R_ACTOR {
-
- int id; /* Actor id */
- int name_i; /* Actor's index in actor name string list */
+ int id; // Actor id
+ int name_i; // Actor's index in actor name string list
uint16 flags;
- R_POINT a_pt; /* Actor's logical coordinates */
- R_POINT s_pt; /* Actor's screen coordinates */
+ R_POINT a_pt; // Actor's logical coordinates
+ R_POINT s_pt; // Actor's screen coordinates
- int sl_rn; /* Actor's sprite list res # */
- int si_rn; /* Actor's sprite index res # */
- R_SPRITELIST *sl_p; /* Actor's sprite list data */
+ int sl_rn; // Actor's sprite list res #
+ int si_rn; // Actor's sprite index res #
+ R_SPRITELIST *sl_p;// Actor's sprite list data
int idle_time;
int orient;
int speaking;
- int a_dcolor; /* Actor dialogue color */
+ int a_dcolor; // Actor dialogue color
- /* The actor intent list describes what the actor intends to do;
- * multiple intents can be queued. The actor must complete an
- * intent before moving on to the next; thus actor movements, esp
- * as described from scripts, can be serialized */
+ // The actor intent list describes what the actor intends to do;
+ // multiple intents can be queued. The actor must complete an
+ // intent before moving on to the next; thus actor movements, esp
+ // as described from scripts, can be serialized
YS_DL_LIST *a_intentlist;
-/*
- R_WALKPATH path;
-*/
+
+// R_WALKPATH path;
int def_action;
uint16 def_action_flags;
int action;
uint16 action_flags;
-
int action_frame;
int action_time;
- R_ACTORACTION *act_tbl; /* Action lookup table */
- int action_ct; /* Number of actions in the action LUT */
-
- YS_DL_NODE *node; /* Actor's node in the actor list */
-
+ R_ACTORACTION *act_tbl; // Action lookup table
+ int action_ct; // Number of actions in the action LUT
+ YS_DL_NODE *node; // Actor's node in the actor list
R_ACTOR() { memset(this, 0, sizeof(*this)); }
-
};
struct R_ACTORDIALOGUE {
-
int d_playing;
const char *d_string;
uint16 d_voice_rn;
-
long d_time;
int d_sem_held;
R_SEMAPHORE *d_sem;
-
R_ACTORDIALOGUE() { memset(this, 0, sizeof(*this)); }
-
};
struct R_ACTIONTIMES {
-
int action;
int time;
-
};
struct R_ACTOR_MODULE {
-
int init;
-
R_RSCFILE_CONTEXT *actor_ctxt;
-
uint16 count;
-
int *alias_tbl;
YS_DL_NODE **tbl;
YS_DL_LIST *list;
-
int err_n;
const char *err_str;
-
};
R_ACTOR *LookupActor(int index);
-
int AddActor(R_ACTOR * actor);
-
int Z_Compare(const void *elem1, const void *elem2);
-
-int
-HandleWalkIntent(R_ACTOR * actor,
- R_WALKINTENT * a_walk_int, int *complete_p, int msec);
-
-int
-HandleSpeakIntent(R_ACTOR * actor,
- R_SPEAKINTENT * a_speakint, int *complete_p, int msec);
-
-int
-ACTOR_SetPathNode(R_WALKINTENT * walk_int,
- R_POINT * src_pt, R_POINT * dst_pt, R_SEMAPHORE * sem);
-
-int LoadActorSpriteIndex(R_ACTOR * actor, int si_rn, int *last_frame_p);
-
+int HandleWalkIntent(R_ACTOR *actor, R_WALKINTENT *a_walk_int, int *complete_p, int msec);
+int HandleSpeakIntent(R_ACTOR *actor, R_SPEAKINTENT *a_speakint, int *complete_p, int msec);
+int ACTOR_SetPathNode(R_WALKINTENT *walk_int, R_POINT *src_pt, R_POINT *dst_pt, R_SEMAPHORE *sem);
+int LoadActorSpriteIndex(R_ACTOR *actor, int si_rn, int *last_frame_p);
static void CF_actor_add(int argc, char *argv[]);
-
static void CF_actor_del(int argc, char *argv[]);
-
static void CF_actor_move(int argc, char *argv[]);
-
static void CF_actor_moverel(int argc, char *argv[]);
-
static void CF_actor_seto(int argc, char *argv[]);
-
static void CF_actor_setact(int argc, char *argv[]);
} // End of namespace Saga
-#endif /* R_ACTOR_H__ */
-/* end "r_actor.h" */
+#endif
diff --git a/saga/actor_mod.h b/saga/actor_mod.h
index d53f851029..e6d87ea1de 100644
--- a/saga/actor_mod.h
+++ b/saga/actor_mod.h
@@ -20,13 +20,8 @@
* $Header$
*
*/
-/*
- Description:
-
- Actor management module public header file
- Notes:
-*/
+// Actor management module public header file
#ifndef SAGA_ACTOR_MOD_H
#define SAGA_ACTOR_MOD_H
@@ -34,13 +29,11 @@
namespace Saga {
enum R_ACTOR_WALKFLAGS {
-
WALK_NONE = 0x00,
WALK_NOREORIENT = 0x01
};
enum R_ACTOR_ORIENTATIONS {
-
ORIENT_N = 0,
ORIENT_NE = 1,
ORIENT_E = 2,
@@ -52,7 +45,6 @@ enum R_ACTOR_ORIENTATIONS {
};
enum R_ACTOR_ACTIONS {
-
ACTION_IDLE = 0,
ACTION_WALK = 1,
ACTION_SPEAK = 2,
@@ -60,34 +52,33 @@ enum R_ACTOR_ACTIONS {
};
enum R_ACTOR_ACTIONFLAGS {
-
ACTION_NONE = 0x00,
ACTION_LOOP = 0x01
};
-int ACTOR_Register(void);
-int ACTOR_Init(void);
-int ACTOR_Shutdown(void);
+int ACTOR_Register();
+int ACTOR_Init();
+int ACTOR_Shutdown();
int ACTOR_Direct(int msec);
int ACTOR_Create(int actor_id, int x, int y);
int ACTOR_ActorExists(uint16 actor_id);
-int ACTOR_DrawList(void);
-int ACTOR_AtoS(R_POINT * logical, const R_POINT * actor);
-int ACTOR_StoA(R_POINT * actor, const R_POINT * screen);
+int ACTOR_DrawList();
+int ACTOR_AtoS(R_POINT *logical, const R_POINT *actor);
+int ACTOR_StoA(R_POINT *actor, const R_POINT *screen);
-int ACTOR_Move(int index, R_POINT * move_pt);
-int ACTOR_MoveRelative(int index, R_POINT * move_pt);
+int ACTOR_Move(int index, R_POINT *move_pt);
+int ACTOR_MoveRelative(int index, R_POINT *move_pt);
-int ACTOR_WalkTo(int index, R_POINT * walk_pt, uint16 flags, R_SEMAPHORE * sem);
+int ACTOR_WalkTo(int index, R_POINT *walk_pt, uint16 flags, R_SEMAPHORE *sem);
int ACTOR_GetActorIndex(uint16 actor_id);
-int ACTOR_Speak(int index, const char *d_string, uint16 d_voice_rn, R_SEMAPHORE * sem);
+int ACTOR_Speak(int index, const char *d_string, uint16 d_voice_rn, R_SEMAPHORE *sem);
-int ACTOR_SkipDialogue(void);
+int ACTOR_SkipDialogue();
int ACTOR_GetSpeechTime(const char *d_string, uint16 d_voice_rn);
int ACTOR_SetOrientation(int index, int orient);
@@ -96,5 +87,4 @@ int ACTOR_SetDefaultAction(int index, int action_n, uint16 action_flags);
} // End of namespace Saga
-#endif /* R_ACTOR_MOD_H */
-/* end "r_actor_mod.h" */
+#endif
diff --git a/saga/actordata.cpp b/saga/actordata.cpp
index 5342d2d9b8..fee8b9d95c 100644
--- a/saga/actordata.cpp
+++ b/saga/actordata.cpp
@@ -20,28 +20,23 @@
* $Header$
*
*/
-/*
- Description:
-
- Actor data table
- Notes:
-*/
+// Actor data table
#include "actordata.h"
namespace Saga {
-/* Lookup table to convert 8 cardinal directions to 4 */
+// Lookup table to convert 8 cardinal directions to 4
int ActorOrientationLUT[] = { 2, 0, 0, 0, 3, 1, 1, 1 };
R_ACTORTABLE ActorTable[R_ACTORCOUNT] = {
-/* namei sl_rn si_rn col
- ----- ----- ----- --- */
+// namei sl_rn si_rn col
+// ----- ----- ----- ---
{0, 1, 0, 0, 0, 37, 135, 0, 1, 0, 0, 0},
- /* original okk entry
- * { 1, 0, 0, 0, 0, 0, 0, 1, 132, 0, 0, 0 }, */
+ // original okk entry
+ // { 1, 0, 0, 0, 0, 0, 0, 1, 132, 0, 0, 0 },
{1, 0, 0, 0, 0, 45, 144, 1, 132, 0, 0, 0},
{2, 0, 0, 0, 0, 48, 143, 2, 161, 0, 0, 0},
{3, 0, 240, 480, 0, 115, 206, 0, 25, 0, 0, 0},
diff --git a/saga/actordata.h b/saga/actordata.h
index abf3fb9ced..a63af88076 100644
--- a/saga/actordata.h
+++ b/saga/actordata.h
@@ -20,13 +20,8 @@
* $Header$
*
*/
-/*
- Description:
-
- Actor data table header file
- Notes:
-*/
+// Actor data table header file
#ifndef SAGA_ACTORDATA_H
#define SAGA_ACTORDATA_H
@@ -34,7 +29,6 @@
namespace Saga {
struct R_ACTORTABLE {
-
int name_index;
int unknown1;
int unknown2;
@@ -47,7 +41,6 @@ struct R_ACTORTABLE {
unsigned char unknown6;
unsigned char unknown7;
unsigned char unknown8;
-
};
#define R_ACTORCOUNT 181
@@ -57,6 +50,4 @@ extern R_ACTORTABLE ActorTable[R_ACTORCOUNT];
} // End of namespace Saga
-#endif /* R_ACTORDATA_H */
-
-/* end "r_actordata.h" */
+#endif
diff --git a/saga/animation.cpp b/saga/animation.cpp
index e21b2aef92..84b12b83f8 100644
--- a/saga/animation.cpp
+++ b/saga/animation.cpp
@@ -20,30 +20,18 @@
* $Header$
*
*/
-/*
- Description:
-
- Background animation management module
- Notes:
-*/
+// Background animation management module
#include "reinherit.h"
-
#include "yslib.h"
-/*
- * Uses the following modules:
-\*--------------------------------------------------------------------------*/
#include "cvar_mod.h"
#include "console_mod.h"
#include "game_mod.h"
#include "events_mod.h"
#include "render_mod.h"
-/*
- * Begin module
-\*--------------------------------------------------------------------------*/
#include "animation_mod.h"
#include "animation.h"
@@ -51,42 +39,30 @@ namespace Saga {
static R_ANIMINFO AnimInfo;
-int ANIM_Register(void)
-{
+int ANIM_Register() {
CVAR_RegisterFunc(CF_anim_info, "anim_info", NULL, R_CVAR_NONE, 0, 0);
-
return R_SUCCESS;
}
-int ANIM_Init(void)
-{
-
+int ANIM_Init() {
AnimInfo.anim_limit = R_MAX_ANIMATIONS;
AnimInfo.anim_count = 0;
-
AnimInfo.initialized = 1;
-
return R_SUCCESS;
}
-int ANIM_Shutdown(void)
-{
+int ANIM_Shutdown(void) {
uint16 i;
for (i = 0; i < R_MAX_ANIMATIONS; i++) {
-
free(AnimInfo.anim_tbl[i]);
}
AnimInfo.initialized = 0;
-
return R_SUCCESS;
}
-int
-ANIM_Load(const byte * anim_resdata,
- size_t anim_resdata_len, uint16 * anim_id_p)
-{
+int ANIM_Load(const byte *anim_resdata, size_t anim_resdata_len, uint16 *anim_id_p) {
R_ANIMATION *new_anim;
uint16 anim_id = 0;
@@ -96,12 +72,9 @@ ANIM_Load(const byte * anim_resdata,
return R_FAILURE;
}
- /* Find an unused animation slot
- * \*------------------------------------------------------------- */
+ // Find an unused animation slot
for (i = 0; i < R_MAX_ANIMATIONS; i++) {
-
if (AnimInfo.anim_tbl[i] == NULL) {
-
anim_id = i;
break;
}
@@ -114,7 +87,6 @@ ANIM_Load(const byte * anim_resdata,
new_anim = (R_ANIMATION *)malloc(sizeof *new_anim);
if (new_anim == NULL) {
R_printf(R_STDERR, "Error: Allocation failure.\n");
-
return R_MEM;
}
@@ -122,41 +94,28 @@ ANIM_Load(const byte * anim_resdata,
new_anim->resdata_len = anim_resdata_len;
if (GAME_GetGameType() == R_GAMETYPE_ITE) {
-
- if (ANIM_GetNumFrames(anim_resdata,
- &new_anim->n_frames) != R_SUCCESS) {
-
- R_printf(R_STDERR,
- "Error: Couldn't get animation frame count.\n");
-
+ if (ANIM_GetNumFrames(anim_resdata, &new_anim->n_frames) != R_SUCCESS) {
+ R_printf(R_STDERR, "Error: Couldn't get animation frame count.\n");
return R_FAILURE;
}
- /* Cache frame offsets
- * \*------------------------------------------------------------- */
- new_anim->frame_offsets = (size_t *)malloc(new_anim->n_frames *
- sizeof *new_anim->frame_offsets);
+ // Cache frame offsets
+ new_anim->frame_offsets = (size_t *)malloc(new_anim->n_frames * sizeof *new_anim->frame_offsets);
if (new_anim->frame_offsets == NULL) {
R_printf(R_STDERR, "Error: Allocation failure.\n");
-
return R_MEM;
}
for (i = 0; i < new_anim->n_frames; i++) {
-
- ANIM_GetFrameOffset(anim_resdata,
- i + 1, &new_anim->frame_offsets[i]);
+ ANIM_GetFrameOffset(anim_resdata, i + 1, &new_anim->frame_offsets[i]);
}
} else {
new_anim->cur_frame_p = anim_resdata + SAGA_FRAME_HEADER_LEN;
- new_anim->cur_frame_len =
- anim_resdata_len - SAGA_FRAME_HEADER_LEN;
-
+ new_anim->cur_frame_len = anim_resdata_len - SAGA_FRAME_HEADER_LEN;
ANIM_GetNumFrames(anim_resdata, &new_anim->n_frames);
}
- /* Set animation data
- * \*------------------------------------------------------------- */
+ // Set animation data
new_anim->current_frame = 1;
new_anim->end_frame = new_anim->n_frames;
new_anim->stop_frame = new_anim->end_frame;
@@ -176,14 +135,11 @@ ANIM_Load(const byte * anim_resdata,
return R_SUCCESS;
}
-int ANIM_Link(uint16 anim_id1, uint16 anim_id2)
-{
+int ANIM_Link(uint16 anim_id1, uint16 anim_id2) {
R_ANIMATION *anim1;
R_ANIMATION *anim2;
- if ((anim_id1 >= AnimInfo.anim_count) ||
- (anim_id2 >= AnimInfo.anim_count)) {
-
+ if ((anim_id1 >= AnimInfo.anim_count) || (anim_id2 >= AnimInfo.anim_count)) {
return R_FAILURE;
}
@@ -202,9 +158,7 @@ int ANIM_Link(uint16 anim_id1, uint16 anim_id2)
return R_SUCCESS;
}
-int ANIM_Play(uint16 anim_id, int vector_time)
-{
-
+int ANIM_Play(uint16 anim_id, int vector_time) {
R_EVENT event;
R_ANIMATION *anim;
R_ANIMATION *link_anim;
@@ -223,7 +177,6 @@ int ANIM_Play(uint16 anim_id, int vector_time)
R_GAME_DISPLAYINFO disp_info;
if (anim_id >= AnimInfo.anim_count) {
-
return R_FAILURE;
}
@@ -234,51 +187,29 @@ int ANIM_Play(uint16 anim_id, int vector_time)
anim = AnimInfo.anim_tbl[anim_id];
if (anim == NULL) {
-
return R_FAILURE;
}
if (anim->play_flag) {
-
frame = anim->current_frame;
-
if (GAME_GetGameType() == R_GAMETYPE_ITE) {
-
- result = ITE_DecodeFrame(anim->resdata,
- anim->frame_offsets[frame - 1],
- display_buf,
- disp_info.logical_w * disp_info.logical_h);
-
+ result = ITE_DecodeFrame(anim->resdata, anim->frame_offsets[frame - 1], display_buf,
+ disp_info.logical_w * disp_info.logical_h);
if (result != R_SUCCESS) {
-
- R_printf(R_STDERR,
- "ANIM_Play: Error decoding frame %u",
- anim->current_frame);
-
+ R_printf(R_STDERR, "ANIM_Play: Error decoding frame %u", anim->current_frame);
anim->play_flag = 0;
return R_FAILURE;
}
} else {
-
if (anim->cur_frame_p == NULL) {
- R_printf(R_STDERR,
- "ANIM_Play: Frames exhausted.\n");
-
+ R_printf(R_STDERR, "ANIM_Play: Frames exhausted.\n");
return R_FAILURE;
}
- result = IHNM_DecodeFrame(display_buf,
- disp_info.logical_w *
- disp_info.logical_h,
- anim->cur_frame_p,
- anim->cur_frame_len, &nextf_p, &nextf_len);
-
+ result = IHNM_DecodeFrame(display_buf, disp_info.logical_w * disp_info.logical_h,
+ anim->cur_frame_p, anim->cur_frame_len, &nextf_p, &nextf_len);
if (result != R_SUCCESS) {
-
- R_printf(R_STDERR,
- "ANIM_Play: Error decoding frame %u",
- anim->current_frame);
-
+ R_printf(R_STDERR, "ANIM_Play: Error decoding frame %u", anim->current_frame);
anim->play_flag = 0;
return R_FAILURE;
}
@@ -286,19 +217,15 @@ int ANIM_Play(uint16 anim_id, int vector_time)
anim->cur_frame_p = nextf_p;
anim->cur_frame_len = nextf_len;
}
-
anim->current_frame++;
}
anim->play_flag = 1;
if (anim->current_frame > anim->n_frames) {
-
- /* Animation done playing */
-
+ // Animation done playing
if (anim->link_flag) {
-
- /* If this animation has a link, follow it */
+ // If this animation has a link, follow it
anim->play_flag = 0;
anim->current_frame = 1;
@@ -306,35 +233,27 @@ int ANIM_Play(uint16 anim_id, int vector_time)
link_anim = AnimInfo.anim_tbl[link_anim_id];
if (link_anim != NULL) {
-
link_anim->current_frame = 1;
link_anim->play_flag = 1;
}
anim_id = link_anim_id;
} else if (anim->flags & ANIM_LOOP) {
-
- /* Loop animation */
+ // Loop animation
anim->current_frame = 1;
-
- anim->cur_frame_p =
- anim->resdata + SAGA_FRAME_HEADER_LEN;
- anim->cur_frame_len =
- anim->resdata_len - SAGA_FRAME_HEADER_LEN;
+ anim->cur_frame_p = anim->resdata + SAGA_FRAME_HEADER_LEN;
+ anim->cur_frame_len = anim->resdata_len - SAGA_FRAME_HEADER_LEN;
} else {
-
- /* No link, stop playing */
+ // No link, stop playing
anim->current_frame = anim->n_frames;
anim->play_flag = 0;
if (anim->flags & ANIM_ENDSCENE) {
-
- /* This animation ends the scene */
+ // This animation ends the scene
event.type = R_ONESHOT_EVENT;
event.code = R_SCENE_EVENT;
event.op = EVENT_END;
event.time = anim->frame_time + vector_time;
-
EVENT_Queue(&event);
}
return R_SUCCESS;
@@ -352,8 +271,7 @@ int ANIM_Play(uint16 anim_id, int vector_time)
return R_SUCCESS;
}
-int ANIM_Reset(void)
-{
+int ANIM_Reset() {
uint16 i;
for (i = 0; i < R_MAX_ANIMATIONS; i++) {
@@ -366,18 +284,15 @@ int ANIM_Reset(void)
return R_SUCCESS;
}
-int ANIM_SetFlag(uint16 anim_id, uint16 flag)
-{
+int ANIM_SetFlag(uint16 anim_id, uint16 flag) {
R_ANIMATION *anim;
if (anim_id > AnimInfo.anim_count) {
-
return R_FAILURE;
}
anim = AnimInfo.anim_tbl[anim_id];
if (anim == NULL) {
-
return R_FAILURE;
}
@@ -386,18 +301,15 @@ int ANIM_SetFlag(uint16 anim_id, uint16 flag)
return R_SUCCESS;
}
-int ANIM_SetFrameTime(uint16 anim_id, int time)
-{
+int ANIM_SetFrameTime(uint16 anim_id, int time) {
R_ANIMATION *anim;
if (anim_id > AnimInfo.anim_count) {
-
return R_FAILURE;
}
anim = AnimInfo.anim_tbl[anim_id];
if (anim == NULL) {
-
return R_FAILURE;
}
@@ -406,23 +318,19 @@ int ANIM_SetFrameTime(uint16 anim_id, int time)
return R_SUCCESS;
}
-int ANIM_Free(uint16 anim_id)
-{
+int ANIM_Free(uint16 anim_id) {
R_ANIMATION *anim;
if (anim_id > AnimInfo.anim_count) {
-
return R_FAILURE;
}
anim = AnimInfo.anim_tbl[anim_id];
if (anim == NULL) {
-
return R_FAILURE;
}
if (GAME_GetGameType() == R_GAMETYPE_ITE) {
-
free(anim->frame_offsets);
anim->frame_offsets = NULL;
}
@@ -434,14 +342,11 @@ int ANIM_Free(uint16 anim_id)
return R_SUCCESS;
}
-int ANIM_GetNumFrames(const byte * anim_resource, uint16 * n_frames)
-/*--------------------------------------------------------------------------*\
- * The actual number of frames present in an animation resource is
- * sometimes less than number present in the .nframes member of the
- * animation header. For this reason, the function attempts to find
- * the last valid frame number, which it returns via 'n_frames'
-\*--------------------------------------------------------------------------*/
-{
+// The actual number of frames present in an animation resource is
+// sometimes less than number present in the .nframes member of the
+// animation header. For this reason, the function attempts to find
+// the last valid frame number, which it returns via 'n_frames'
+int ANIM_GetNumFrames(const byte *anim_resource, uint16 *n_frames) {
R_ANIMATION_HEADER ah;
size_t offset;
@@ -452,7 +357,6 @@ int ANIM_GetNumFrames(const byte * anim_resource, uint16 * n_frames)
const byte *read_p = anim_resource;
if (!AnimInfo.initialized) {
-
return R_FAILURE;
}
@@ -465,25 +369,18 @@ int ANIM_GetNumFrames(const byte * anim_resource, uint16 * n_frames)
ah.nframes = ys_read_u8(read_p, NULL);
if (GAME_GetGameType() == R_GAMETYPE_IHNM) {
-
*n_frames = ah.nframes;
}
if (ah.magic == 68) {
-
for (x = ah.nframes; x > 0; x--) {
-
- if (ANIM_GetFrameOffset(anim_resource,
- x, &offset) != R_SUCCESS) {
-
+ if (ANIM_GetFrameOffset(anim_resource, x, &offset) != R_SUCCESS) {
return R_FAILURE;
}
magic = *(anim_resource + offset);
-
if (magic == SAGA_FRAME_HEADER_MAGIC) {
*n_frames = x;
-
return R_SUCCESS;
}
}
@@ -494,11 +391,7 @@ int ANIM_GetNumFrames(const byte * anim_resource, uint16 * n_frames)
return R_FAILURE;
}
-int
-ITE_DecodeFrame(const byte * resdata,
- size_t frame_offset, byte * buf, size_t buf_len)
-{
-
+int ITE_DecodeFrame(const byte * resdata, size_t frame_offset, byte * buf, size_t buf_len) {
R_ANIMATION_HEADER ah;
R_FRAME_HEADER fh;
@@ -525,12 +418,10 @@ ITE_DecodeFrame(const byte * resdata,
uint16 i;
if (!AnimInfo.initialized) {
-
return R_FAILURE;
}
- /* Read animation header
- * \*------------------------------------------------------------- */
+ // Read animation header
ah.magic = ys_read_u16_le(read_p, &read_p);
ah.screen_w = ys_read_u16_le(read_p, &read_p);
ah.screen_h = ys_read_u16_le(read_p, &read_p);
@@ -545,29 +436,24 @@ ITE_DecodeFrame(const byte * resdata,
screen_h = ah.screen_h;
if ((screen_w * screen_h) > buf_len) {
- /* Buffer argument is too small to hold decoded frame, abort. */
- R_printf(R_STDERR,
- "ITE_DecodeFrame: Buffer size inadequate.\n");
-
+ // Buffer argument is too small to hold decoded frame, abort.
+ R_printf(R_STDERR, "ITE_DecodeFrame: Buffer size inadequate.\n");
return R_FAILURE;
}
- /* Read frame header
- * \*------------------------------------------------------------- */
+ // Read frame header
read_p = resdata + frame_offset;
- /* Check for frame magic byte */
+ // Check for frame magic byte
magic = ys_read_u8(read_p, &read_p);
if (magic != SAGA_FRAME_HEADER_MAGIC) {
-
R_printf(R_STDERR, "ITE_DecodeFrame: Invalid frame offset.\n");
-
return R_FAILURE;
}
- /* For some strange reason, the animation header is in little
- * endian format, but the actual RLE encoded frame data,
- * including the frame header, is in big endian format. */
+ // For some strange reason, the animation header is in little
+ // endian format, but the actual RLE encoded frame data,
+ // including the frame header, is in big endian format.
fh.x_start = ys_read_u16_be(read_p, &read_p);
fh.y_start = ys_read_u8(read_p, &read_p);
@@ -580,22 +466,15 @@ ITE_DecodeFrame(const byte * resdata,
x_start = fh.x_start;
y_start = fh.y_start;
- /* Setup write pointer to the draw origin
- * \*------------------------------------------------------------- */
+ // Setup write pointer to the draw origin
write_p = (buf + (y_start * screen_w) + x_start);
- /* Begin RLE decompression to output buffer
- * \*------------------------------------------------------------- */
+ // Begin RLE decompression to output buffer
do {
-
mark_byte = ys_read_u8(read_p, &read_p);
-
switch (mark_byte) {
-
- case 0x10: /* Long Unencoded Run */
-
+ case 0x10: // Long Unencoded Run
runcount = ys_read_s16_be(read_p, &read_p);
-
for (i = 0; i < runcount; i++) {
if (*read_p != 0) {
*write_p = *read_p;
@@ -605,79 +484,55 @@ ITE_DecodeFrame(const byte * resdata,
}
continue;
break;
-
- case 0x20: /* Long encoded run */
-
+ case 0x20: // Long encoded run
runcount = ys_read_s16_be(read_p, &read_p);
-
data_byte = *read_p++;
-
for (i = 0; i < runcount; i++) {
*write_p++ = data_byte;
}
continue;
break;
-
- case 0x2F: /* End of row */
-
+ case 0x2F: // End of row
x_vector = ys_read_s16_be(read_p, &read_p);
new_row = ys_read_u8(read_p, &read_p);
-
- /* Set write pointer to the new draw origin */
- write_p = buf + ((y_start + new_row) * screen_w)
- + x_start + x_vector;
+ // Set write pointer to the new draw origin
+ write_p = buf + ((y_start + new_row) * screen_w) + x_start + x_vector;
continue;
break;
-
- case 0x30: /* Reposition command */
-
+ case 0x30: // Reposition command
x_vector = ys_read_s16_be(read_p, &read_p);
-
write_p += x_vector;
continue;
break;
-
- case 0x3F: /* End of frame marker */
-
+ case 0x3F: // End of frame marker
return R_SUCCESS;
break;
-
default:
break;
}
- /* Mask all but two high order control bits */
+ // Mask all but two high order control bits
control_ch = mark_byte & 0xC0U;
param_ch = mark_byte & 0x3FU;
-
switch (control_ch) {
-
- case 0xC0: /* 1100 0000 */
-
- /* Run of empty pixels */
+ case 0xC0: // 1100 0000
+ // Run of empty pixels
runcount = param_ch + 1;
write_p += runcount;
continue;
break;
-
- case 0x80: /* 1000 0000 */
-
- /* Run of compressed data */
+ case 0x80: // 1000 0000
+ // Run of compressed data
runcount = param_ch + 1;
-
data_byte = *read_p++;
-
for (i = 0; i < runcount; i++) {
*write_p++ = data_byte;
}
continue;
break;
-
- case 0x40: /* 0100 0000 */
-
- /* Uncompressed run */
+ case 0x40: // 0100 0000
+ // Uncompressed run
runcount = param_ch + 1;
-
for (i = 0; i < runcount; i++) {
if (*read_p != 0) {
*write_p = *read_p;
@@ -687,40 +542,25 @@ ITE_DecodeFrame(const byte * resdata,
}
continue;
break;
-
default:
- /* Unknown marker found - abort */
-
- R_printf(R_STDERR,
- "ITE_DecodeFrame: Invalid RLE marker "
- "encountered.\n");
-
+ // Unknown marker found - abort
+ R_printf(R_STDERR, "ITE_DecodeFrame: Invalid RLE marker encountered.\n");
return R_FAILURE;
break;
}
-
- } while (mark_byte != 63); /* end of frame marker */
+ } while (mark_byte != 63); // end of frame marker
return R_SUCCESS;
}
-int
-IHNM_DecodeFrame(byte * decode_buf,
- size_t decode_buf_len,
- const byte * thisf_p,
- size_t thisf_len, const byte ** nextf_p, size_t * nextf_len)
-{
-
+int IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte *thisf_p,
+ size_t thisf_len, const byte **nextf_p, size_t *nextf_len) {
int in_ch;
-
int decoded_data = 0;
int cont_flag = 1;
-
int control_ch;
int param_ch;
-
byte data_pixel;
-
int x_origin = 0;
int y_origin = 0;
int x_vector;
@@ -745,15 +585,11 @@ IHNM_DecodeFrame(byte * decode_buf,
*nextf_p = NULL;
for (; cont_flag; decoded_data = 1) {
-
in_ch_offset = (size_t) (inbuf_p - thisf_p);
-
in_ch = *inbuf_p++;
inbuf_remain--;
-
switch (in_ch) {
-
- case 0x0F: /* 15: Frame header */
+ case 0x0F: // 15: Frame header
{
int param1;
int param2;
@@ -763,16 +599,13 @@ IHNM_DecodeFrame(byte * decode_buf,
int param6;
if (inbuf_remain < 13) {
- R_printf(R_STDERR,
- "0x%02X: Input buffer underrun.",
- in_ch);
-
+ R_printf(R_STDERR, "0x%02X: Input buffer underrun.", in_ch);
return R_FAILURE;
}
param1 = ys_read_u16_be(inbuf_p, &inbuf_p);
param2 = ys_read_u16_be(inbuf_p, &inbuf_p);
- inbuf_p++; /* skip 1? */
+ inbuf_p++; // skip 1?
param3 = ys_read_u16_be(inbuf_p, &inbuf_p);
param4 = ys_read_u16_be(inbuf_p, &inbuf_p);
param5 = ys_read_u16_be(inbuf_p, &inbuf_p);
@@ -783,43 +616,26 @@ IHNM_DecodeFrame(byte * decode_buf,
x_origin = param1;
y_origin = param2;
- outbuf_p = decode_buf + x_origin +
- (y_origin * di.logical_w);
+ outbuf_p = decode_buf + x_origin + (y_origin * di.logical_w);
if (outbuf_p > outbuf_endp) {
-
- R_printf(R_STDERR,
- "0x%02X: (0x%X) Invalid output position. "
- "(x: %d, y: %d)\n",
- in_ch,
- in_ch_offset, x_origin, y_origin);
-
+ R_printf(R_STDERR, "0x%02X: (0x%X) Invalid output position. (x: %d, y: %d)\n",
+ in_ch, in_ch_offset, x_origin, y_origin);
return R_FAILURE;
}
outbuf_remain = (outbuf_endp - outbuf_p) + 1;
-
continue;
}
break;
-
- case 0x10: /* Long Unencoded Run */
-
+ case 0x10: // Long Unencoded Run
runcount = ys_read_s16_be(inbuf_p, &inbuf_p);
-
if (inbuf_remain < runcount) {
-
- R_printf(R_STDERR,
- "0x%02X: Input buffer underrun.", in_ch);
-
+ R_printf(R_STDERR, "0x%02X: Input buffer underrun.", in_ch);
return R_FAILURE;
}
-
if (outbuf_remain < runcount) {
-
- R_printf(R_STDERR,
- "0x%02X: Output buffer overrun.", in_ch);
-
+ R_printf(R_STDERR, "0x%02X: Output buffer overrun.", in_ch);
return R_FAILURE;
}
@@ -833,33 +649,21 @@ IHNM_DecodeFrame(byte * decode_buf,
inbuf_remain -= runcount;
outbuf_remain -= runcount;
-
continue;
break;
-
- case 0x1F: /* 31: Unusued? */
-
+ case 0x1F: // 31: Unusued?
if (inbuf_remain < 3) {
-
- R_printf(R_STDERR,
- "0x%02X: Input buffer underrun.", in_ch);
-
+ R_printf(R_STDERR, "0x%02X: Input buffer underrun.", in_ch);
return R_FAILURE;
}
inbuf_p += 3;
inbuf_remain -= 3;
-
continue;
break;
-
- case 0x20: /* Long compressed run */
-
+ case 0x20: // Long compressed run
if (inbuf_remain <= 3) {
-
- R_printf(R_STDERR,
- "0x%02X: Input buffer underrun.", in_ch);
-
+ R_printf(R_STDERR, "0x%02X: Input buffer underrun.", in_ch);
return R_FAILURE;
}
@@ -872,12 +676,10 @@ IHNM_DecodeFrame(byte * decode_buf,
outbuf_remain -= runcount;
inbuf_remain -= 1;
-
continue;
break;
- case 0x2F: /* End of row */
-
+ case 0x2F: // End of row
if (inbuf_remain <= 4) {
return R_FAILURE;
}
@@ -885,50 +687,35 @@ IHNM_DecodeFrame(byte * decode_buf,
x_vector = ys_read_s16_be(inbuf_p, &inbuf_p);
new_row = ys_read_s16_be(inbuf_p, &inbuf_p);
- outbuf_p =
- decode_buf + ((y_origin + new_row) * di.logical_w)
- + x_origin + x_vector;
-
+ outbuf_p = decode_buf + ((y_origin + new_row) * di.logical_w) + x_origin + x_vector;
inbuf_remain -= 4;
outbuf_remain = (outbuf_endp - outbuf_p) + 1;
-
continue;
break;
-
- case 0x30: /* Reposition command */
+ case 0x30: // Reposition command
if (inbuf_remain < 2) {
return R_FAILURE;
}
x_vector = ys_read_s16_be(inbuf_p, &inbuf_p);
- if (((x_vector > 0)
- && ((size_t) x_vector > outbuf_remain))
- || (-x_vector > outbuf_p - decode_buf)) {
-
- R_printf(R_STDERR,
- "0x30: Invalid x_vector.\n");
-
+ if (((x_vector > 0) && ((size_t) x_vector > outbuf_remain)) || (-x_vector > outbuf_p - decode_buf)) {
+ R_printf(R_STDERR, "0x30: Invalid x_vector.\n");
return R_FAILURE;
}
outbuf_p += x_vector;
outbuf_remain -= x_vector;
inbuf_remain -= 2;
-
continue;
break;
- case 0x3F: /* 68: Frame end marker */
-
+ case 0x3F: // 68: Frame end marker
printf("0x3F: Frame end marker\n");
-
if (decoded_data && inbuf_remain > 0) {
-
*nextf_p = inbuf_p;
*nextf_len = inbuf_remain;
} else {
-
*nextf_p = NULL;
*nextf_len = 0;
}
@@ -939,34 +726,25 @@ IHNM_DecodeFrame(byte * decode_buf,
default:
break;
-
- } /* end switch() */
+ }
control_ch = in_ch & 0xC0;
param_ch = in_ch & 0x3f;
-
switch (control_ch) {
- case 0xC0: /* Run of empty pixels */
-
+ case 0xC0: // Run of empty pixels
runcount = param_ch + 1;
-
if (outbuf_remain < runcount) {
return R_FAILURE;
}
outbuf_p += runcount;
outbuf_remain -= runcount;
-
continue;
break;
-
- case 0x80: /* Run of compressed data */
-
+ case 0x80: // Run of compressed data
runcount = param_ch + 1;
-
if ((outbuf_remain < runcount) || (inbuf_remain <= 1)) {
-
return R_FAILURE;
}
@@ -979,17 +757,11 @@ IHNM_DecodeFrame(byte * decode_buf,
}
outbuf_remain -= runcount;
-
continue;
break;
-
- case 0x40: /* Uncompressed run */
-
+ case 0x40: // Uncompressed run
runcount = param_ch + 1;
-
- if ((outbuf_remain < runcount) ||
- (inbuf_remain < runcount)) {
-
+ if ((outbuf_remain < runcount) || (inbuf_remain < runcount)) {
return R_FAILURE;
}
@@ -1009,17 +781,13 @@ IHNM_DecodeFrame(byte * decode_buf,
default:
break;
- } /* end switch */
-
- } /* end while() */
+ }
+ }
return R_SUCCESS;
}
-int
-ANIM_GetFrameOffset(const byte * resdata,
- uint16 find_frame, size_t * frame_offset_p)
-{
+int ANIM_GetFrameOffset(const byte *resdata, uint16 find_frame, size_t *frame_offset_p) {
R_ANIMATION_HEADER ah;
uint16 num_frames;
@@ -1031,16 +799,13 @@ ANIM_GetFrameOffset(const byte * resdata,
byte mark_byte;
uint16 control;
uint16 runcount;
-
uint16 magic;
if (!AnimInfo.initialized) {
-
return R_FAILURE;
}
- /* Read animation header
- * \*------------------------------------------------------------- */
+ // Read animation header
ah.magic = ys_read_u16_le(read_p, &read_p);
ah.screen_w = ys_read_u16_le(read_p, &read_p);
ah.screen_h = ys_read_u16_le(read_p, &read_p);
@@ -1054,115 +819,84 @@ ANIM_GetFrameOffset(const byte * resdata,
num_frames = ah.nframes;
if ((find_frame < 1) || (find_frame > num_frames)) {
-
return R_FAILURE;
}
search_ptr = read_p;
-
for (current_frame = 1; current_frame < find_frame; current_frame++) {
-
magic = ys_read_u8(search_ptr, &search_ptr);
-
if (magic != SAGA_FRAME_HEADER_MAGIC) {
-
- /* Frame sync failure. Magic Number not found */
+ // Frame sync failure. Magic Number not found
return R_FAILURE;
}
search_ptr += SAGA_FRAME_HEADER_LEN;
-
- /* For some strange reason, the animation header is in little
- * endian format, but the actual RLE encoded frame data,
- * including the frame header, is in big endian format. */
-
+ // For some strange reason, the animation header is in little
+ // endian format, but the actual RLE encoded frame data,
+ // including the frame header, is in big endian format. */
do {
-
mark_byte = *search_ptr;
-
switch (mark_byte) {
-
- case 0x3F: /* End of frame marker */
-
+ case 0x3F: // End of frame marker
search_ptr++;
continue;
break;
-
- case 0x30: /* Reposition command */
-
+ case 0x30: // Reposition command
search_ptr += 3;
continue;
break;
-
- case 0x2F: /* End of row marker */
-
+ case 0x2F: // End of row marker
search_ptr += 4;
continue;
break;
-
- case 0x20: /* Long compressed run marker */
-
+ case 0x20: // Long compressed run marker
search_ptr += 4;
continue;
break;
-
- case 0x10: /* (16) 0001 0000 */
- /* Long Uncompressed Run */
+ case 0x10: // (16) 0001 0000
+ // Long Uncompressed Run
search_ptr++;
- runcount =
- ys_read_s16_be(search_ptr, &search_ptr);
+ runcount = ys_read_s16_be(search_ptr, &search_ptr);
search_ptr += runcount;
continue;
break;
-
default:
break;
-
}
- /* Mask all but two high order (control) bits */
+ // Mask all but two high order (control) bits
control = mark_byte & 0xC0;
-
switch (control) {
-
case 0xC0:
- /* Run of empty pixels */
+ // Run of empty pixels
search_ptr++;
continue;
break;
-
case 0x80:
- /* Run of compressed data */
- search_ptr += 2; /* Skip data byte */
+ // Run of compressed data
+ search_ptr += 2; // Skip data byte
continue;
break;
-
case 0x40:
- /* Uncompressed run */
+ // Uncompressed run
search_ptr++;
runcount = (mark_byte & 0x3f) + 1;
search_ptr += runcount;
continue;
break;
-
default:
- /* Encountered unknown RLE marker, abort */
+ // Encountered unknown RLE marker, abort
return R_FAILURE;
break;
-
- } /* end switch ( test_byte ) */
-
- } while (mark_byte != 63); /* end of frame marker */
-
- } /* end for( i = 0 ; i < find_frame ; i ++ ) */
+ }
+ } while (mark_byte != 63);
+ }
*frame_offset_p = (search_ptr - resdata);
-
return R_SUCCESS;
}
-static void CF_anim_info(int argc, char *argv[])
-{
+static void CF_anim_info(int argc, char *argv[]) {
uint16 anim_ct;
uint16 i;
uint16 idx;
@@ -1175,15 +909,11 @@ static void CF_anim_info(int argc, char *argv[])
CON_Print("There are %d animations loaded:", anim_ct);
for (idx = 0, i = 0; i < anim_ct; idx++, i++) {
-
while (AnimInfo.anim_tbl[idx] == NULL) {
idx++;
}
- CON_Print("%02d: Frames: %u Flags: %u",
- i,
- AnimInfo.anim_tbl[idx]->n_frames,
- AnimInfo.anim_tbl[idx]->flags);
+ CON_Print("%02d: Frames: %u Flags: %u", i, AnimInfo.anim_tbl[idx]->n_frames, AnimInfo.anim_tbl[idx]->flags);
}
return;
diff --git a/saga/animation.h b/saga/animation.h
index b4e5db5177..cd775765db 100644
--- a/saga/animation.h
+++ b/saga/animation.h
@@ -20,13 +20,8 @@
* $Header$
*
*/
-/*
- Description:
-
- Background animation management module private header
- Notes:
-*/
+// Background animation management module private header
#ifndef SAGA_ANIMATION_H_
#define SAGA_ANIMATION_H_
@@ -39,12 +34,10 @@ namespace Saga {
#define SAGA_FRAME_HEADER_MAGIC 15
#define SAGA_FRAME_HEADER_LEN 12
-/* All animation resources begin with an ANIMATION_HEADER
- * at 0x00, followed by a RLE code stream
-\*--------------------------------------------------------------------------*/
+// All animation resources begin with an ANIMATION_HEADER
+// at 0x00, followed by a RLE code stream
struct R_ANIMATION_HEADER {
-
uint16 magic;
uint16 screen_w;
@@ -61,12 +54,7 @@ struct R_ANIMATION_HEADER {
};
-/* A byte from the code stream of FRAME_HEADER_MAGIC signifies that a
- * FRAME_HEADER structure follows
-\*--------------------------------------------------------------------------*/
-
struct R_FRAME_HEADER {
-
int x_start;
int y_start;
@@ -75,10 +63,9 @@ struct R_FRAME_HEADER {
int width;
int height;
-
};
-/* Animation info array member */
+// Animation info array member
struct R_ANIMATION {
const byte *resdata;
@@ -86,51 +73,31 @@ struct R_ANIMATION {
uint16 n_frames;
size_t *frame_offsets;
-
uint16 current_frame;
uint16 end_frame;
uint16 stop_frame;
-
const byte *cur_frame_p;
size_t cur_frame_len;
-
int frame_time;
uint16 play_flag;
int link_flag;
uint16 link_id;
-
uint16 flags;
-
};
struct R_ANIMINFO {
-
int initialized;
-
uint16 anim_count;
uint16 anim_limit;
-
R_ANIMATION *anim_tbl[R_MAX_ANIMATIONS];
-
};
-int ANIM_GetNumFrames(const byte * anim_resource, uint16 * n_frames);
-
-int
-ITE_DecodeFrame(const byte * anim_resource,
- size_t frame_offset, byte * buf, size_t buf_len);
-
-int
-IHNM_DecodeFrame(byte * decode_buf,
- size_t decode_buf_len,
- const byte * thisf_p,
- size_t thisf_len, const byte ** nextf_p, size_t * nextf_len);
-
-int
-ANIM_GetFrameOffset(const byte * anim_resource,
- uint16 find_frame, size_t * frame_offset);
-
+int ANIM_GetNumFrames(const byte *anim_resource, uint16 *n_frames);
+int ITE_DecodeFrame(const byte * anim_resource, size_t frame_offset, byte * buf, size_t buf_len);
+int IHNM_DecodeFrame(byte * decode_buf, size_t decode_buf_len, const byte * thisf_p,
+ size_t thisf_len, const byte ** nextf_p, size_t * nextf_len);
+int ANIM_GetFrameOffset(const byte * anim_resource, uint16 find_frame, size_t * frame_offset);
static void CF_anim_info(int argc, char *argv[]);
} // End of namespace Saga
diff --git a/saga/animation_mod.h b/saga/animation_mod.h
index 3afda9ed5f..b73b1ed556 100644
--- a/saga/animation_mod.h
+++ b/saga/animation_mod.h
@@ -20,13 +20,8 @@
* $Header$
*
*/
-/*
- Description:
-
- Background animation management module public header
- Notes:
-*/
+// Background animation management module public header
#ifndef SAGA_ANIMATION_MOD_H__
#define SAGA_ANIMATION_MOD_H__
@@ -34,34 +29,21 @@
namespace Saga {
enum ANIM_FLAGS {
-
ANIM_LOOP = 0x01,
- ANIM_ENDSCENE = 0x80 /* When animation ends, dispatch scene end event */
+ ANIM_ENDSCENE = 0x80 // When animation ends, dispatch scene end event
};
int ANIM_Register(void);
-
int ANIM_Init(void);
-
int ANIM_Shutdown(void);
-
-int
-ANIM_Load(const byte * anim_resdata,
- size_t anim_resdata_len, uint16 * anim_id_p);
-
+int ANIM_Load(const byte *anim_resdata, size_t anim_resdata_len, uint16 *anim_id_p);
int ANIM_Free(uint16 anim_id);
-
int ANIM_Play(uint16 anim_id, int vector_time);
-
int ANIM_Link(uint16 anim_id1, uint16 anim_id2);
-
int ANIM_SetFlag(uint16 anim_id, uint16 flag);
-
int ANIM_SetFrameTime(uint16 anim_id, int time);
-
int ANIM_Reset(void);
} // End of namespace Saga
-#endif /* R_ANIMATION_MOD_H__ */
-/* end "r_animation_mod.h__ */
+#endif