[Scummvm-cvs-logs] CVS: scummvm/saga scene_mod.h,1.4,1.5 sceneproc.cpp,1.4,1.5 sceneproc.h,1.1,1.2 script.cpp,1.3,1.4 script.h,1.3,1.4 script_mod.h,1.2,1.3

Pawel Kolodziejski aquadran at users.sourceforge.net
Sat May 1 07:06:01 CEST 2004


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13836

Modified Files:
	scene_mod.h sceneproc.cpp sceneproc.h script.cpp script.h 
	script_mod.h 
Log Message:
indent


Index: sceneproc.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sceneproc.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- sceneproc.cpp	29 Apr 2004 03:52:59 -0000	1.4
+++ sceneproc.cpp	1 May 2004 14:05:10 -0000	1.5
@@ -20,22 +20,14 @@
  * $Header$
  *
  */
-/*
- Description:   
- 
-    Initial and default scene procedures
 
- Notes: 
-*/
+// Initial and default scene procedures
 
 #include "saga.h"
 #include "reinherit.h"
 
 #include "yslib.h"
 
-/*
- * Uses the following modules:
-\*--------------------------------------------------------------------------*/
 #include "animation_mod.h"
 #include "events_mod.h"
 #include "scene_mod.h"
@@ -43,35 +35,26 @@
 #include "sound.h"
 #include "music.h"
 
