aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Kołodziejski2004-05-01 14:34:00 +0000
committerPaweł Kołodziejski2004-05-01 14:34:00 +0000
commit3ad363a274ac767e5831bc0c69b8b89271aad3c7 (patch)
tree7c7d0ea406df1c08972a1121d784cfefe9ede7f9
parente04312c0a56a875304dffec1a64b3fb40527e40d (diff)
downloadscummvm-rg350-3ad363a274ac767e5831bc0c69b8b89271aad3c7.tar.gz
scummvm-rg350-3ad363a274ac767e5831bc0c69b8b89271aad3c7.tar.bz2
scummvm-rg350-3ad363a274ac767e5831bc0c69b8b89271aad3c7.zip
indent
svn-id: r13713
-rw-r--r--saga/sdata.cpp67
-rw-r--r--saga/sdata.h12
-rw-r--r--saga/sdebug.cpp252
-rw-r--r--saga/sfuncs.cpp652
-rw-r--r--saga/sfuncs.h59
5 files changed, 281 insertions, 761 deletions
diff --git a/saga/sdata.cpp b/saga/sdata.cpp
index bb7f69e772..0994d4d7aa 100644
--- a/saga/sdata.cpp
+++ b/saga/sdata.cpp
@@ -20,16 +20,7 @@
* $Header$
*
*/
-/*
-
- Description:
-
- Scripting module data management component
-
- Notes:
-
- Type SDataWord_T must be unpadded
-*/
+// Type SDataWord_T must be unpadded
#include "reinherit.h"
@@ -37,47 +28,31 @@
#include <limits.h>
-/*
- * Uses the following modules:
-\*--------------------------------------------------------------------------*/
#include "text_mod.h"
-/*
- * Begin module component
-\*--------------------------------------------------------------------------*/
#include "script_mod.h"
#include "script.h"
#include "sdata.h"
namespace Saga {
-int SDATA_Init(void)
-{
-
+int SDATA_Init() {
unsigned int i;
void *alloc_ptr;
R_printf(R_STDOUT, "Initializing script data buffers.\n");
-
for (i = 0; i < R_SCRIPT_DATABUF_NUM; i++) {
-
alloc_ptr = malloc(sizeof *ScriptModule.data_buf[0]);
-
if (alloc_ptr == NULL) {
- R_printf(R_STDERR,
- "Error allocating memory for script data buffer %d.\n",
- i);
+ R_printf(R_STDERR, "Error allocating memory for script data buffer %d.\n", i);
return R_MEM;
}
ScriptModule.data_buf[i] = (R_SCRIPT_DATABUF *)alloc_ptr;
-
alloc_ptr = calloc(R_SCRIPT_DATABUF_LEN, sizeof(SDataWord_T));
if (alloc_ptr == NULL) {
- R_printf(R_STDERR,
- "Error allocating memory for script data buffer %d.\n",
- i);
+ R_printf(R_STDERR, "Error allocating memory for script data buffer %d.\n", i);
return R_MEM;
}
@@ -88,9 +63,7 @@ int SDATA_Init(void)
return R_SUCCESS;
}
-int SDATA_GetWord(int n_buf, int n_word, SDataWord_T * data)
-{
-
+int SDATA_GetWord(int n_buf, int n_word, SDataWord_T * data) {
if ((n_buf < 0) || (n_buf >= R_SCRIPT_DATABUF_NUM)) {
return R_FAILURE;
}
@@ -108,9 +81,7 @@ int SDATA_GetWord(int n_buf, int n_word, SDataWord_T * data)
return R_SUCCESS;
}
-int SDATA_PutWord(int n_buf, int n_word, SDataWord_T data)
-{
-
+int SDATA_PutWord(int n_buf, int n_word, SDataWord_T data) {
if ((n_buf < 0) || (n_buf >= R_SCRIPT_DATABUF_NUM)) {
return R_FAILURE;
}
@@ -124,9 +95,7 @@ int SDATA_PutWord(int n_buf, int n_word, SDataWord_T data)
return R_SUCCESS;
}
-int SDATA_SetBit(int n_buf, SDataWord_T n_bit, int bitstate)
-{
-
+int SDATA_SetBit(int n_buf, SDataWord_T n_bit, int bitstate) {
int n_word;
int n_bitpos;
@@ -136,9 +105,7 @@ int SDATA_SetBit(int n_buf, SDataWord_T n_bit, int bitstate)
return R_FAILURE;
}
- if (n_bit >= (unsigned long)ScriptModule.data_buf[n_buf]->len *
- (sizeof(SDataWord_T) * CHAR_BIT)) {
-
+ if (n_bit >= (unsigned long)ScriptModule.data_buf[n_buf]->len * (sizeof(SDataWord_T) * CHAR_BIT)) {
return R_FAILURE;
}
@@ -156,22 +123,17 @@ int SDATA_SetBit(int n_buf, SDataWord_T n_bit, int bitstate)
return R_SUCCESS;
}
-int SDATA_GetBit(int n_buf, SDataWord_T n_bit, int *bitstate)
-{
-
+int SDATA_GetBit(int n_buf, SDataWord_T n_bit, int *bitstate) {
int n_word;
int n_bitpos;
SDataWord_T bit_pattern = 0x01;
if ((n_buf < 0) || (n_buf >= R_SCRIPT_DATABUF_NUM)) {
-
return R_FAILURE;
}
- if (n_bit >= (SDataWord_T) ScriptModule.data_buf[n_buf]->len *
- (sizeof(SDataWord_T) * CHAR_BIT)) {
-
+ if (n_bit >= (SDataWord_T) ScriptModule.data_buf[n_buf]->len * (sizeof(SDataWord_T) * CHAR_BIT)) {
return R_FAILURE;
}
@@ -180,14 +142,12 @@ int SDATA_GetBit(int n_buf, SDataWord_T n_bit, int *bitstate)
bit_pattern <<= ((sizeof(SDataWord_T) * CHAR_BIT) - (n_bitpos + 1));
- *bitstate = (ScriptModule.data_buf[n_buf]->data[n_word] &
- bit_pattern) ? 1 : 0;
+ *bitstate = (ScriptModule.data_buf[n_buf]->data[n_word] & bit_pattern) ? 1 : 0;
return R_SUCCESS;
}
-int SDATA_ReadWordS(SDataWord_T word)
-{
+int SDATA_ReadWordS(SDataWord_T word) {
uint16 u_int = word;
int s_int;
@@ -200,8 +160,7 @@ int SDATA_ReadWordS(SDataWord_T word)
return s_int;
}
-uint16 SDATA_ReadWordU(SDataWord_T word)
-{
+uint16 SDATA_ReadWordU(SDataWord_T word) {
uint16 u_int = (uint16) word;
return u_int;
diff --git a/saga/sdata.h b/saga/sdata.h
index 1b6f81d944..a8a8470d3c 100644
--- a/saga/sdata.h
+++ b/saga/sdata.h
@@ -20,14 +20,8 @@
* $Header$
*
*/
-/*
- Description:
-
- Scripting module data management component header file
-
- Notes:
-*/
+// Scripting module data management component header file
#ifndef SAGA_SDATA_H
#define SAGA_SDATA_H
@@ -37,8 +31,8 @@ namespace Saga {
#define R_SCRIPT_DATABUF_NUM 5
#define R_SCRIPT_DATABUF_LEN 1024
-int SDATA_Init(void);
+int SDATA_Init();
} // End of namespace Saga
-#endif /* SAGA_SDATA_H */
+#endif
diff --git a/saga/sdebug.cpp b/saga/sdebug.cpp
index b7e24d61c0..c51dd417b8 100644
--- a/saga/sdebug.cpp
+++ b/saga/sdebug.cpp
@@ -20,57 +20,37 @@
* $Header$
*
*/
-/*
-
- Description:
-
- Scripting module simple thread debugging support
- Notes:
-*/
+// Scripting module simple thread debugging support
#include "reinherit.h"
#include "yslib.h"
-/*
- * Uses the following modules:
-\*--------------------------------------------------------------------------*/
#include "actor_mod.h"
#include "console_mod.h"
#include "text_mod.h"
#include "scene_mod.h"
#include "font_mod.h"
-/*
- * Begin module component
-\*--------------------------------------------------------------------------*/
#include "script.h"
#include "sthread.h"
namespace Saga {
#define SD_DISPLAY_LEN 128
-
#define SD_ADDTXT( x ) strncat( disp_buf, x, SD_DISPLAY_LEN );
-int SDEBUG_PrintInstr(R_SCRIPT_THREAD * thread)
-{
-
+int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) {
R_TEXTLIST_ENTRY tl_e;
-
const byte *start_p;
const byte *read_p;
-
char tmp_buf[80] = { 0 };
static char disp_buf[SD_DISPLAY_LEN] = { 0 };
-
int in_char;
- /*int op_offset; */
-
+// int op_offset;
int n_switch;
int i;
-
R_SCENE_INFO si;
SCENE_GetInfo(&si);
@@ -78,7 +58,6 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD * thread)
disp_buf[0] = 0;
if (ScriptModule.dbg_txtentry != NULL) {
-
TEXT_DeleteEntry(si.text_list, ScriptModule.dbg_txtentry);
ScriptModule.dbg_txtentry = NULL;
}
@@ -92,70 +71,53 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD * thread)
tl_e.string = disp_buf;
tl_e.display = 1;
- read_p = ScriptModule.current_script->bytecode->bytecode_p +
- thread->i_offset;
-
+ read_p = ScriptModule.current_script->bytecode->bytecode_p + thread->i_offset;
start_p = read_p;
-
in_char = ys_read_u8(read_p, &read_p);
-
sprintf(tmp_buf, "%04lX | %02X | ", thread->i_offset, in_char);
strncat(disp_buf, tmp_buf, SD_DISPLAY_LEN);
switch (in_char) {
-
- /* Align */
+ // Align
case 0x01:
-
SD_ADDTXT("ALGN |");
break;
-
- /* Push nothing */
+ // Push nothing
case 0x02:
-
SD_ADDTXT("PSHN |");
break;
-
- /* Pop nothing */
+ // Pop nothing
case 0x03:
-
SD_ADDTXT("POPN |");
break;
-
- /* Push false (0) */
+ // Push false (0)
case 0x04:
-
SD_ADDTXT("PSHF |");
break;
-
- /* Push true (1) */
+ // Push true (1)
case 0x05:
-
SD_ADDTXT("PSHT |");
break;
-
- /* Push word (dialogue string index) */
+ // Push word (dialogue string index)
case 0x08:
{
int param;
SD_ADDTXT("PSHD | ");
-
param = ys_read_u16_le(read_p, &read_p);
sprintf(tmp_buf, "%02X", param);
SD_ADDTXT(tmp_buf);
/*
- if(( param >= 0 ) && ( param < diag_list->n_dialogue )) {
- printf(" ; \"%.*s\"", R_SCRIPT_STRINGLIMIT, diag_list->str[param] );
- }
- else {
- printf(" ; Invalid dialogue string.\n" );
- }
+ if(( param >= 0 ) && ( param < diag_list->n_dialogue )) {
+ printf(" ; \"%.*s\"", R_SCRIPT_STRINGLIMIT, diag_list->str[param] );
+ }
+ else {
+ printf(" ; Invalid dialogue string.\n" );
+ }
*/
}
break;
-
- /* Push word */
+ // Push word
case 0x06:
{
int param;
@@ -166,8 +128,7 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD * thread)
SD_ADDTXT(tmp_buf);
}
break;
-
- /* Test flag */
+ // Test flag
case 0x0B:
{
int param1;
@@ -176,13 +137,11 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD * thread)
SD_ADDTXT("TSTF | ");
param1 = *read_p++;
param2 = ys_read_u16_le(read_p, &read_p);
-
sprintf(tmp_buf, "%02X %04X", param1, param2);
SD_ADDTXT(tmp_buf);
}
break;
-
- /* Get word */
+ // Get word
case 0x0C:
{
int param1;
@@ -191,13 +150,11 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD * thread)
SD_ADDTXT("GETW | ");
param1 = *read_p++;
param2 = ys_read_u16_le(read_p, &read_p);
-
sprintf(tmp_buf, "%02X %04X", param1, param2);
SD_ADDTXT(tmp_buf);
}
break;
-
- /* Modify flag */
+ // Modify flag
case 0x0F:
{
int param1;
@@ -206,13 +163,11 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD * thread)
SD_ADDTXT("MODF | ");
param1 = *read_p++;
param2 = ys_read_u16_le(read_p, &read_p);
-
sprintf(tmp_buf, "%02X %04X", param1, param2);
SD_ADDTXT(tmp_buf);
}
break;
-
- /* Put word */
+ // Put word
case 0x10:
{
int param1;
@@ -221,13 +176,11 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD * thread)
SD_ADDTXT("PUTW | ");
param1 = *read_p++;
param2 = ys_read_u16_le(read_p, &read_p);
-
sprintf(tmp_buf, "%02X %04X", param1, param2);
SD_ADDTXT(tmp_buf);
}
break;
-
- /* Modify flag and pop */
+ // Modify flag and pop
case 0x13:
{
int param1;
@@ -236,13 +189,11 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD * thread)
SD_ADDTXT("MDFP | ");
param1 = *read_p++;
param2 = ys_read_u16_le(read_p, &read_p);
-
sprintf(tmp_buf, "%02X %04X", param1, param2);
SD_ADDTXT(tmp_buf);
}
break;
-
- /* Put word and pop */
+ // Put word and pop
case 0x14:
{
int param1;
@@ -256,8 +207,7 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD * thread)
SD_ADDTXT(tmp_buf);
}
break;
-
- /* Call subscript ? */
+ // Call subscript ?
case 0x17:
{
int param1;
@@ -268,14 +218,11 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD * thread)
param1 = *read_p++;
param2 = *read_p++;
param3 = ys_read_u16_le(read_p, &read_p);
-
- sprintf(tmp_buf, "%02X %02X %04X", param1, param2,
- param3);
+ sprintf(tmp_buf, "%02X %02X %04X", param1, param2, param3);
SD_ADDTXT(tmp_buf);
}
break;
-
- /* Call function */
+ // Call function
case 0x19:
case 0x18:
{
@@ -283,116 +230,96 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD * thread)
int param;
SD_ADDTXT("CALL | ");
-
func_num = *read_p++;
sprintf(tmp_buf, "%02X ", func_num);
SD_ADDTXT(tmp_buf);
-
param = ys_read_u16_le(read_p, &read_p);
sprintf(tmp_buf, "%04X ", param);
SD_ADDTXT(tmp_buf);
}
break;
-
- /* Begin subscript */
+ // Begin subscript
case 0x1A:
{
int param;
SD_ADDTXT("ENTR | ");
param = ys_read_u16_le(read_p, &read_p);
-
sprintf(tmp_buf, "%04X ", param);
SD_ADDTXT(tmp_buf);
/*
- for( i = 0 ; i < script_list->n_scripts ; i++ ) {
- if( op_offset == script_list->scripts[i].offset ) {
- printf("; Entrypoint \"%s\".", script_list->scriptl_p +
- script_list->scripts[i].name_offset );
-
- break;
- }
+ for( i = 0 ; i < script_list->n_scripts ; i++ ) {
+ if( op_offset == script_list->scripts[i].offset ) {
+ printf("; Entrypoint \"%s\".", script_list->scriptl_p + script_list->scripts[i].name_offset );
+ break;
}
+ }
*/
}
break;
-
case 0x1B:
SD_ADDTXT("??? ");
break;
-
- /* End subscript */
+ // End subscript
case 0x1C:
SD_ADDTXT("EXIT |");
break;
-
- /* Unconditional jump */
+ // Unconditional jump
case 0x1D:
{
int param1;
SD_ADDTXT("JMP | ");
param1 = ys_read_u16_le(read_p, &read_p);
-
sprintf(tmp_buf, "%04X", param1);
SD_ADDTXT(tmp_buf);
}
break;
-
- /* Jump if nonzero + POP */
+ // Jump if nonzero + POP
case 0x1E:
{
int param1;
SD_ADDTXT("JNZP | ");
param1 = ys_read_u16_le(read_p, &read_p);
-
sprintf(tmp_buf, "%04X", param1);
SD_ADDTXT(tmp_buf);
}
break;
-
- /* Jump if zero + POP */
+ // Jump if zero + POP
case 0x1F:
{
int param1;
SD_ADDTXT("JZP | ");
param1 = ys_read_u16_le(read_p, &read_p);
-
sprintf(tmp_buf, "%04X", param1);
SD_ADDTXT(tmp_buf);
}
break;
-
- /* Jump if nonzero */
+ // Jump if nonzero
case 0x20:
{
int param1;
-
SD_ADDTXT("JNZ | ");
param1 = ys_read_u16_le(read_p, &read_p);
-
sprintf(tmp_buf, "%04X", param1);
SD_ADDTXT(tmp_buf);
}
break;
- /* Jump if zero */
+ // Jump if zero
case 0x21:
{
int param1;
SD_ADDTXT("JZ | ");
param1 = ys_read_u16_le(read_p, &read_p);
-
sprintf(tmp_buf, "%04X", param1);
SD_ADDTXT(tmp_buf);
-
}
break;
-
- /* Switch */
+ // Switch
case 0x22:
{
int switch_num;
@@ -401,28 +328,18 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD * thread)
SD_ADDTXT("SWCH | ");
n_switch = ys_read_u16_le(read_p, &read_p);
-
sprintf(tmp_buf, "%02X\n", n_switch);
SD_ADDTXT(tmp_buf);
-
for (i = 0; i < n_switch; i++) {
switch_num = ys_read_u16_le(read_p, &read_p);
switch_jmp = ys_read_u16_le(read_p, &read_p);
-
- /*
- * printf( R_TAB "CASE %04X, %04X\n", switch_num, switch_jmp );
- */
+ // printf( R_TAB "CASE %04X, %04X\n", switch_num, switch_jmp);
}
-
default_jmp = ys_read_u16_le(read_p, &read_p);
-
- /*
- * printf( R_TAB "DEF %04X", default_jmp );
- */
+ //printf( R_TAB "DEF %04X", default_jmp);
}
break;
-
- /* Random branch */
+ // Random branch
case 0x24:
{
int n_switch2;
@@ -430,149 +347,116 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD * thread)
int switch_jmp;
SD_ADDTXT("RJMP | ");
-
- /* Ignored? */
+ // Ignored?
ys_read_u16_le(read_p, &read_p);
-
n_switch2 = ys_read_u16_le(read_p, &read_p);
-
sprintf(tmp_buf, "%04X", n_switch2);
SD_ADDTXT(tmp_buf);
-
for (i = 0; i < n_switch2; i++) {
- /*printf("\n"); */
+ //printf("\n");
switch_num = ys_read_u16_le(read_p, &read_p);
switch_jmp = ys_read_u16_le(read_p, &read_p);
- /*
- * printf( R_TAB "WEIGHT %04X, %04X", switch_num, switch_jmp );
- */
+ //printf( R_TAB "WEIGHT %04X, %04X", switch_num, switch_jmp);
}
}
break;
-
case 0x25:
SD_ADDTXT("NEG |");
break;
-
case 0x26:
SD_ADDTXT("TSTZ |");
break;
-
case 0x27:
SD_ADDTXT("NOT |");
break;
-
case 0x28:
SD_ADDTXT("??? ");
read_p++;
ys_read_u16_le(read_p, &read_p);
break;
-
case 0x29:
SD_ADDTXT("??? ");
read_p++;
ys_read_u16_le(read_p, &read_p);
break;
-
case 0x2A:
SD_ADDTXT("??? ");
read_p++;
ys_read_u16_le(read_p, &read_p);
break;
-
case 0x2B:
SD_ADDTXT("??? ");
read_p++;
ys_read_u16_le(read_p, &read_p);
break;
-
- /* Addition */
+ // Addition
case 0x2C:
SD_ADDTXT("ADD |");
break;
-
- /* Subtraction */
+ // Subtraction
case 0x2D:
SD_ADDTXT("SUB |");
break;
-
- /* Integer multiplication */
+ // Integer multiplication
case 0x2E:
SD_ADDTXT("MULT |");
break;
-
- /* Integer division */
+ // Integer division
case 0x2F:
SD_ADDTXT("DIV |");
break;
-
- /* Modulus */
+ // Modulus
case 0x30:
SD_ADDTXT("MOD |");
break;
-
- /* Test equality */
+ // Test equality
case 0x33:
SD_ADDTXT("EQU |");
break;
-
- /* Test inequality */
+ // Test inequality
case 0x34:
SD_ADDTXT("NEQU |");
break;
-
- /* Test Greater-than */
+ // Test Greater-than
case 0x35:
SD_ADDTXT("GRT |");
break;
-
- /* Test Less-than */
+ // Test Less-than
case 0x36:
SD_ADDTXT("LST |");
break;
-
- /* Test Greater-than or Equal to */
+ // Test Greater-than or Equal to
case 0x37:
SD_ADDTXT("GRTE |");
break;
-
- /* Test Less-than or Equal to */
+ // Test Less-than or Equal to
case 0x38:
SD_ADDTXT("LSTE |");
break;
-
case 0x3F:
SD_ADDTXT("SHR |");
break;
-
case 0x40:
SD_ADDTXT("SHL |");
break;
-
case 0x41:
SD_ADDTXT("AND |");
break;
-
case 0x42:
SD_ADDTXT("OR |");
break;
-
case 0x43:
SD_ADDTXT("XOR |");
break;
-
case 0x44:
SD_ADDTXT("LAND |");
break;
-
case 0x45:
SD_ADDTXT("LOR |");
break;
-
case 0x46:
SD_ADDTXT("LXOR |");
break;
-
case 0x53:
{
int n_voices;
@@ -580,28 +464,21 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD * thread)
int param2;
SD_ADDTXT("DLGP | ");
-
n_voices = *read_p++;
param1 = ys_read_u16_le(read_p, &read_p);
param2 = *read_p++;
-
- /* ignored ? */
+ // ignored ?
ys_read_u16_le(read_p, &read_p);
-
- sprintf(tmp_buf, "%02X %04X %02X", n_voices, param1,
- param2);
+ sprintf(tmp_buf, "%02X %04X %02X", n_voices, param1, param2);
SD_ADDTXT(tmp_buf);
}
break;
-
case 0x54:
SD_ADDTXT("DLGS |");
break;
-
case 0x55:
SD_ADDTXT("DLGX |");
break;
-
case 0x56:
{
int param1;
@@ -611,19 +488,15 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD * thread)
SD_ADDTXT("DLGO | ");
param1 = *read_p++;
param2 = *read_p++;
-
sprintf(tmp_buf, "%02X %02X ", param1, param2);
SD_ADDTXT(tmp_buf);
-
if (param2 > 0) {
param3 = ys_read_u16_le(read_p, &read_p);
-
sprintf(tmp_buf, "%04X", param3);
SD_ADDTXT(tmp_buf);
}
}
break;
-
case 0x57:
{
int param1;
@@ -631,23 +504,18 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD * thread)
int param3;
SD_ADDTXT("JMPS | ");
-
param1 = ys_read_u16_le(read_p, &read_p);
param2 = ys_read_u16_le(read_p, &read_p);
param3 = *read_p++;
-
- sprintf(tmp_buf, "%04X %04X %02X", param1, param2,
- param3);
+ sprintf(tmp_buf, "%04X %04X %02X", param1, param2, param3);
SD_ADDTXT(tmp_buf);
}
break;
-
default:
sprintf(tmp_buf, "Invalid opcode.\n");
SD_ADDTXT(tmp_buf);
break;
-
- } /* end switch( in_char ) */
+ }
ScriptModule.dbg_txtentry = TEXT_AddEntry(si.text_list, &tl_e);
TEXT_SetDisplay(ScriptModule.dbg_txtentry, 1);
diff --git a/saga/sfuncs.cpp b/saga/sfuncs.cpp
index 8e586983cb..cc808efc01 100644
--- a/saga/sfuncs.cpp
+++ b/saga/sfuncs.cpp
@@ -20,295 +20,164 @@
* $Header$
*
*/
-/*
- Description:
-
- Scripting module script function component
-
- Notes:
-*/
+// Scripting module script function component
#include "reinherit.h"
#include "yslib.h"
-/*
- * Uses the following modules:
-\*--------------------------------------------------------------------------*/
#include "actor_mod.h"
#include "animation_mod.h"
#include "console_mod.h"
#include "interface_mod.h"
#include "text_mod.h"
-/*
-\*--------------------------------------------------------------------------*/
#include "script.h"
#include "sfuncs.h"
namespace Saga {
R_SFUNC_ENTRY SFuncList[R_SFUNC_NUM] = {
-
- {0, 0, NULL}
- ,
- {1, 1, SF_Sleep}
- ,
- {2, 0, NULL}
- ,
- {3, 1, SF_3}
- ,
- {4, 1, SF_SetCommandText}
- ,
- {5, 0, NULL}
- ,
- {6, 3, SF_ActorWalkTo}
- ,
- {7, 0, NULL}
- ,
- {8, 2, SF_SetActorOrient}
- ,
- {9, 0, NULL}
- ,
- {10, 0, NULL}
- ,
- {11, 1, SF_FreezeInterface}
- ,
- {12, 0, NULL}
- ,
- {13, 0, NULL}
- ,
- {14, 0, NULL}
- ,
- {15, 0, NULL}
- ,
- {16, 0, NULL}
- ,
- {17, 0, NULL}
- ,
- {18, 0, NULL}
- ,
- {19, 0, NULL}
- ,
- {20, 0, NULL}
- ,
- {21, 0, NULL}
- ,
- {22, 0, NULL}
- ,
- {23, 0, NULL}
- ,
- {24, 0, NULL}
- ,
- {25, 0, NULL}
- ,
- {26, 3, SF_StartAnim}
- ,
- {27, 3, SF_ActorWalkToAsync}
- ,
- {28, 0, NULL}
- ,
- {29, 0, NULL}
- ,
- {30, 3, SF_PlaceActor}
- ,
- {31, 0, NULL}
- ,
- {32, 0, NULL}
- ,
- {33, 0, NULL}
- ,
- {34, 0, NULL}
- ,
- {35, 0, NULL}
- ,
- {36, 4, SF_ActorWalkTo2}
- ,
- {37, 4, SF_SetActorAct}
- ,
- {38, 3, SF_SetActorAct2}
- ,
- {39, 0, NULL}
- ,
- {40, 0, NULL}
- ,
- {41, 4, SF_LinkAnim}
- ,
- {42, 0, NULL}
- ,
- {43, 6, SF_PlaceActorEx}
- ,
- {44, 0, SF_CheckUserInterrupt}
- ,
- {45, 0, NULL}
- ,
- {46, 0, NULL}
- ,
- {47, 0, NULL}
- ,
- {48, 0, NULL}
- ,
- {49, 0, NULL}
- ,
- {50, 0, NULL}
- ,
- {51, 0, NULL}
- ,
- {52, 0, NULL}
- ,
- {53, 0, NULL}
- ,
- {54, 0, NULL}
- ,
- {55, 0, NULL}
- ,
- {56, 0, NULL}
- ,
- {57, 0, NULL}
- ,
- {58, 0, NULL}
- ,
- {59, 0, NULL}
- ,
- {60, 0, NULL}
- ,
- {61, 0, NULL}
- ,
- {62, 0, NULL}
- ,
- {63, 0, NULL}
- ,
- {64, 0, NULL}
- ,
- {65, 0, NULL}
- ,
- {66, 0, NULL}
- ,
- {67, 0, NULL}
- ,
- {68, 0, NULL}
- ,
- {69, 0, NULL}
- ,
- {70, 0, NULL}
- ,
- {71, 0, NULL}
- ,
- {72, 0, NULL}
- ,
- {73, 0, NULL}
- ,
- {74, 0, NULL}
- ,
- {75, 0, NULL}
- ,
- {76, 0, NULL}
- ,
+ {0, 0, NULL},
+ {1, 1, SF_Sleep},
+ {2, 0, NULL},
+ {3, 1, SF_3},
+ {4, 1, SF_SetCommandText},
+ {5, 0, NULL},
+ {6, 3, SF_ActorWalkTo},
+ {7, 0, NULL},
+ {8, 2, SF_SetActorOrient},
+ {9, 0, NULL},
+ {10, 0, NULL},
+ {11, 1, SF_FreezeInterface},
+ {12, 0, NULL},
+ {13, 0, NULL},
+ {14, 0, NULL},
+ {15, 0, NULL},
+ {16, 0, NULL},
+ {17, 0, NULL},
+ {18, 0, NULL},
+ {19, 0, NULL},
+ {20, 0, NULL},
+ {21, 0, NULL},
+ {22, 0, NULL},
+ {23, 0, NULL},
+ {24, 0, NULL},
+ {25, 0, NULL},
+ {26, 3, SF_StartAnim},
+ {27, 3, SF_ActorWalkToAsync},
+ {28, 0, NULL},
+ {29, 0, NULL},
+ {30, 3, SF_PlaceActor},
+ {31, 0, NULL},
+ {32, 0, NULL},
+ {33, 0, NULL},
+ {34, 0, NULL},
+ {35, 0, NULL},
+ {36, 4, SF_ActorWalkTo2},
+ {37, 4, SF_SetActorAct},
+ {38, 3, SF_SetActorAct2},
+ {39, 0, NULL},
+ {40, 0, NULL},
+ {41, 4, SF_LinkAnim},
+ {42, 0, NULL},
+ {43, 6, SF_PlaceActorEx},
+ {44, 0, SF_CheckUserInterrupt},
+ {45, 0, NULL},
+ {46, 0, NULL},
+ {47, 0, NULL},
+ {48, 0, NULL},
+ {49, 0, NULL},
+ {50, 0, NULL},
+ {51, 0, NULL},
+ {52, 0, NULL},
+ {53, 0, NULL},
+ {54, 0, NULL},
+ {55, 0, NULL},
+ {56, 0, NULL},
+ {57, 0, NULL},
+ {58, 0, NULL},
+ {59, 0, NULL},
+ {60, 0, NULL},
+ {61, 0, NULL},
+ {62, 0, NULL},
+ {63, 0, NULL},
+ {64, 0, NULL},
+ {65, 0, NULL},
+ {66, 0, NULL},
+ {67, 0, NULL},
+ {68, 0, NULL},
+ {69, 0, NULL},
+ {70, 0, NULL},
+ {71, 0, NULL},
+ {72, 0, NULL},
+ {73, 0, NULL},
+ {74, 0, NULL},
+ {75, 0, NULL},
+ {76, 0, NULL},
{77, 0, NULL}
};
-int SF_Sleep(R_SCRIPTFUNC_PARAMS)
-/*--------------------------------------------------------------------------*\
- *
- * Script function #1 (0x01) blocking
- *
- * Suspends thread execution for the specified time period
- *
- * Param1: time to suspend ( units? )
- *
-\*--------------------------------------------------------------------------*/
-{
+// Script function #1 (0x01) blocking
+// Suspends thread execution for the specified time period
+// Param1: time to suspend ( units? )
+int SF_Sleep(R_SCRIPTFUNC_PARAMS) {
SDataWord_T time_param;
-
int time;
SSTACK_Pop(thread->stack, &time_param);
-
time = SDATA_ReadWordU(time_param);
-
thread->sleep_time = time * 10;
-
return R_SUCCESS;
}
-int SF_3(R_SCRIPTFUNC_PARAMS)
-/*--------------------------------------------------------------------------*\
- *
- * Script function #3 (0x03)
- *
- * Unknown function; pops a parameter and pushes a return value
- *
- * Param1: unknown
- *
-\*--------------------------------------------------------------------------*/
-{
- /* INCOMPLETE */
-
+// Script function #3 (0x03)
+// Unknown function; pops a parameter and pushes a return value
+// Param1: unknown
+int SF_3(R_SCRIPTFUNC_PARAMS) {
+ // INCOMPLETE
SDataWord_T param1;
-
SSTACK_Pop(thread->stack, &param1);
-
- SSTACK_Push(thread->stack, 0); /* push for now to allow intro faire
- * setup to run completely */
+ SSTACK_Push(thread->stack, 0); // push for now to allow intro faire
+ // setup to run completely
return R_SUCCESS;
}
-int SF_SetCommandText(R_SCRIPTFUNC_PARAMS)
-/*--------------------------------------------------------------------------*\
- *
- * Script function #4 (0x04) nonblocking
- *
- * Set the command display to the specified text string
- *
- * Param1: dialogue index of string
- *
-\*--------------------------------------------------------------------------*/
-{
+// Script function #4 (0x04) nonblocking
+// Set the command display to the specified text string
+// Param1: dialogue index of string
+int SF_SetCommandText(R_SCRIPTFUNC_PARAMS) {
SDataWord_T s_idx_parm;
SSTACK_Pop(thread->stack, &s_idx_parm);
-
- /* INCOMPLETE */
+ // INCOMPLETE
return R_SUCCESS;
}
-int SF_ActorWalkTo(R_SCRIPTFUNC_PARAMS)
-/*--------------------------------------------------------------------------*\
- *
- * Script function #6 (0x06) blocking
- *
- * Commands the specified actor to walk to the given position
- *
- * Param1: actor id
- * Param2: actor destination x
- * Param3: actor destination y
- *
-\*--------------------------------------------------------------------------*/
-{
+// Script function #6 (0x06) blocking
+// Commands the specified actor to walk to the given position
+// Param1: actor id
+// Param2: actor destination x
+// Param3: actor destination y
+int SF_ActorWalkTo(R_SCRIPTFUNC_PARAMS) {
SDataWord_T actor_parm;
-
SDataWord_T x_parm;
SDataWord_T y_parm;
-
int actor_id;
int actor_idx;
-
R_POINT pt;
SSTACK_Pop(thread->stack, &actor_parm);
-
SSTACK_Pop(thread->stack, &x_parm);
SSTACK_Pop(thread->stack, &y_parm);
actor_id = SDATA_ReadWordS(actor_parm);
-
actor_idx = ACTOR_GetActorIndex(actor_id);
if (actor_idx < 0) {
- CON_Print(S_WARN_PREFIX "SF.08: Actor id 0x%X not found.",
- actor_id);
+ CON_Print(S_WARN_PREFIX "SF.08: Actor id 0x%X not found.", actor_id);
return R_FAILURE;
}
@@ -320,21 +189,13 @@ int SF_ActorWalkTo(R_SCRIPTFUNC_PARAMS)
return R_SUCCESS;
}
-int SF_SetActorOrient(R_SCRIPTFUNC_PARAMS)
-/*--------------------------------------------------------------------------*\
- *
- * Script function #8 (0x08) nonblocking
- *
- * Sets the orientation of the specified actor.
- *
- * Param1: actor id
- * Param2: actor orientation
- *
-\*--------------------------------------------------------------------------*/
-{
+// Script function #8 (0x08) nonblocking
+// Sets the orientation of the specified actor.
+// Param1: actor id
+// Param2: actor orientation
+int SF_SetActorOrient(R_SCRIPTFUNC_PARAMS) {
SDataWord_T actor_parm;
SDataWord_T orient_parm;
-
int actor_id;
int actor_idx;
int orientation;
@@ -344,12 +205,9 @@ int SF_SetActorOrient(R_SCRIPTFUNC_PARAMS)
actor_id = SDATA_ReadWordS(actor_parm);
orientation = SDATA_ReadWordS(orient_parm);
-
actor_idx = ACTOR_GetActorIndex(actor_id);
if (actor_idx < 0) {
- CON_Print(S_WARN_PREFIX "SF.08: Actor id 0x%X not found.",
- actor_id);
-
+ CON_Print(S_WARN_PREFIX "SF.08: Actor id 0x%X not found.", actor_id);
return R_FAILURE;
}
@@ -357,19 +215,12 @@ int SF_SetActorOrient(R_SCRIPTFUNC_PARAMS)
return R_SUCCESS;
}
-int SF_FreezeInterface(R_SCRIPTFUNC_PARAMS)
-/*--------------------------------------------------------------------------*\
- *
- * Script function #11 (0x0B) nonblocking
- *
- * If the parameter is true, the user interface is disabled while script
- * continues to run. If the parameter is false, the user interface is
- * reenabled.
- *
- * Param1: boolean
- *
-\*--------------------------------------------------------------------------*/
-{
+// Script function #11 (0x0B) nonblocking
+// If the parameter is true, the user interface is disabled while script
+// continues to run. If the parameter is false, the user interface is
+// reenabled.
+// Param1: boolean
+int SF_FreezeInterface(R_SCRIPTFUNC_PARAMS) {
SDataWord_T b_param;
SSTACK_Pop(thread->stack, &b_param);
@@ -383,23 +234,15 @@ int SF_FreezeInterface(R_SCRIPTFUNC_PARAMS)
return R_SUCCESS;
}
-int SF_StartAnim(R_SCRIPTFUNC_PARAMS)
-/*--------------------------------------------------------------------------*\
- *
- * Script function #26 (0x1A) nonblocking
- *
- * Starts the specified animation
- *
- * Param1: ?
- * Param2: frames of animation to play or -1 to loop
- * Param3: animation id
- *
-\*--------------------------------------------------------------------------*/
-{
+// Script function #26 (0x1A) nonblocking
+// Starts the specified animation
+// Param1: ?
+// Param2: frames of animation to play or -1 to loop
+// Param3: animation id
+int SF_StartAnim(R_SCRIPTFUNC_PARAMS) {
SDataWord_T unk_parm;
SDataWord_T frame_parm;
SDataWord_T anim_id_parm;
-
int frame_count;
int anim_id;
@@ -411,46 +254,31 @@ int SF_StartAnim(R_SCRIPTFUNC_PARAMS)
anim_id = SDATA_ReadWordS(anim_id_parm);
if (ANIM_Play(anim_id, 0) != R_SUCCESS) {
-
- CON_Print(S_WARN_PREFIX
- "SF.26: ANIM_Play() failed. Anim id: %u\n", anim_id);
-
+ CON_Print(S_WARN_PREFIX "SF.26: ANIM_Play() failed. Anim id: %u\n", anim_id);
return R_FAILURE;
}
return R_SUCCESS;
}
-int SF_ActorWalkToAsync(R_SCRIPTFUNC_PARAMS)
-/*--------------------------------------------------------------------------*\
- *
- * Script function #27 (0x1B) nonblocking
- *
- * Commands the specified actor to walk to the given position
- *
- * Param1: actor id
- * Param2: actor destination x
- * Param3: actor destination y
- *
-\*--------------------------------------------------------------------------*/
-{
+// Script function #27 (0x1B) nonblocking
+// Commands the specified actor to walk to the given position
+// Param1: actor id
+// Param2: actor destination x
+// Param3: actor destination y
+int SF_ActorWalkToAsync(R_SCRIPTFUNC_PARAMS) {
SDataWord_T actor_parm;
-
SDataWord_T x_parm;
SDataWord_T y_parm;
-
int actor_id;
int actor_idx;
-
R_POINT pt;
SSTACK_Pop(thread->stack, &actor_parm);
-
SSTACK_Pop(thread->stack, &x_parm);
SSTACK_Pop(thread->stack, &y_parm);
actor_id = SDATA_ReadWordS(actor_parm);
-
actor_idx = ACTOR_GetActorIndex(actor_id);
if (actor_idx < 0) {
CON_Print(S_WARN_PREFIX "SF.08: Actor id 0x%X not found.",
@@ -460,103 +288,71 @@ int SF_ActorWalkToAsync(R_SCRIPTFUNC_PARAMS)
pt.x = SDATA_ReadWordS(x_parm);
pt.y = SDATA_ReadWordS(y_parm);
-
ACTOR_WalkTo(actor_idx, &pt, 0, NULL);
return R_SUCCESS;
}
-int SF_PlaceActor(R_SCRIPTFUNC_PARAMS)
-/*--------------------------------------------------------------------------*\
- *
- * Script function #30 (0x1E) nonblocking
- *
- * Positions an actor at the specified location; actor is created if the
- * actor does not already exist.
- *
- * Param1: actor id
- * Param2: actor pos x
- * Param3: actor pos y
- *
-\*--------------------------------------------------------------------------*/
-{
+// Script function #30 (0x1E) nonblocking
+// Positions an actor at the specified location; actor is created if the
+// actor does not already exist.
+// Param1: actor id
+// Param2: actor pos x
+// Param3: actor pos y
+int SF_PlaceActor(R_SCRIPTFUNC_PARAMS) {
SDataWord_T actor_parm;
-
SDataWord_T x_parm;
SDataWord_T y_parm;
-
int actor_id;
int actor_idx;
int result;
-
R_POINT pt;
SSTACK_Pop(thread->stack, &actor_parm);
-
SSTACK_Pop(thread->stack, &x_parm);
SSTACK_Pop(thread->stack, &y_parm);
actor_id = SDATA_ReadWordS(actor_parm);
-
pt.x = SDATA_ReadWordS(x_parm);
pt.y = SDATA_ReadWordS(y_parm);
if (!ACTOR_ActorExists(actor_id)) {
-
result = ACTOR_Create(actor_id, pt.x, pt.y);
-
if (result != R_SUCCESS) {
-
- CON_Print(S_WARN_PREFIX
- "SF.30: Couldn't create actor 0x%X.", actor_id);
+ CON_Print(S_WARN_PREFIX "SF.30: Couldn't create actor 0x%X.", actor_id);
return R_FAILURE;
}
} else {
-
actor_idx = ACTOR_GetActorIndex(actor_id);
-
ACTOR_Move(actor_idx, &pt);
}
return R_SUCCESS;
}
-int SF_ActorWalkTo2(R_SCRIPTFUNC_PARAMS)
-/*--------------------------------------------------------------------------*\
- *
- * Script function #36 (0x24) ?
- *
- * Commands the specified actor to walk to the given position
- *
- * Param1: actor id
- * Param2: actor destination x
- * Param3: actor destination y
- * Param4: unknown
- *
-\*--------------------------------------------------------------------------*/
-{
- /* INCOMPLETE */
-
+// Script function #36 (0x24) ?
+// Commands the specified actor to walk to the given position
+// Param1: actor id
+// Param2: actor destination x
+// Param3: actor destination y
+// Param4: unknown
+int SF_ActorWalkTo2(R_SCRIPTFUNC_PARAMS) {
+ // INCOMPLETE
SDataWord_T actor_parm;
-
SDataWord_T x_parm;
SDataWord_T y_parm;
SDataWord_T unk_parm;
-
int actor_idx;
-
R_POINT pt;
SSTACK_Pop(thread->stack, &actor_parm);
-
SSTACK_Pop(thread->stack, &x_parm);
SSTACK_Pop(thread->stack, &y_parm);
SSTACK_Pop(thread->stack, &unk_parm);
actor_idx = ACTOR_GetActorIndex(SDATA_ReadWordS(actor_parm));
if (actor_idx < 0) {
- CON_Print(S_WARN_PREFIX "SF.36: Actor id 0x%X not found.",
- (int)actor_parm);
+ CON_Print(S_WARN_PREFIX "SF.36: Actor id 0x%X not found.", (int)actor_parm);
return R_FAILURE;
}
@@ -572,238 +368,164 @@ int SF_ActorWalkTo2(R_SCRIPTFUNC_PARAMS)
return R_SUCCESS;
}
-int SF_SetActorAct(R_SCRIPTFUNC_PARAMS)
-/*--------------------------------------------------------------------------*\
- *
- * Script function #37 (0x25) nonblocking
- *
- * Sets an actor to the specified action state
- *
- * Param1: actor id
- * Param2: unknown
- * Param3: actor action state
- * Param4: unknown
- *
-\*--------------------------------------------------------------------------*/
-{
- /* INCOMPLETE */
-
+// Script function #37 (0x25) nonblocking
+// Sets an actor to the specified action state
+// Param1: actor id
+// Param2: unknown
+// Param3: actor action state
+// Param4: unknown
+int SF_SetActorAct(R_SCRIPTFUNC_PARAMS) {
+ // INCOMPLETE
SDataWord_T actor_parm;
-
SDataWord_T unk1_parm;
SDataWord_T unk2_parm;
SDataWord_T action_parm;
-
int actor_id;
int actor_idx;
-
int action;
- /*uint16 flags; */
+ //uint16 flags;
SSTACK_Pop(thread->stack, &actor_parm);
-
SSTACK_Pop(thread->stack, &unk1_parm);
SSTACK_Pop(thread->stack, &action_parm);
SSTACK_Pop(thread->stack, &unk2_parm);
-
actor_id = SDATA_ReadWordS(actor_parm);
action = SDATA_ReadWordS(action_parm);
-
actor_idx = ACTOR_GetActorIndex(actor_id);
if (ACTOR_SetAction(actor_idx, action, ACTION_NONE) != R_SUCCESS) {
CON_Print(S_WARN_PREFIX "SF.37: ACTOR_SetAction() failed.");
-
return R_FAILURE;
}
return R_SUCCESS;
}
-int SF_SetActorAct2(R_SCRIPTFUNC_PARAMS)
-/*--------------------------------------------------------------------------*\
- *
- * Script function #38 (0x26) nonblocking
- *
- * Sets an actor to the specified action state
- *
- * Param1: actor id
- * Param2: actor action state
- * Param3: unknown
- *
-\*--------------------------------------------------------------------------*/
-{
- /* INCOMPLETE */
+// Script function #38 (0x26) nonblocking
+// Sets an actor to the specified action state
+// Param1: actor id
+// Param2: actor action state
+// Param3: unknown
+int SF_SetActorAct2(R_SCRIPTFUNC_PARAMS) {
+ // INCOMPLETE
SDataWord_T actor_parm;
-
SDataWord_T unk1_parm;
SDataWord_T action_parm;
int actor_id;
int actor_idx;
-
int action;
- /*uint16 flags; */
+ //uint16 flags;
SSTACK_Pop(thread->stack, &actor_parm);
-
SSTACK_Pop(thread->stack, &action_parm);
SSTACK_Pop(thread->stack, &unk1_parm);
actor_id = SDATA_ReadWordS(actor_parm);
action = SDATA_ReadWordS(action_parm);
-
actor_idx = ACTOR_GetActorIndex(actor_id);
if (ACTOR_SetAction(actor_idx, action, ACTION_NONE) != R_SUCCESS) {
CON_Print(S_WARN_PREFIX "SF.38: ACTOR_SetAction() failed.");
-
return R_FAILURE;
}
return R_SUCCESS;
}
-int SF_LinkAnim(R_SCRIPTFUNC_PARAMS)
-/*--------------------------------------------------------------------------*\
- *
- * Script function #41 (0x29) nonblocking
- *
- * Links the specified animations for playback
- *
- * Param1: ?
- * Param2: total linked frame count
- * Param3: animation id link target
- * Param4: animation id link source
- *
-\*--------------------------------------------------------------------------*/
-{
- SDataWord_T unk_parm;
+// Script function #41 (0x29) nonblocking
+// Links the specified animations for playback
+// Param1: ?
+// Param2: total linked frame count
+// Param3: animation id link target
+// Param4: animation id link source
+int SF_LinkAnim(R_SCRIPTFUNC_PARAMS) {
+ SDataWord_T unk_parm;
SDataWord_T tframes_parm;
SDataWord_T anim1_parm;
SDataWord_T anim2_parm;
-
int tframes;
-
uint16 anim_id1;
uint16 anim_id2;
SSTACK_Pop(thread->stack, &anim1_parm);
SSTACK_Pop(thread->stack, &anim2_parm);
-
SSTACK_Pop(thread->stack, &tframes_parm);
SSTACK_Pop(thread->stack, &unk_parm);
-
tframes = SDATA_ReadWordS(tframes_parm);
-
anim_id1 = SDATA_ReadWordU(anim1_parm);
anim_id2 = SDATA_ReadWordU(anim2_parm);
if (ANIM_Link(anim_id1, anim_id2) != R_SUCCESS) {
-
- CON_Print(S_WARN_PREFIX
- "SF.41: ANIM_Link() failed. (%u->%u)\n", anim_id1,
- anim_id2);
-
+ CON_Print(S_WARN_PREFIX "SF.41: ANIM_Link() failed. (%u->%u)\n", anim_id1, anim_id2);
return R_FAILURE;
}
return R_SUCCESS;
}
-int SF_PlaceActorEx(R_SCRIPTFUNC_PARAMS)
-/*--------------------------------------------------------------------------*\
- *
- * Script function #43 (0x2B) nonblocking
- *
- * Positions an actor at the specified location; actor is created if the
- * actor does not already exist.
- *
- * Param1: actor id
- * Param2: actor pos x
- * Param3: actor pos y
- * Param4: ?
- * Param5: actor action
- * Param6: ?
- *
-\*--------------------------------------------------------------------------*/
-{
- /* INCOMPLETE */
-
+// Script function #43 (0x2B) nonblocking
+// Positions an actor at the specified location; actor is created if the
+// actor does not already exist.
+// Param1: actor id
+// Param2: actor pos x
+// Param3: actor pos y
+// Param4: ?
+// Param5: actor action
+// Param6: ?
+int SF_PlaceActorEx(R_SCRIPTFUNC_PARAMS) {
+ // INCOMPLETE
SDataWord_T actor_parm;
-
SDataWord_T x_parm;
SDataWord_T y_parm;
-
SDataWord_T action_parm;
-
SDataWord_T unknown_parm;
-
int actor_id;
int actor_idx;
int action_state;
int result;
-
R_POINT pt;
SSTACK_Pop(thread->stack, &actor_parm);
-
SSTACK_Pop(thread->stack, &x_parm);
SSTACK_Pop(thread->stack, &y_parm);
-
SSTACK_Pop(thread->stack, &unknown_parm);
SSTACK_Pop(thread->stack, &action_parm);
SSTACK_Pop(thread->stack, &unknown_parm);
actor_id = SDATA_ReadWordS(actor_parm);
-
pt.x = SDATA_ReadWordS(x_parm);
pt.y = SDATA_ReadWordS(y_parm);
-
action_state = SDATA_ReadWordU(action_parm);
if (!ACTOR_ActorExists(actor_id)) {
-
result = ACTOR_Create(actor_id, pt.x, pt.y);
-
if (result != R_SUCCESS) {
-
- CON_Print(S_WARN_PREFIX
- "SF.43: Couldn't create actor 0x%X.", actor_id);
-
+ CON_Print(S_WARN_PREFIX "SF.43: Couldn't create actor 0x%X.", actor_id);
return R_FAILURE;
}
} else {
-
actor_idx = ACTOR_GetActorIndex(actor_id);
-
ACTOR_Move(actor_idx, &pt);
}
actor_idx = ACTOR_GetActorIndex(actor_id);
-
ACTOR_SetDefaultAction(actor_idx, action_state, ACTION_NONE);
ACTOR_SetAction(actor_idx, action_state, ACTION_NONE);
return R_SUCCESS;
}
-int SF_CheckUserInterrupt(R_SCRIPTFUNC_PARAMS)
-/*--------------------------------------------------------------------------*\
- *
- * Script function #44 (0x2C) nonblocking
- *
- * Checks to see if the user has interrupted a currently playing
- * game cinematic. Pushes a zero or positive value if the game
- * has not been interrupted.
- *
-\*--------------------------------------------------------------------------*/
-{
+// Script function #44 (0x2C) nonblocking
+// Checks to see if the user has interrupted a currently playing
+// game cinematic. Pushes a zero or positive value if the game
+// has not been interrupted.
+int SF_CheckUserInterrupt(R_SCRIPTFUNC_PARAMS) {
SSTACK_Push(thread->stack, 0);
- /* INCOMPLETE */
+ // INCOMPLETE
return R_SUCCESS;
}
diff --git a/saga/sfuncs.h b/saga/sfuncs.h
index 343618fbb6..03f9c82f29 100644
--- a/saga/sfuncs.h
+++ b/saga/sfuncs.h
@@ -20,14 +20,8 @@
* $Header$
*
*/
-/*
- Description:
-
- Scripting module script function component header file
-
- Notes:
-*/
+// Scripting module script function component header file
#ifndef SAGA_SFUNCS_H
#define SAGA_SFUNCS_H
@@ -38,66 +32,49 @@ namespace Saga {
#define R_SFUNC_NUM 78
-
-#define R_SCRIPTFUNC_PARAMS R_SCRIPT_THREAD * thread
+#define R_SCRIPTFUNC_PARAMS R_SCRIPT_THREAD *thread
typedef int (*SFunc_T) (R_SCRIPTFUNC_PARAMS);
struct R_SFUNC_ENTRY {
-
int sfunc_num;
int sfunc_argc;
SFunc_T sfunc_fp;
-
};
extern R_SFUNC_ENTRY SFuncList[];
-/* SF 1 */
+// SF 1
int SF_Sleep(R_SCRIPTFUNC_PARAMS);
-
-/* SF 3 */
+// SF 3
int SF_3(R_SCRIPTFUNC_PARAMS);
-
-/* SF 4 */
+// SF 4
int SF_SetCommandText(R_SCRIPTFUNC_PARAMS);
-
-/* SF 6 */
+// SF 6
int SF_ActorWalkTo(R_SCRIPTFUNC_PARAMS);
-
-/* SF 8 */
+// SF 8
int SF_SetActorOrient(R_SCRIPTFUNC_PARAMS);
-
-/* SF 11 */
+// SF 11
int SF_FreezeInterface(R_SCRIPTFUNC_PARAMS);
-
-/* SF 26 */
+// SF 26
int SF_StartAnim(R_SCRIPTFUNC_PARAMS);
-
-/* SF 27 */
+// SF 27
int SF_ActorWalkToAsync(R_SCRIPTFUNC_PARAMS);
-
-/* SF 30 */
+// SF 30
int SF_PlaceActor(R_SCRIPTFUNC_PARAMS);
-
-/* SF 36 */
+// SF 36
int SF_ActorWalkTo2(R_SCRIPTFUNC_PARAMS);
-
-/* SF 37 */
+// SF 37
int SF_SetActorAct(R_SCRIPTFUNC_PARAMS);
-
-/* SF 38 */
+// SF 38
int SF_SetActorAct2(R_SCRIPTFUNC_PARAMS);
-
-/* SF 41 */
+// SF 41
int SF_LinkAnim(R_SCRIPTFUNC_PARAMS);
-
-/* SF 43 */
+// SF 43
int SF_PlaceActorEx(R_SCRIPTFUNC_PARAMS);
-
-/* SF 44 */
+// SF 44
int SF_CheckUserInterrupt(R_SCRIPTFUNC_PARAMS);
} // End of namespace Saga
-#endif /* SAGA_SFUNCS_H */
+#endif