-/*
- * Begin module
-\*--------------------------------------------------------------------------*/
 #include "scene.h"
 #include "sceneproc.h"
 
 namespace Saga {
 
-int InitialSceneProc(int param, R_SCENE_INFO * scene_info)
-{
+int InitialSceneProc(int param, R_SCENE_INFO *scene_info) {
 	R_EVENT event;
 	R_EVENT *q_event;
-
 	int delay_time = 0;
-
 	static PALENTRY current_pal[R_PAL_ENTRIES];
 	PALENTRY *pal;
 
 	YS_IGNORE_PARAM(scene_info);
 
 	switch (param) {
-
 	case SCENE_BEGIN:
-
 		_vm->_music->stop();
 		_vm->_sound->stopVoice();
 
-		/* Fade palette to black from intro scene
-		 * \*----------------------------------------------------- */
+		// Fade palette to black from intro scene
 		SYSGFX_GetCurrentPal(current_pal);
 
 		event.type = R_CONTINUOUS_EVENT;
@@ -85,8 +68,7 @@
 
 		q_event = EVENT_Queue(&event);
 
-		/* Activate user interface
-		 * \*----------------------------------------------------- */
+		// Activate user interface
 		event.type = R_ONESHOT_EVENT;
 		event.code = R_INTERFACE_EVENT;
 		event.op = EVENT_ACTIVATE;
@@ -94,8 +76,7 @@
 
 		q_event = EVENT_Chain(q_event, &event);
 
-		/* Set first scene background w/o changing palette
-		 * \*----------------------------------------------------- */
+		// Set first scene background w/o changing palette
 		event.type = R_ONESHOT_EVENT;
 		event.code = R_BG_EVENT;
 		event.op = EVENT_DISPLAY;
@@ -104,8 +85,7 @@
 
 		q_event = EVENT_Chain(q_event, &event);
 
-		/* Fade in to first scene background palette
-		 * \*----------------------------------------------------- */
+		// Fade in to first scene background palette
 		SCENE_GetBGPal(&pal);
 
 		event.type = R_CONTINUOUS_EVENT;
@@ -125,35 +105,25 @@
 
 		ANIM_SetFlag(0, ANIM_LOOP);
 		ANIM_Play(0, delay_time);
-
 		break;
-
 	case SCENE_END:
-
 		break;
-
 	default:
 		R_printf(R_STDERR, "Illegal scene procedure parameter.\n");
 		break;
-
 	}
 
 	return 0;
 }
 
-int DefaultSceneProc(int param, R_SCENE_INFO * scene_info)
-{
-
+int DefaultSceneProc(int param, R_SCENE_INFO *scene_info) {
 	R_EVENT event;
 
 	YS_IGNORE_PARAM(scene_info);
 
 	switch (param) {
-
 	case SCENE_BEGIN:
-
-		/* Set scene background
-		 * \*----------------------------------------------------- */
+		// Set scene background
 		event.type = R_ONESHOT_EVENT;
 		event.code = R_BG_EVENT;
 		event.op = EVENT_DISPLAY;
@@ -162,8 +132,7 @@
 
 		EVENT_Queue(&event);
 
-		/* Activate user interface
-		 * \*----------------------------------------------------- */
+		// Activate user interface
 		event.type = R_ONESHOT_EVENT;
 		event.code = R_INTERFACE_EVENT;
 		event.op = EVENT_ACTIVATE;
@@ -171,25 +140,19 @@
 
 		EVENT_Queue(&event);
 
-		/* Begin palette cycle animation if present
-		 * \*----------------------------------------------------- */
+		// Begin palette cycle animation if present
 		event.type = R_ONESHOT_EVENT;
 		event.code = R_PALANIM_EVENT;
 		event.op = EVENT_CYCLESTART;
 		event.time = 0;
 
 		EVENT_Queue(&event);
-
 		break;
-
 	case SCENE_END:
-
 		break;
-
 	default:
 		R_printf(R_STDERR, "Illegal scene procedure parameter.\n");
 		break;
-
 	}
 
 	return 0;

Index: sceneproc.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sceneproc.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- sceneproc.h	12 Apr 2004 21:40:47 -0000	1.1
+++ sceneproc.h	1 May 2004 14:05:10 -0000	1.2
@@ -20,13 +20,8 @@
  * $Header$
  *
  */
-/*
- Description:	
- 
-	Initial and default scene procedures header file
 
- Notes: 
-*/
+// Initial and default scene procedures header file
 
 #ifndef SAGA_SCENEPROC_H
 #define SAGA_SCENEPROC_H

Index: script.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/script.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- script.cpp	30 Apr 2004 23:02:23 -0000	1.3
+++ script.cpp	1 May 2004 14:05:10 -0000	1.4
@@ -20,31 +20,19 @@
  * $Header$
  *
  */
-/*
-
- Description:   
- 
-    Scripting module: Script resource handling functions
 
- Notes: 
-*/
+// Scripting module: Script resource handling functions
 
 #include "reinherit.h"
 
 #include "yslib.h"
 
-/*
- * Uses the following modules:
-\*--------------------------------------------------------------------------*/
 #include "rscfile_mod.h"
 #include "game_mod.h"
 #include "text_mod.h"
 #include "console_mod.h"
 #include "cvar_mod.h"
 
-/*
- * Begin module component
-\*--------------------------------------------------------------------------*/
 #include "script_mod.h"
 #include "script.h"
 #include "sstack.h"
@@ -54,132 +42,88 @@
 
 R_SCRIPT_MODULE ScriptModule;
 
-int SCRIPT_Register(void)
-{
-
-	CVAR_RegisterFunc(CF_script_info,
-	    "script_info", NULL, R_CVAR_NONE, 0, 0);
-
-	CVAR_RegisterFunc(CF_script_exec,
-	    "script_exec", "<Script number>", R_CVAR_NONE, 1, 1);
-
-	CVAR_RegisterFunc(CF_script_togglestep,
-	    "script_togglestep", NULL, R_CVAR_NONE, 0, 0);
+int SCRIPT_Register() {
+	CVAR_RegisterFunc(CF_script_info, "script_info", NULL, R_CVAR_NONE, 0, 0);
+	CVAR_RegisterFunc(CF_script_exec, "script_exec", "<Script number>", R_CVAR_NONE, 1, 1);
+	CVAR_RegisterFunc(CF_script_togglestep, "script_togglestep", NULL, R_CVAR_NONE, 0, 0);
 
 	return R_SUCCESS;
 }
 
-int SCRIPT_Init(void)
-/*--------------------------------------------------------------------------*\
- * Initializes the scripting module.
- * Loads script resource look-up table, initializes script data system
-\*--------------------------------------------------------------------------*/
-{
+// Initializes the scripting module.
+// Loads script resource look-up table, initializes script data system
+int SCRIPT_Init() {
 	R_RSCFILE_CONTEXT *s_lut_ctxt;
-
 	byte *rsc_ptr;
 	size_t rsc_len;
-
 	const byte *read_ptr;
 	const byte *read_ptr2;
-
 	int result;
 	int i;
 
 	R_printf(R_STDOUT, "Initializing scripting subsystem.\n");
-
-	/* Load script resource file context
-	 * \*---------------------------------------------------------------------- */
-	result = GAME_GetFileContext(&ScriptModule.script_ctxt,
-	    R_GAME_SCRIPTFILE, 0);
+	// Load script resource file context
+	result = GAME_GetFileContext(&ScriptModule.script_ctxt, R_GAME_SCRIPTFILE, 0);
 	if (result != R_SUCCESS) {
-
 		R_printf(R_STDERR, "Couldn't get script file context.\n");
-
 		return R_FAILURE;
 	}
 
-	/* Load script LUT resource
-	 * \*---------------------------------------------------------------------- */
+	// Load script LUT resource
 	result = GAME_GetFileContext(&s_lut_ctxt, R_GAME_RESOURCEFILE, 0);
 	if (result != R_SUCCESS) {
-
 		R_printf(R_STDERR, "Couldn't get resource file context.\n");
-
 		return R_FAILURE;
 	}
 
-	result = RSC_LoadResource(s_lut_ctxt,
-	    ITE_SCRIPT_LUT, &rsc_ptr, &rsc_len);
+	result = RSC_LoadResource(s_lut_ctxt, ITE_SCRIPT_LUT, &rsc_ptr, &rsc_len);
 	if (result != R_SUCCESS) {
-
-		R_printf(R_STDERR,
-		    "Error: Couldn't load script resource look-up table.\n");
-
+		R_printf(R_STDERR, "Error: Couldn't load script resource look-up table.\n");
 		return R_FAILURE;
 	}
 
-	/* Create logical script LUT from resource
-	 * \*---------------------------------------------------------------------- */
+	// Create logical script LUT from resource
 	if (rsc_len % R_S_LUT_ENTRYLEN_ITECD == 0) {
-
 		ScriptModule.script_lut_entrylen = R_S_LUT_ENTRYLEN_ITECD;
 	} else if (rsc_len % R_S_LUT_ENTRYLEN_ITEDISK == 0) {
-
 		ScriptModule.script_lut_entrylen = R_S_LUT_ENTRYLEN_ITEDISK;
 	} else {
-		R_printf(R_STDERR,
-		    "Error: Invalid script lookup table length.\n");
+		R_printf(R_STDERR, "Error: Invalid script lookup table length.\n");
 		return R_FAILURE;
 	}
 
-	/* Calculate number of entries */
-	ScriptModule.script_lut_max =
-	    rsc_len / ScriptModule.script_lut_entrylen;
+	// Calculate number of entries
+	ScriptModule.script_lut_max = rsc_len / ScriptModule.script_lut_entrylen;
 
-	/* Allocate space for logical LUT */
-	ScriptModule.script_lut = (R_SCRIPT_LUT_ENTRY *)malloc(ScriptModule.script_lut_max *
-	    sizeof(R_SCRIPT_LUT_ENTRY));
+	// Allocate space for logical LUT
+	ScriptModule.script_lut = (R_SCRIPT_LUT_ENTRY *)malloc(ScriptModule.script_lut_max * sizeof(R_SCRIPT_LUT_ENTRY));
 	if (ScriptModule.script_lut == NULL) {
-		R_printf(R_STDERR,
-		    "Error: Couldn't allocate memory for script resource "
-		    "look-up table.\n");
+		R_printf(R_STDERR, "Error: Couldn't allocate memory for script resource look-up table.\n");
 		return R_MEM;
 	}
 
-	/* Convert LUT resource to logical LUT */
+	// Convert LUT resource to logical LUT
 	read_ptr = rsc_ptr;
 	for (i = 0; i < ScriptModule.script_lut_max; i++) {
-
 		read_ptr2 = read_ptr;
-
-		ScriptModule.script_lut[i].script_rn =
-		    ys_read_u16_le(read_ptr2, &read_ptr2);
-
-		ScriptModule.script_lut[i].diag_list_rn =
-		    ys_read_u16_le(read_ptr2, &read_ptr2);
-
-		ScriptModule.script_lut[i].voice_lut_rn =
-		    ys_read_u16_le(read_ptr2, &read_ptr2);
-
-		/* Skip the unused portion of the structure */
+		ScriptModule.script_lut[i].script_rn = ys_read_u16_le(read_ptr2, &read_ptr2);
+		ScriptModule.script_lut[i].diag_list_rn = ys_read_u16_le(read_ptr2, &read_ptr2);
+		ScriptModule.script_lut[i].voice_lut_rn = ys_read_u16_le(read_ptr2, &read_ptr2);
+		// Skip the unused portion of the structure
 		read_ptr += ScriptModule.script_lut_entrylen;
 	}
 
 	RSC_FreeResource(rsc_ptr);
 
-	/* Any voice lookup table resources present? */
+	// Any voice lookup table resources present?
 	for (i = 0; i < ScriptModule.script_lut_max; i++) {
-
 		if (ScriptModule.script_lut[i].voice_lut_rn) {
-
 			ScriptModule.voice_lut_present = 1;
 			break;
 		}
 	}
 
-	/* Initialize script submodules
-	 * \*---------------------------------------------------------------------- */
+	// Initialize script submodules
 	ScriptModule.thread_list = ys_dll_create();
 
 	if (SDATA_Init() != R_SUCCESS) {
@@ -191,31 +135,25 @@
 	return R_SUCCESS;
 }
 
-int SCRIPT_Shutdown(void)
-/*--------------------------------------------------------------------------*\
- * Shut down script module gracefully; free all allocated module resources
-\*--------------------------------------------------------------------------*/
-{
+// Shut down script module gracefully; free all allocated module resources
+int SCRIPT_Shutdown() {
 	YS_DL_NODE *thread_node;
 	R_SCRIPT_THREAD *thread;
 
 	if (!ScriptModule.initialized) {
-
 		return R_FAILURE;
 	}
 
 	R_printf(R_STDOUT, "Shutting down scripting subsystem.\n");
 
-	/* Free script lookup table */
+	// Free script lookup table
 	free(ScriptModule.script_lut);
 
-	/* Stop all threads and destroy them */
-
-	for (thread_node = ys_dll_head(ScriptModule.thread_list);
-	    thread_node != NULL; thread_node = ys_dll_next(thread_node)) {
+	// Stop all threads and destroy them
 
+	for (thread_node = ys_dll_head(ScriptModule.thread_list); thread_node != NULL;
+				thread_node = ys_dll_next(thread_node)) {
 		thread = (R_SCRIPT_THREAD *)ys_dll_get_data(thread_node);
-
 		STHREAD_Destroy(thread);
 	}
 
@@ -224,45 +162,35 @@
 	return R_SUCCESS;
 }
 
-int SCRIPT_Load(int script_num)
-/*--------------------------------------------------------------------------*\
- * Loads a script; including script bytecode and dialogue list 
-\*--------------------------------------------------------------------------*/
-{
-
+// Loads a script; including script bytecode and dialogue list 
+int SCRIPT_Load(int script_num) {
 	R_SCRIPTDATA *script_data;
-
 	byte *bytecode_p;
 	size_t bytecode_len;
 	uint32 scriptl_rn;
-
 	byte *diagl_p;
 	size_t diagl_len;
 	uint32 diagl_rn;
-
 	byte *voicelut_p;
 	size_t voicelut_len;
 	uint32 voicelut_rn;
-
 	int result;
 
 	if (GAME_GetGameType() == R_GAMETYPE_IHNM) {
 		return R_SUCCESS;
 	}
 
-	/* Validate script number */
+	// Validate script number
 	if ((script_num < 0) || (script_num > ScriptModule.script_lut_max)) {
 		R_printf(R_STDERR, "SCRIPT_Load(): Invalid script number!\n");
 		return R_FAILURE;
 	}
 
-	/* Release old script data if present */
+	// Release old script data if present
 	SCRIPT_Free();
 
-	/* Initialize script data structure
-	 * \*---------------------------------------------------------------------- */
-	R_printf(R_STDOUT, "Loading script data for script #%d.\n",
-	    script_num);
+	// Initialize script data structure
+	R_printf(R_STDOUT, "Loading script data for script #%d.\n", script_num);
 
 	script_data = (R_SCRIPTDATA *)malloc(sizeof *script_data);
 	if (script_data == NULL) {
@@ -272,20 +200,17 @@
 
 	script_data->loaded = 0;
 
-	/* Initialize script pointers */
+	// Initialize script pointers
 	script_data->diag = NULL;
 	script_data->bytecode = NULL;
 	script_data->voice = NULL;
 
-	/* Load script bytecode
-	 * \*---------------------------------------------------------------------- */
+	// Load script bytecode
 	scriptl_rn = ScriptModule.script_lut[script_num].script_rn;
 
-	result = RSC_LoadResource(ScriptModule.script_ctxt,
-	    scriptl_rn, &bytecode_p, &bytecode_len);
+	result = RSC_LoadResource(ScriptModule.script_ctxt, scriptl_rn, &bytecode_p, &bytecode_len);
 	if (result != R_SUCCESS) {
-		R_printf(R_STDERR,
-		    "Error loading script bytecode resource.\n");
+		R_printf(R_STDERR, "Error loading script bytecode resource.\n");
 		free(script_data);
 		return R_FAILURE;
 	}
@@ -293,20 +218,17 @@
 	script_data->bytecode = SCRIPT_LoadBytecode(bytecode_p, bytecode_len);
 
 	if (script_data->bytecode == NULL) {
-		R_printf(R_STDERR,
-		    "Error interpreting script bytecode resource.\n");
+		R_printf(R_STDERR, "Error interpreting script bytecode resource.\n");
 		free(script_data);
 		RSC_FreeResource(bytecode_p);
 		return R_FAILURE;
 	}
 
-	/* Load script dialogue list
-	 * \*---------------------------------------------------------------------- */
+	// Load script dialogue list
 	diagl_rn = ScriptModule.script_lut[script_num].diag_list_rn;
 
-	/* Load dialogue list resource */
-	result = RSC_LoadResource(ScriptModule.script_ctxt,
-	    diagl_rn, &diagl_p, &diagl_len);
+	// Load dialogue list resource
+	result = RSC_LoadResource(ScriptModule.script_ctxt, diagl_rn, &diagl_p, &diagl_len);
 	if (result != R_SUCCESS) {
 		R_printf(R_STDERR, "Error loading dialogue list resource.\n");
 		free(script_data);
@@ -314,69 +236,51 @@
 		return R_FAILURE;
 	}
 
-	/* Convert dialogue list resource to logical dialogue list */
+	// Convert dialogue list resource to logical dialogue list
 	script_data->diag = SCRIPT_LoadDialogue(diagl_p, diagl_len);
 	if (script_data->diag == NULL) {
-		R_printf(R_STDERR,
-		    "Error interpreting dialogue list resource.\n");
+		R_printf(R_STDERR, "Error interpreting dialogue list resource.\n");
 		free(script_data);
 		RSC_FreeResource(bytecode_p);
 		RSC_FreeResource(diagl_p);
 		return R_FAILURE;
 	}
 
-	/* Load voice resource lookup table
-	 * \*---------------------------------------------------------------------- */
+	// Load voice resource lookup table
 	if (ScriptModule.voice_lut_present) {
-
 		voicelut_rn = ScriptModule.script_lut[script_num].voice_lut_rn;
 
-		/* Load voice LUT resource */
-		result = RSC_LoadResource(ScriptModule.script_ctxt,
-		    voicelut_rn, &voicelut_p, &voicelut_len);
+		// Load voice LUT resource
+		result = RSC_LoadResource(ScriptModule.script_ctxt, voicelut_rn, &voicelut_p, &voicelut_len);
 		if (result != R_SUCCESS) {
-
-			R_printf(R_STDERR,
-			    "Error loading voice LUT resource.\n");
-
+			R_printf(R_STDERR, "Error loading voice LUT resource.\n");
 			free(script_data);
 			RSC_FreeResource(bytecode_p);
 			RSC_FreeResource(diagl_p);
-
 			return R_FAILURE;
 		}
 
-		/* Convert voice LUT resource to logical voice LUT */
-		script_data->voice = SCRIPT_LoadVoiceLUT(voicelut_p,
-		    voicelut_len, script_data);
+		// Convert voice LUT resource to logical voice LUT
+		script_data->voice = SCRIPT_LoadVoiceLUT(voicelut_p, voicelut_len, script_data);
 		if (script_data->voice == NULL) {
-			R_printf(R_STDERR,
-			    "Error interpreting voice LUT resource.\n");
-
+			R_printf(R_STDERR, "Error interpreting voice LUT resource.\n");
 			free(script_data);
 			RSC_FreeResource(bytecode_p);
 			RSC_FreeResource(diagl_p);
 			RSC_FreeResource(voicelut_p);
-
 			return R_FAILURE;
 		}
-
 	}
 
-	/* Finish initialization
-	 * \*---------------------------------------------------------------------- */
+	// Finish initialization
 	script_data->loaded = 1;
 	ScriptModule.current_script = script_data;
 
 	return R_SUCCESS;
 }
 
-int SCRIPT_Free(void)
-/*--------------------------------------------------------------------------*\
- * Frees all resources associated with current script.
-\*--------------------------------------------------------------------------*/
-{
-
+// Frees all resources associated with current script.
+int SCRIPT_Free() {
 	if (ScriptModule.current_script == NULL) {
 		return R_FAILURE;
 	}
@@ -387,8 +291,7 @@
 
 	R_printf(R_STDOUT, "Releasing script data.\n");
 
-	/* Finish initialization
-	 * \*---------------------------------------------------------------------- */
+	// Finish initialization
 	if (ScriptModule.current_script->diag != NULL) {
 		free(ScriptModule.current_script->diag->str);
 		free(ScriptModule.current_script->diag->str_off);
@@ -397,8 +300,7 @@
 
 	if (ScriptModule.current_script->bytecode != NULL) {
 		free(ScriptModule.current_script->bytecode->entrypoints);
-		RSC_FreeResource(ScriptModule.current_script->bytecode->
-		    bytecode_p);
+		RSC_FreeResource(ScriptModule.current_script->bytecode->bytecode_p);
 	}
 
 	free(ScriptModule.current_script->bytecode);
@@ -415,35 +317,27 @@
 	return R_SUCCESS;
 }
 
-R_SCRIPT_BYTECODE *SCRIPT_LoadBytecode(byte * bytecode_p,
-    size_t bytecode_len)
-/*--------------------------------------------------------------------------*\
- * Reads the entrypoint table from a script bytecode resource in memory. 
- * Returns NULL on failure.
-\*--------------------------------------------------------------------------*/
-{
-
+// Reads the entrypoint table from a script bytecode resource in memory. 
+// Returns NULL on failure.
+R_SCRIPT_BYTECODE *SCRIPT_LoadBytecode(byte *bytecode_p, size_t bytecode_len) {
 	const byte *read_p = bytecode_p;
 	R_PROC_TBLENTRY *bc_ep_tbl = NULL;
 	R_SCRIPT_BYTECODE *bc_new_data = NULL;
 
-	unsigned long n_entrypoints;	/* Number of entrypoints */
-	size_t ep_tbl_offset;	/* Offset of bytecode entrypoint table */
-
+	unsigned long n_entrypoints; // Number of entrypoints
+	size_t ep_tbl_offset; // Offset of bytecode entrypoint table
 	unsigned long i;
 
 	R_printf(R_STDOUT, "Loading script bytecode...\n");
 
-	/* The first two uint32 values are the number of entrypoints, and the
-	 * offset to the entrypoint table, respectively. */
+	// The first two uint32 values are the number of entrypoints, and the
+	// offset to the entrypoint table, respectively.
 
 	n_entrypoints = ys_read_u32_le(read_p, &read_p);
 	ep_tbl_offset = ys_read_u32_le(read_p, &read_p);
 
-	/* Check that the entrypoint table offset is valid. */
-	if ((bytecode_len - ep_tbl_offset) <
-	    (n_entrypoints * R_SCRIPT_TBLENTRY_LEN)) {
-
+	// Check that the entrypoint table offset is valid.
+	if ((bytecode_len - ep_tbl_offset) < (n_entrypoints * R_SCRIPT_TBLENTRY_LEN)) {
 		R_printf(R_STDERR, "Invalid table offset.\n");
 		return NULL;
 	}
@@ -453,41 +347,36 @@
 		return NULL;
 	}
 
-	/* Allocate a new bytecode resource information structure and table of
-	 * entrypoints */
+	// Allocate a new bytecode resource information structure and table of
+	// entrypoints
 
 	bc_new_data = (R_SCRIPT_BYTECODE *)malloc(sizeof *bc_new_data);
 	if (bc_new_data == NULL) {
-		R_printf(R_STDERR,
-		    "Memory allocation failure loading script bytecode.\n");
+		R_printf(R_STDERR, "Memory allocation failure loading script bytecode.\n");
 		return NULL;
 	}
 
 	bc_ep_tbl = (R_PROC_TBLENTRY *)malloc(n_entrypoints * sizeof *bc_ep_tbl);
 	if (bc_ep_tbl == NULL) {
-		R_printf(R_STDERR,
-		    "Memory allocation failure creating script entrypoint table.\n");
+		R_printf(R_STDERR, "Memory allocation failure creating script entrypoint table.\n");
 		free(bc_new_data);
 		return NULL;
 	}
 
-	/* Read in the entrypoint table */
+	// Read in the entrypoint table
 
 	read_p = bytecode_p + ep_tbl_offset;
 
 	for (i = 0; i < n_entrypoints; i++) {
-		/* First uint16 is the offset of the entrypoint name from the start
-		 * of the bytecode resource, second uint16 is the offset of the 
-		 * bytecode itself for said entrypoint */
+		// First uint16 is the offset of the entrypoint name from the start
+		// of the bytecode resource, second uint16 is the offset of the 
+		// bytecode itself for said entrypoint
 		bc_ep_tbl[i].name_offset = ys_read_u16_le(read_p, &read_p);
 		bc_ep_tbl[i].offset = ys_read_u16_le(read_p, &read_p);
 
-		/* Perform a simple range check on offset values */
-		if ((bc_ep_tbl[i].name_offset > bytecode_len) ||
-		    (bc_ep_tbl[i].offset > bytecode_len)) {
-
-			R_printf(R_STDERR,
-			    "Invalid offset encountered in script entrypoint table.\n");
+		// Perform a simple range check on offset values
+		if ((bc_ep_tbl[i].name_offset > bytecode_len) || (bc_ep_tbl[i].offset > bytecode_len)) {
+			R_printf(R_STDERR, "Invalid offset encountered in script entrypoint table.\n");
 			free(bc_new_data);
 			free(bc_ep_tbl);
 			return NULL;
@@ -504,48 +393,42 @@
 	return bc_new_data;
 }
 
-R_DIALOGUE_LIST *SCRIPT_LoadDialogue(const byte * dialogue_p,
-    size_t dialogue_len)
-/*--------------------------------------------------------------------------*\
- * Reads a logical dialogue list from a dialogue list resource in memory.
- * Returns NULL on failure.
-\*--------------------------------------------------------------------------*/
-{
+// Reads a logical dialogue list from a dialogue list resource in memory.
+// Returns NULL on failure.
+R_DIALOGUE_LIST *SCRIPT_LoadDialogue(const byte *dialogue_p, size_t dialogue_len) {
 	const byte *read_p = dialogue_p;
-
 	R_DIALOGUE_LIST *dialogue_list;
 	uint16 n_dialogue;
-
 	uint16 i;
 	size_t offset;
 
 	R_printf(R_STDOUT, "Loading dialogue list...\n");
 
-	/* Allocate dialogue list structure */
+	// Allocate dialogue list structure
 	dialogue_list = (R_DIALOGUE_LIST *)malloc(sizeof *dialogue_list);
 	if (dialogue_list == NULL) {
 		return NULL;
 	}
 
-	/* First uint16 is the offset of the first string */
+	// First uint16 is the offset of the first string
 	offset = ys_read_u16_le(read_p, &read_p);
 	if (offset > dialogue_len) {
 		R_printf(R_STDERR, "Error, invalid string offset.\n");
 		return NULL;
 	}
 
-	/* Calculate table length */
+	// Calculate table length
 	n_dialogue = offset / 2;
 	dialogue_list->n_dialogue = n_dialogue;
 
-	/* Allocate table of string pointers */
+	// Allocate table of string pointers
 	dialogue_list->str = (const char **)malloc(n_dialogue * sizeof(const char *));
 	if (dialogue_list->str == NULL) {
 		free(dialogue_list);
 		return NULL;
 	}
 
-	/* Allocate table of string offsets */
+	// Allocate table of string offsets
 	dialogue_list->str_off = (size_t *)malloc(n_dialogue * sizeof(size_t));
 	if (dialogue_list->str_off == NULL) {
 		free(dialogue_list->str);
@@ -553,11 +436,10 @@
 		return NULL;
 	}
 
-	/* Read in tables from dialogue list resource */
+	// Read in tables from dialogue list resource
 	read_p = dialogue_p;
 	for (i = 0; i < n_dialogue; i++) {
 		offset = ys_read_u16_le(read_p, &read_p);
-
 		if (offset > dialogue_len) {
 			R_printf(R_STDERR, "Error, invalid string offset.\n");
 			free(dialogue_list->str);
@@ -572,13 +454,9 @@
 	return dialogue_list;
 }
 
-R_VOICE_LUT *SCRIPT_LoadVoiceLUT(const byte * voicelut_p,
-    size_t voicelut_len, R_SCRIPTDATA * script)
-/*--------------------------------------------------------------------------*\
- * Reads a logical voice LUT from a voice LUT resource in memory.
- * Returns NULL on failure.
-\*--------------------------------------------------------------------------*/
-{
+// Reads a logical voice LUT from a voice LUT resource in memory.
+// Returns NULL on failure.
+R_VOICE_LUT *SCRIPT_LoadVoiceLUT(const byte *voicelut_p, size_t voicelut_len, R_SCRIPTDATA *script) {
 	const byte *read_p = voicelut_p;
 
 	R_VOICE_LUT *voice_lut;
@@ -593,8 +471,7 @@
 
 	n_voices = voicelut_len / 2;
 	if (n_voices != script->diag->n_dialogue) {
-		R_printf(R_STDERR, "Error: Voice LUT entries do not match "
-		    "dialogue entries.\n");
+		R_printf(R_STDERR, "Error: Voice LUT entries do not match dialogue entries.\n");
 		return NULL;
 	}
 
@@ -612,9 +489,7 @@
 	return voice_lut;
 }
 
-void CF_script_info(int argc, char *argv[])
-{
-
+void CF_script_info(int argc, char *argv[]) {
 	uint32 n_entrypoints;
 	uint32 i;
 	char *name_ptr;
@@ -632,19 +507,13 @@
 	CON_Print("Current script contains %d entrypoints:", n_entrypoints);
 
 	for (i = 0; i < n_entrypoints; i++) {
-		name_ptr = (char *)
-		    ScriptModule.current_script->bytecode->bytecode_p +
-		    ScriptModule.current_script->bytecode->entrypoints[i].
-		    name_offset;
-
+		name_ptr = (char *)ScriptModule.current_script->bytecode->bytecode_p +
+							ScriptModule.current_script->bytecode->entrypoints[i].name_offset;
 		CON_Print("%lu: %s", i, name_ptr);
 	}
-
-	return;
 }
 
-void CF_script_exec(int argc, char *argv[])
-{
+void CF_script_exec(int argc, char *argv[]) {
 	uint16 ep_num;
 
 	if (argc < 1) {
@@ -654,10 +523,8 @@
 	ep_num = atoi(argv[0]);
 
 	if (ScriptModule.dbg_thread == NULL) {
-
 		CON_Print("Creating debug thread...");
 		ScriptModule.dbg_thread = STHREAD_Create();
-
 		if (ScriptModule.dbg_thread == NULL) {
 			CON_Print("Thread creation failed.");
 			return;
@@ -670,15 +537,10 @@
 	}
 
 	STHREAD_Execute(ScriptModule.dbg_thread, ep_num);
-
-	return;
 }
 
-void CF_script_togglestep(int argc, char *argv[])
-{
+void CF_script_togglestep(int argc, char *argv[]) {
 	ScriptModule.dbg_singlestep = !ScriptModule.dbg_singlestep;
-
-	return;
 }
 
 } // End of namespace Saga

Index: script.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/script.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- script.h	30 Apr 2004 23:02:23 -0000	1.3
+++ script.h	1 May 2004 14:05:10 -0000	1.4
@@ -20,14 +20,8 @@
  * $Header$
  *
  */
-/*
-
- Description:   
- 
-    Scripting module private header
 
- Notes: 
-*/
+// Scripting module private header
 
 #ifndef SAGA_SCRIPT_H
 #define SAGA_SCRIPT_H
@@ -53,103 +47,71 @@
 #define S_WARN_PREFIX "SWarning: "
 
 struct R_PROC_TBLENTRY {
-
 	size_t name_offset;
 	size_t offset;
-
 };
 
 struct R_SCRIPT_BYTECODE {
-
 	unsigned char *bytecode_p;
 	size_t bytecode_len;
-
 	size_t ep_tbl_offset;
 	unsigned long n_entrypoints;
 	R_PROC_TBLENTRY *entrypoints;
-
 };
 
 struct R_DIALOGUE_LIST {
-
 	unsigned int n_dialogue;
 	const char **str;
 	size_t *str_off;
-
 };
 
 struct R_VOICE_LUT {
-
 	int n_voices;
 	int *voices;
-
 };
 
 struct R_SCRIPTDATA {
-
 	int loaded;
 	R_SCRIPT_BYTECODE *bytecode;
 	R_DIALOGUE_LIST *diag;
 	R_VOICE_LUT *voice;
-
 };
 
 struct R_SCRIPT_LUT_ENTRY {
-
 	int script_rn;
 	int diag_list_rn;
 	int voice_lut_rn;
-
 };
 
 struct R_SCRIPT_DATABUF {
-
 	SDataWord_T *data;
 	int len;
-
 };
 
 struct R_SCRIPT_MODULE {
-
 	int initialized;
-
 	R_RSCFILE_CONTEXT *script_ctxt;
-
 	int voice_lut_present;
 	R_SCRIPT_LUT_ENTRY *script_lut;
 	int script_lut_max;
 	uint16 script_lut_entrylen;
-
 	R_SCRIPTDATA *current_script;
 	YS_DL_LIST *thread_list;
 	R_SCRIPT_DATABUF *data_buf[R_SCRIPT_DATABUF_NUM];
-
 	int dbg_singlestep;
 	int dbg_dostep;
 	R_SCRIPT_THREAD *dbg_thread;
 	R_TEXTLIST_ENTRY *dbg_txtentry;
-
 };
 
 extern R_SCRIPT_MODULE ScriptModule;
 
-R_SCRIPT_BYTECODE *SCRIPT_LoadBytecode(byte * bytecode_p,
-    size_t bytecode_len);
-
-R_DIALOGUE_LIST *SCRIPT_LoadDialogue(const byte * dialogue_p,
-    size_t dialogue_len);
-
-R_VOICE_LUT *SCRIPT_LoadVoiceLUT(const byte * voicelut_p,
-    size_t voicelut_len, R_SCRIPTDATA * script);
-
-int
-SCRIPT_Disassemble(R_SCRIPT_BYTECODE * script_list,
-    R_DIALOGUE_LIST * diag_list);
-
+R_SCRIPT_BYTECODE *SCRIPT_LoadBytecode(byte *bytecode_p, size_t bytecode_len);
+R_DIALOGUE_LIST *SCRIPT_LoadDialogue(const byte *dialogue_p, size_t dialogue_len);
+R_VOICE_LUT *SCRIPT_LoadVoiceLUT(const byte *voicelut_p, size_t voicelut_len, R_SCRIPTDATA *script);
+int SCRIPT_Disassemble(R_SCRIPT_BYTECODE *script_list, R_DIALOGUE_LIST *diag_list);
 void CF_script_info(int argc, char *argv[]);
-
 void CF_script_exec(int argc, char *argv[]);
-
 void CF_script_togglestep(int argc, char *argv[]);
 
 } // End of namespace Saga

Index: script_mod.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/script_mod.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- script_mod.h	30 Apr 2004 23:02:23 -0000	1.2
+++ script_mod.h	1 May 2004 14:05:10 -0000	1.3
@@ -20,14 +20,8 @@
  * $Header$
  *
  */
-/*
-
- Description:   
- 
-    Scripting module public header
 
- Notes: 
-*/
+// Scripting module public header
 
 #ifndef SAGA_SCRIPT_MOD_H
 #define SAGA_SCRIPT_MOD_H
@@ -39,7 +33,6 @@
 typedef struct R_SCRIPT_THREAD_tag R_SCRIPT_THREAD;
 
 enum R_SCRIPT_VERBS {
-
 	S_VERB_WALKTO = 0,
 	S_VERB_LOOKAT = 2,
 	S_VERB_PICKUP = 1,
@@ -50,40 +43,24 @@
 	S_VERB_GIVE
 };
 
-int SCRIPT_Register(void);
-
-int SCRIPT_Init(void);
-
-int SCRIPT_Shutdown(void);
-
+int SCRIPT_Register();
+int SCRIPT_Init();
+int SCRIPT_Shutdown();
 int SCRIPT_Load(int script_num);
-
-int SCRIPT_Free(void);
-
-int SDATA_GetWord(int n_buf, int n_word, SDataWord_T * data);
-
+int SCRIPT_Free();
+int SDATA_GetWord(int n_buf, int n_word, SDataWord_T *data);
 int SDATA_PutWord(int n_buf, int n_word, SDataWord_T data);
-
 int SDATA_SetBit(int n_buf, SDataWord_T n_bit, int bitstate);
-
 int SDATA_GetBit(int n_buf, SDataWord_T n_bit, int *bitstate);
-
 int SDATA_ReadWordS(SDataWord_T word);
-
 uint16 SDATA_ReadWordU(SDataWord_T word);
-
-R_SCRIPT_THREAD *STHREAD_Create(void);
-
-int STHREAD_Execute(R_SCRIPT_THREAD * thread, int ep_num);
-
+R_SCRIPT_THREAD *STHREAD_Create();
+int STHREAD_Execute(R_SCRIPT_THREAD *thread, int ep_num);
 int STHREAD_ExecThreads(int msec);
-
-int STHREAD_HoldSem(R_SEMAPHORE * sem);
-
-int STHREAD_ReleaseSem(R_SEMAPHORE * sem);
-
-int STHREAD_DebugStep(void);
+int STHREAD_HoldSem(R_SEMAPHORE *sem);
+int STHREAD_ReleaseSem(R_SEMAPHORE *sem);
+int STHREAD_DebugStep();
 
 } // End of namespace Saga
 
-#endif				/* SAGA_SCRIPT_MOD_H */
+#endif





More information about the Scummvm-git-logs mailing list