aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Kołodziejski2004-05-01 16:15:55 +0000
committerPaweł Kołodziejski2004-05-01 16:15:55 +0000
commit0af53f3c97075e380aab15bcc8dd7126b05bd9c4 (patch)
treea2f929125159a287518df2a70f11d58561dd954e
parentd84d93b5d0709e95dec412fe8c9b4e5c2dfa9e2e (diff)
downloadscummvm-rg350-0af53f3c97075e380aab15bcc8dd7126b05bd9c4.tar.gz
scummvm-rg350-0af53f3c97075e380aab15bcc8dd7126b05bd9c4.tar.bz2
scummvm-rg350-0af53f3c97075e380aab15bcc8dd7126b05bd9c4.zip
indent
svn-id: r13715
-rw-r--r--saga/sndres.cpp41
-rw-r--r--saga/sndres.h33
-rw-r--r--saga/sound.cpp19
-rw-r--r--saga/sound.h23
-rw-r--r--saga/sprite.cpp175
-rw-r--r--saga/sprite.h24
-rw-r--r--saga/sprite_mod.h37
-rw-r--r--saga/sstack.cpp60
-rw-r--r--saga/sstack.h23
-rw-r--r--saga/sthread.cpp558
-rw-r--r--saga/sthread.h19
-rw-r--r--saga/sys_interface.h3
-rw-r--r--saga/sysinput.cpp74
-rw-r--r--saga/systimer.cpp24
-rw-r--r--saga/systimer.h11
-rw-r--r--saga/text.cpp162
-rw-r--r--saga/text.h10
-rw-r--r--saga/text_mod.h16
-rw-r--r--saga/transitions.cpp20
-rw-r--r--saga/ys_binread.cpp127
-rw-r--r--saga/ys_binwrite.cpp31
-rw-r--r--saga/ys_dl_list.cpp80
-rw-r--r--saga/yslib.h55
23 files changed, 395 insertions, 1230 deletions
diff --git a/saga/sndres.cpp b/saga/sndres.cpp
index 3e6d45e895..6fc98017c7 100644
--- a/saga/sndres.cpp
+++ b/saga/sndres.cpp
@@ -20,13 +20,8 @@
* $Header$
*
*/
-/*
- Description:
-
- Sound resource management class
- Notes:
-*/
+// Sound resource management class
#include "saga.h"
#include "reinherit.h"
@@ -35,15 +30,9 @@
#include <limits.h>
-/*
- * Uses the following modules:
-\*--------------------------------------------------------------------------*/
#include "game_mod.h"
#include "rscfile_mod.h"
-/*
- * Begin module component
-\*--------------------------------------------------------------------------*/
#include "sndres.h"
#include "sound.h"
@@ -58,13 +47,12 @@ SndRes::SndRes(SagaEngine *vm) {
return;
}
- result = GAME_GetFileContext(&_voice_ctxt,
- R_GAME_VOICEFILE, 0);
+ result = GAME_GetFileContext(&_voice_ctxt, R_GAME_VOICEFILE, 0);
if (result != R_SUCCESS) {
return;
}
- /* Grab sound resource information for the current game */
+ // Grab sound resource information for the current game
GAME_GetSoundInfo(&_snd_info);
_vm = vm;
@@ -110,31 +98,21 @@ int SndRes::load(R_RSCFILE_CONTEXT *snd_ctxt, uint32 snd_rn, R_SOUNDBUFFER *snd_
snd_buf_i->s_freq = _snd_info.freq;
snd_buf_i->s_samplebits = _snd_info.sample_size;
snd_buf_i->s_stereo = _snd_info.stereo;
-
snd_buf_i->res_data = snd_res;
snd_buf_i->res_len = snd_res_len;
-
snd_buf_i->s_buf = snd_res;
snd_buf_i->s_buf_len = snd_res_len;
-
snd_buf_i->s_signed = 1;
-
break;
-
case R_GAME_SOUND_VOC:
if (loadVocSound(snd_res, snd_res_len, snd_buf_i) != R_SUCCESS) {
-
RSC_FreeResource(snd_res);
-
return R_FAILURE;
}
-
break;
-
default:
/* Unknown sound type */
RSC_FreeResource(snd_res);
-
return R_FAILURE;
break;
}
@@ -206,8 +184,7 @@ int SndRes::loadVocSound(byte *snd_res, size_t snd_res_len, R_SOUNDBUFFER *snd_b
return R_FAILURE;
}
- byte_rate = R_VOC_TIME_BASE / (R_VOC_TIME_CBASE -
- (voc_b1.time_constant << 8));
+ byte_rate = R_VOC_TIME_BASE / (R_VOC_TIME_CBASE - (voc_b1.time_constant << 8));
snd_buf_i->s_stereo = 0;
snd_buf_i->s_samplebits = 8;
@@ -220,11 +197,8 @@ int SndRes::loadVocSound(byte *snd_res, size_t snd_res_len, R_SOUNDBUFFER *snd_b
snd_buf_i->s_buf_len = read_len - 1; /* -1 for end block */
snd_buf_i->s_signed = 0;
-
return R_SUCCESS;
-
break;
-
default:
read_p += voc_gb.block_len;
read_len -= voc_gb.block_len;
@@ -251,13 +225,10 @@ int SndRes::getVoiceLength(uint32 voice_rn) {
}
if (_snd_info.res_type == R_GAME_SOUND_PCM) {
- ms_f = (double)length /
- (_snd_info.sample_size / CHAR_BIT) /
- (_snd_info.freq) * 1000.0;
-
+ ms_f = (double)length / (_snd_info.sample_size / CHAR_BIT) / (_snd_info.freq) * 1000.0;
ms_i = (int)ms_f;
} else if (_snd_info.res_type == R_GAME_SOUND_VOC) {
- /* Rough hack, fix this to be accurate */
+ // Rough hack, fix this to be accurate
ms_f = (double)length / 14705 * 1000.0;
ms_i = (int)ms_f;
} else {
diff --git a/saga/sndres.h b/saga/sndres.h
index 759a62ee0d..23b144b632 100644
--- a/saga/sndres.h
+++ b/saga/sndres.h
@@ -20,13 +20,8 @@
* $Header$
*
*/
-/*
- Description:
-
- Sound resource class header
- Notes:
-*/
+// Sound resource class header
#ifndef SAGA_SNDRES_H_
#define SAGA_SNDRES_H_
@@ -44,30 +39,30 @@ namespace Saga {
#define R_VOC_FILE_DESC "Creative Voice File\x1A"
struct R_VOC_HEADER_BLOCK {
- char ft_desc[20]; /* BYTE [20] */
- uint16 db_offset; /* WORD */
- uint16 voc_version; /* WORD */
- uint16 voc_fileid; /* WORD */
+ char ft_desc[20]; // BYTE [20]
+ uint16 db_offset; // WORD
+ uint16 voc_version;// WORD
+ uint16 voc_fileid; // WORD
};
#define R_VOC_HEADER_BLOCK_LEN 26
struct R_VOC_GENBLOCK {
- int block_id; /* BYTE */
- uint32 block_len; /* BYTE[3] */
+ int block_id; // BYTE
+ uint32 block_len; // BYTE[3]
};
#define R_VOC_GENBLOCK_LEN 4
struct R_VOC_BLOCK1 {
- int block_id; /* BYTE */
- uint32 block_len; /* BYTE[3] */
- uint16 time_constant; /* BYTE */
- int pack_method; /* BYTE */
+ int block_id; // BYTE
+ uint32 block_len; // BYTE[3]
+ uint16 time_constant; // BYTE
+ int pack_method; // BYTE
};
class SndRes {
- public:
+public:
SndRes(SagaEngine *vm);
@@ -89,8 +84,8 @@ class SndRes {
R_GAME_SOUNDINFO _snd_info;
SagaEngine *_vm;
- };
+};
} // End of namespace Saga
-#endif /* SAGA_SNDRES_H_ */
+#endif
diff --git a/saga/sound.cpp b/saga/sound.cpp
index 6747c266f6..65797b92d9 100644
--- a/saga/sound.cpp
+++ b/saga/sound.cpp
@@ -25,9 +25,6 @@
#include "yslib.h"
-/*
- * Uses the following modules:
-\*--------------------------------------------------------------------------*/
#include "sound.h"
#include "game_mod.h"
@@ -35,15 +32,11 @@
namespace Saga {
-/*
- * Begin module component
-\*--------------------------------------------------------------------------*/
-
Sound::Sound(SagaEngine *vm, SoundMixer *mixer, int enabled) :
_vm(vm), _mixer(mixer), _enabled(enabled) {
int result;
- /* Load sound module resource file contexts */
+ // Load sound module resource file contexts
result = GAME_GetFileContext(&_soundContext, R_GAME_SOUNDFILE, 0);
if (result != R_SUCCESS) {
return;
@@ -54,8 +47,8 @@ Sound::Sound(SagaEngine *vm, SoundMixer *mixer, int enabled) :
return;
}
- /* Grab sound resource information for the current game */
- GAME_GetSoundInfo(&_snd_info);
+ // Grab sound resource information for the current game
+ GAME_GetSoundInfo(&_snd_info);
_soundInitialized = 1;
return;
@@ -130,7 +123,7 @@ int Sound::playVoice(R_SOUNDBUFFER *buf) {
return R_SUCCESS;
}
-int Sound::pauseVoice(void) {
+int Sound::pauseVoice() {
if (!_soundInitialized) {
return R_FAILURE;
}
@@ -140,7 +133,7 @@ int Sound::pauseVoice(void) {
return R_SUCCESS;
}
-int Sound::resumeVoice(void) {
+int Sound::resumeVoice() {
if (!_soundInitialized) {
return R_FAILURE;
}
@@ -150,7 +143,7 @@ int Sound::resumeVoice(void) {
return R_SUCCESS;
}
-int Sound::stopVoice(void) {
+int Sound::stopVoice() {
if (!_soundInitialized) {
return R_FAILURE;
}
diff --git a/saga/sound.h b/saga/sound.h
index 9aeaa5799a..9f35a94e50 100644
--- a/saga/sound.h
+++ b/saga/sound.h
@@ -20,13 +20,8 @@
* $Header$
*
*/
-/*
- Description:
-
- Sound class
- Notes:
-*/
+// Sound class
#ifndef SAGA_SOUND_H_
#define SAGA_SOUND_H_
@@ -51,10 +46,10 @@ struct R_SOUNDBUFFER {
};
class Sound {
- public:
+public:
Sound(SagaEngine *vm, SoundMixer *mixer, int enabled);
- ~Sound(void);
+ ~Sound();
int play(int sound_rn, int channel);
int pause(int channel);
@@ -62,16 +57,16 @@ class Sound {
int stop(int channel);
int playVoice(R_SOUNDBUFFER *);
- int pauseVoice(void);
- int resumeVoice(void);
- int stopVoice(void);
+ int pauseVoice();
+ int resumeVoice();
+ int stopVoice();
private:
int _soundInitialized;
int _enabled;
- R_GAME_SOUNDINFO _snd_info;
+ R_GAME_SOUNDINFO _snd_info;
R_RSCFILE_CONTEXT *_soundContext;
R_RSCFILE_CONTEXT *_voiceContext;
@@ -83,8 +78,8 @@ class Sound {
PlayingSoundHandle _voiceHandle;
PlayingSoundHandle _musictHandle;
- };
+};
} // End of namespace Saga
-#endif /* SAGA_SOUND_H_ */
+#endif
diff --git a/saga/sprite.cpp b/saga/sprite.cpp
index 0339e5f00a..e47c175c02 100644
--- a/saga/sprite.cpp
+++ b/saga/sprite.cpp
@@ -20,21 +20,13 @@
* $Header$
*
*/
-/*
- Description:
-
- Sprite management module
- Notes:
-*/
+// Sprite management module
#include "reinherit.h"
#include "yslib.h"
-/*
- * Uses the following modules:
-\*--------------------------------------------------------------------------*/
#include "game_mod.h"
#include "gfx_mod.h"
#include "scene_mod.h"
@@ -43,9 +35,6 @@
#include "text_mod.h"
#include "font_mod.h"
-/*
- * Begin module component
-\*--------------------------------------------------------------------------*/
#include "sprite_mod.h"
#include "sprite.h"
@@ -53,8 +42,7 @@ namespace Saga {
static R_SPRITE_MODULE SpriteModule = { 0, 0, 0, 0 };
-int SPRITE_Init(void)
-{
+int SPRITE_Init() {
int result;
if (SpriteModule.init) {
@@ -63,12 +51,9 @@ int SPRITE_Init(void)
R_printf(R_STDOUT, "Initializing sprite subsystem...\n");
- /* Load sprite module resource context
- * \*------------------------------------------------------------- */
- result = GAME_GetFileContext(&SpriteModule.sprite_ctxt,
- R_GAME_RESOURCEFILE, 0);
+ // Load sprite module resource context
+ result = GAME_GetFileContext(&SpriteModule.sprite_ctxt, R_GAME_RESOURCEFILE, 0);
if (result != R_SUCCESS) {
-
return R_FAILURE;
}
@@ -84,8 +69,7 @@ int SPRITE_Init(void)
return R_SUCCESS;
}
-int SPRITE_Shutdown(void)
-{
+int SPRITE_Shutdown() {
if (!SpriteModule.init) {
return R_FAILURE;
}
@@ -97,28 +81,20 @@ int SPRITE_Shutdown(void)
return R_SUCCESS;
}
-int SPRITE_LoadList(int resource_num, R_SPRITELIST ** sprite_list_p)
-{
+int SPRITE_LoadList(int resource_num, R_SPRITELIST **sprite_list_p) {
R_SPRITELIST *new_slist;
-
byte *spritelist_data;
size_t spritelist_len;
-
const byte *read_p;
-
uint16 sprite_count;
uint16 i;
new_slist = (R_SPRITELIST *)malloc(sizeof *new_slist);
if (new_slist == NULL) {
-
return R_MEM;
}
- if (RSC_LoadResource(SpriteModule.sprite_ctxt,
- resource_num,
- &spritelist_data, &spritelist_len) != R_SUCCESS) {
-
+ if (RSC_LoadResource(SpriteModule.sprite_ctxt, resource_num, &spritelist_data, &spritelist_len) != R_SUCCESS) {
return R_FAILURE;
}
@@ -128,18 +104,15 @@ int SPRITE_LoadList(int resource_num, R_SPRITELIST ** sprite_list_p)
new_slist->sprite_count = sprite_count;
- new_slist->offset_list = (R_SPRITELIST_OFFSET *)malloc(sprite_count *
- sizeof *new_slist->offset_list);
+ new_slist->offset_list = (R_SPRITELIST_OFFSET *)malloc(sprite_count * sizeof *new_slist->offset_list);
if (new_slist->offset_list == NULL) {
free(new_slist);
-
return R_MEM;
}
for (i = 0; i < sprite_count; i++) {
new_slist->offset_list[i].data_idx = 0;
- new_slist->offset_list[i].offset =
- ys_read_u16_le(read_p, &read_p);
+ new_slist->offset_list[i].offset = ys_read_u16_le(read_p, &read_p);
}
new_slist->slist_rn = resource_num;
@@ -151,30 +124,21 @@ int SPRITE_LoadList(int resource_num, R_SPRITELIST ** sprite_list_p)
return R_SUCCESS;
}
-int SPRITE_AppendList(int resource_num, R_SPRITELIST * spritelist)
-{
+int SPRITE_AppendList(int resource_num, R_SPRITELIST *spritelist) {
byte *spritelist_data;
size_t spritelist_len;
-
const byte *read_p;
-
void *test_p;
-
uint16 old_sprite_count;
uint16 new_sprite_count;
uint16 sprite_count;
-
int i;
if (spritelist->append_count >= (R_APPENDMAX - 1)) {
-
return R_FAILURE;
}
- if (RSC_LoadResource(SpriteModule.sprite_ctxt,
- resource_num,
- &spritelist_data, &spritelist_len) != R_SUCCESS) {
-
+ if (RSC_LoadResource(SpriteModule.sprite_ctxt, resource_num, &spritelist_data, &spritelist_len) != R_SUCCESS) {
return R_FAILURE;
}
@@ -185,8 +149,7 @@ int SPRITE_AppendList(int resource_num, R_SPRITELIST * spritelist)
old_sprite_count = spritelist->sprite_count;
new_sprite_count = spritelist->sprite_count + sprite_count;
- test_p = realloc(spritelist->offset_list,
- new_sprite_count * sizeof *spritelist->offset_list);
+ test_p = realloc(spritelist->offset_list, new_sprite_count * sizeof *spritelist->offset_list);
if (test_p == NULL) {
return R_MEM;
}
@@ -198,8 +161,7 @@ int SPRITE_AppendList(int resource_num, R_SPRITELIST * spritelist)
for (i = old_sprite_count; i < spritelist->sprite_count; i++) {
spritelist->offset_list[i].data_idx = spritelist->append_count;
- spritelist->offset_list[i].offset =
- ys_read_u16_le(read_p, &read_p);
+ spritelist->offset_list[i].offset = ys_read_u16_le(read_p, &read_p);
}
spritelist->sprite_data[spritelist->append_count] = spritelist_data;
@@ -207,14 +169,11 @@ int SPRITE_AppendList(int resource_num, R_SPRITELIST * spritelist)
return R_SUCCESS;
}
-int SPRITE_GetListLen(R_SPRITELIST * spritelist)
-{
-
+int SPRITE_GetListLen(R_SPRITELIST *spritelist) {
return spritelist->sprite_count;
}
-int SPRITE_Free(R_SPRITELIST * spritelist)
-{
+int SPRITE_Free(R_SPRITELIST *spritelist) {
int i;
for (i = 0; i <= spritelist->append_count; i++) {
@@ -228,30 +187,19 @@ int SPRITE_Free(R_SPRITELIST * spritelist)
return R_SUCCESS;
}
-int
-SPRITE_Draw(R_SURFACE * ds,
- R_SPRITELIST * sprite_list, int sprite_num, int spr_x, int spr_y)
-{
-
+int SPRITE_Draw(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_num, int spr_x, int spr_y) {
int offset;
int offset_idx;
-
byte *sprite_p;
-
const byte *sprite_data_p;
const byte *read_p;
-
int i, j;
-
byte *buf_row_p;
byte *src_row_p;
-
int s_width;
int s_height;
-
int clip_width;
int clip_height;
-
int x_align;
int y_align;
@@ -286,32 +234,29 @@ SPRITE_Draw(R_SURFACE * ds,
return 0;
}
- DecodeRLESprite(sprite_data_p,
- 64000, SpriteModule.decode_buf, s_width * s_height);
+ DecodeRLESprite(sprite_data_p, 64000, SpriteModule.decode_buf, s_width * s_height);
buf_row_p = ds->buf + ds->buf_pitch * spr_y;
src_row_p = SpriteModule.decode_buf;
- /* Clip to right side of surface */
+ // Clip to right side of surface
clip_width = s_width;
if (s_width > (ds->buf_w - spr_x)) {
clip_width = (ds->buf_w - spr_x);
}
- /* Clip to bottom side of surface */
+ // Clip to bottom side of surface
clip_height = s_height;
if (s_height > (ds->buf_h - spr_y)) {
clip_height = (ds->buf_h - spr_y);
}
for (i = 0; i < clip_height; i++) {
-
for (j = 0; j < clip_width; j++) {
if (*(src_row_p + j) != 0) {
*(buf_row_p + j + spr_x) = *(src_row_p + j);
}
}
-
buf_row_p += ds->buf_pitch;
src_row_p += s_width;
}
@@ -319,51 +264,41 @@ SPRITE_Draw(R_SURFACE * ds,
return R_SUCCESS;
}
-int
-SPRITE_DrawOccluded(R_SURFACE * ds,
- R_SPRITELIST * sprite_list, int sprite_num, int spr_x, int spr_y)
-{
+int SPRITE_DrawOccluded(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_num, int spr_x, int spr_y) {
int offset;
int offset_idx;
-
byte *sprite_p;
const byte *sprite_data_p;
const byte *read_p;
-
int i;
-
int x, y;
byte *dst_row_p;
byte *src_row_p;
byte *src_p;
byte *dst_p;
byte *mask_p;
-
int s_width;
int s_height;
int x_align;
int y_align;
-
int z_lut[R_SPRITE_ZMAX];
int e_slope;
- /* Clipinfo variables */
+ // Clipinfo variables
R_POINT spr_pt;
R_RECT spr_src_rect;
R_RECT spr_dst_rect;
-
R_CLIPINFO ci;
- /* BG mask variables */
+ // BG mask variables
int mask_w;
int mask_h;
byte *mask_buf;
size_t mask_buf_len;
-
byte *mask_row_p;
int mask_z;
- /* Z info variables */
+ // Z info variables
SCENE_ZINFO zinfo;
int actor_z;
@@ -376,16 +311,11 @@ SPRITE_DrawOccluded(R_SURFACE * ds,
}
if (sprite_num >= sprite_list->sprite_count) {
-
- R_printf(R_STDOUT,
- "Invalid sprite number (%d) for sprite list %d.\n",
- sprite_num, sprite_list->slist_rn);
-
+ R_printf(R_STDOUT, "Invalid sprite number (%d) for sprite list %d.\n", sprite_num, sprite_list->slist_rn);
return R_FAILURE;
}
- /* Get sprite data from list
- * \*------------------------------------------------------------- */
+ // Get sprite data from list
offset = sprite_list->offset_list[sprite_num].offset;
offset_idx = sprite_list->offset_list[sprite_num].data_idx;
@@ -394,8 +324,8 @@ SPRITE_DrawOccluded(R_SURFACE * ds,
read_p = sprite_p;
- /* Read sprite dimensions -- should probably cache this stuff in
- * sprite list */
+ // Read sprite dimensions -- should probably cache this stuff in
+ // sprite list
x_align = ys_read_s8(read_p, &read_p);
y_align = ys_read_s8(read_p, &read_p);
@@ -404,16 +334,13 @@ SPRITE_DrawOccluded(R_SURFACE * ds,
sprite_data_p = read_p;
- /* Create actor Z occlusion LUT
- * \*---------------------------------------------------------------------- */
+ // Create actor Z occlusion LUT
SCENE_GetZInfo(&zinfo);
e_slope = zinfo.end_slope;
for (i = 0; i < R_SPRITE_ZMAX; i++) {
-
- z_lut[i] =
- (int)(e_slope + ((137.0 - e_slope) / 14.0) * (15.0 - i));
+ z_lut[i] = (int)(e_slope + ((137.0 - e_slope) / 14.0) * (15.0 - i));
}
actor_z = spr_y;
@@ -446,29 +373,21 @@ SPRITE_DrawOccluded(R_SURFACE * ds,
return R_SUCCESS;
}
- DecodeRLESprite(sprite_data_p,
- 64000, SpriteModule.decode_buf, s_width * s_height);
+ DecodeRLESprite(sprite_data_p, 64000, SpriteModule.decode_buf, s_width * s_height);
- /* Finally, draw the occluded sprite
- * \*---------------------------------------------------------------------- */
- src_row_p = SpriteModule.decode_buf + ci.src_draw_x +
- (ci.src_draw_y * s_width);
+ // Finally, draw the occluded sprite
+ src_row_p = SpriteModule.decode_buf + ci.src_draw_x + (ci.src_draw_y * s_width);
dst_row_p = ds->buf + ci.dst_draw_x + (ci.dst_draw_y * ds->buf_pitch);
mask_row_p = mask_buf + ci.dst_draw_x + (ci.dst_draw_y * mask_w);
for (y = 0; y < ci.draw_h; y++) {
-
src_p = src_row_p;
dst_p = dst_row_p;
mask_p = mask_row_p;
-
for (x = 0; x < ci.draw_w; x++) {
-
if (*src_p != 0) {
-
mask_z = *mask_p & R_SPRITE_ZMASK;
-
if (actor_z > z_lut[mask_z]) {
*dst_p = *src_p;
}
@@ -482,36 +401,23 @@ SPRITE_DrawOccluded(R_SURFACE * ds,
src_row_p += s_width;
}
/*
- {
- char buf[1024] = { 0 };
-
- sprintf( buf, "dw: %d, dh: %d.", ci.draw_w, ci.draw_h );
-
- TEXT_Draw( 2,
- ds,
- buf,
- spr_x - x_align, spr_y - y_align,
- 255, 0,
- FONT_OUTLINE );
- }
+ {
+ char buf[1024] = { 0 };
+ sprintf( buf, "dw: %d, dh: %d.", ci.draw_w, ci.draw_h );
+
+ TEXT_Draw(2, ds, buf, spr_x - x_align, spr_y - y_align, 255, 0, FONT_OUTLINE);
+ }
*/
return R_SUCCESS;
}
-int
-DecodeRLESprite(const byte * inbuf,
- size_t inbuf_len, byte * outbuf, size_t outbuf_len)
-{
-
+int DecodeRLESprite(const byte *inbuf, size_t inbuf_len, byte *outbuf, size_t outbuf_len) {
int bg_runcount;
int fg_runcount;
-
const byte *inbuf_ptr;
byte *outbuf_ptr;
-
const byte *inbuf_end;
byte *outbuf_end;
-
int c;
inbuf_ptr = inbuf;
@@ -526,7 +432,6 @@ DecodeRLESprite(const byte * inbuf,
memset(outbuf, 0, outbuf_len);
while ((inbuf_ptr < inbuf_end) && (outbuf_ptr < outbuf_end)) {
-
bg_runcount = *inbuf_ptr;
if (inbuf_ptr < inbuf_end)
inbuf_ptr++;
@@ -539,7 +444,6 @@ DecodeRLESprite(const byte * inbuf,
return 0;
for (c = 0; c < bg_runcount; c++) {
-
*outbuf_ptr = (byte) 0;
if (outbuf_ptr < outbuf_end)
outbuf_ptr++;
@@ -548,7 +452,6 @@ DecodeRLESprite(const byte * inbuf,
}
for (c = 0; c < fg_runcount; c++) {
-
*outbuf_ptr = *inbuf_ptr;
if (inbuf_ptr < inbuf_end)
inbuf_ptr++;
diff --git a/saga/sprite.h b/saga/sprite.h
index 4279e93296..ece166e9de 100644
--- a/saga/sprite.h
+++ b/saga/sprite.h
@@ -20,13 +20,8 @@
* $Header$
*
*/
-/*
- Description:
-
- Sprite management module private header file
- Notes:
-*/
+// Sprite management module private header file
#ifndef SAGA_SPRITE_H__
#define SAGA_SPRITE_H__
@@ -41,7 +36,6 @@ namespace Saga {
#define R_DECODE_BUF_LEN 64000
struct R_SPRITELIST_ENTRY {
-
int x_align;
int y_align;
int width;
@@ -50,39 +44,27 @@ struct R_SPRITELIST_ENTRY {
};
struct R_SPRITELIST_OFFSET {
-
uint16 data_idx;
size_t offset;
-
};
struct R_SPRITELIST_tag {
-
int append_count;
int sprite_count;
-
R_SPRITELIST_OFFSET *offset_list;
-
int slist_rn;
byte *sprite_data[R_APPENDMAX];
-
};
struct R_SPRITE_MODULE {
-
int init;
-
R_RSCFILE_CONTEXT *sprite_ctxt;
-
byte *decode_buf;
size_t decode_buf_len;
-
};
-int
-DecodeRLESprite(const byte * inbuf,
- size_t inbuf_len, byte * outbuf, size_t outbuf_len);
+int DecodeRLESprite(const byte *inbuf, size_t inbuf_len, byte *outbuf, size_t outbuf_len);
} // End of namespace Saga
-#endif /* SAGA_SPRITE_H__ */
+#endif
diff --git a/saga/sprite_mod.h b/saga/sprite_mod.h
index e93eec0513..a91ab2c298 100644
--- a/saga/sprite_mod.h
+++ b/saga/sprite_mod.h
@@ -20,14 +20,8 @@
* $Header$
*
*/
-/*
- Description:
-
- Sprite management module public header file
-
- Notes:
-*/
+// Sprite management module public header file
#ifndef SAGA_SPRITE_MOD_H__
#define SAGA_SPRITE_MOD_H__
@@ -36,26 +30,15 @@ namespace Saga {
typedef struct R_SPRITELIST_tag R_SPRITELIST;
-int SPRITE_Init(void);
-
-int SPRITE_Shutdown(void);
-
-int SPRITE_LoadList(int resource_num, R_SPRITELIST ** sprite_list_p);
-
-int SPRITE_AppendList(int resource_num, R_SPRITELIST * spritelist);
-
-int SPRITE_GetListLen(R_SPRITELIST * spritelist);
-
-int SPRITE_Free(R_SPRITELIST * spritelist);
-
-int
-SPRITE_Draw(R_SURFACE * ds,
- R_SPRITELIST * sprite_list, int sprite_num, int spr_x, int spr_y);
-
-int
-SPRITE_DrawOccluded(R_SURFACE * ds,
- R_SPRITELIST * sprite_list, int sprite_num, int spr_x, int spr_y);
+int SPRITE_Init();
+int SPRITE_Shutdown();
+int SPRITE_LoadList(int resource_num, R_SPRITELIST **sprite_list_p);
+int SPRITE_AppendList(int resource_num, R_SPRITELIST *spritelist);
+int SPRITE_GetListLen(R_SPRITELIST *spritelist);
+int SPRITE_Free(R_SPRITELIST *spritelist);
+int SPRITE_Draw(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_num, int spr_x, int spr_y);
+int SPRITE_DrawOccluded(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_num, int spr_x, int spr_y);
} // End of namespace Saga
-#endif /* SAGA_SPRITE_MOD_H__ */
+#endif
diff --git a/saga/sstack.cpp b/saga/sstack.cpp
index 99741ac632..8d899b8101 100644
--- a/saga/sstack.cpp
+++ b/saga/sstack.cpp
@@ -20,36 +20,22 @@
* $Header$
*
*/
-/*
- Description:
-
- Scripting engine stack component
-
- Notes:
-*/
+// Scripting engine stack component
#include "reinherit.h"
#include "yslib.h"
-/*
- * Uses the following modules:
-\*--------------------------------------------------------------------------*/
#include "console_mod.h"
#include "text_mod.h"
-/*
- * Begin module component
-\*--------------------------------------------------------------------------*/
#include "script.h"
#include "sstack.h"
namespace Saga {
-int SSTACK_Create(SSTACK * stack, int stack_len, int flags)
-{
-
+int SSTACK_Create(SSTACK *stack, int stack_len, int flags) {
SSTACK new_stack;
SDataWord_T *new_stack_data;
@@ -57,30 +43,25 @@ int SSTACK_Create(SSTACK * stack, int stack_len, int flags)
new_stack = (SSTACK_tag *)malloc(sizeof(struct SSTACK_tag));
if (new_stack == NULL) {
-
return STACK_MEM;
}
new_stack_data = (SDataWord_T *)calloc(stack_len, sizeof *new_stack_data);
if (new_stack_data == NULL) {
free(new_stack);
-
return STACK_MEM;
}
new_stack->data = new_stack_data;
-
new_stack->flags = flags;
new_stack->len = stack_len;
new_stack->top = -1;
-
*stack = new_stack;
return STACK_SUCCESS;
}
-int SSTACK_Destroy(SSTACK stack)
-{
+int SSTACK_Destroy(SSTACK stack) {
if (stack != NULL) {
free(stack->data);
}
@@ -90,24 +71,17 @@ int SSTACK_Destroy(SSTACK stack)
return STACK_SUCCESS;
}
-int SSTACK_Clear(SSTACK stack)
-{
-
+int SSTACK_Clear(SSTACK stack) {
stack->top = -1;
return STACK_SUCCESS;
}
-int SSTACK_PushNull(SSTACK stack)
-{
-
+int SSTACK_PushNull(SSTACK stack) {
if (stack->top >= (stack->len - 1)) {
-
if (stack->flags & STACK_FIXED) {
-
return STACK_OVERFLOW;
} else if (SSTACK_Grow(stack) != STACK_SUCCESS) {
-
return STACK_MEM;
}
}
@@ -117,16 +91,11 @@ int SSTACK_PushNull(SSTACK stack)
return STACK_SUCCESS;
}
-int SSTACK_Push(SSTACK stack, SDataWord_T value)
-{
-
+int SSTACK_Push(SSTACK stack, SDataWord_T value) {
if (stack->top >= (stack->len - 1)) {
-
if (stack->flags & STACK_FIXED) {
-
return STACK_OVERFLOW;
} else if (SSTACK_Grow(stack) != STACK_SUCCESS) {
-
return STACK_MEM;
}
}
@@ -137,16 +106,12 @@ int SSTACK_Push(SSTACK stack, SDataWord_T value)
return STACK_SUCCESS;
}
-int SSTACK_Pop(SSTACK stack, SDataWord_T * value)
-{
-
+int SSTACK_Pop(SSTACK stack, SDataWord_T *value) {
if (stack->top <= -1) {
-
return STACK_UNDERFLOW;
}
if (value == NULL) {
-
stack->top--;
return STACK_SUCCESS;
}
@@ -157,13 +122,10 @@ int SSTACK_Pop(SSTACK stack, SDataWord_T * value)
return STACK_SUCCESS;
}
-int SSTACK_Top(SSTACK stack, SDataWord_T * value)
-{
-
+int SSTACK_Top(SSTACK stack, SDataWord_T *value) {
*value = 0;
if (stack->top <= -1) {
-
return STACK_UNDERFLOW;
}
@@ -172,20 +134,16 @@ int SSTACK_Top(SSTACK stack, SDataWord_T * value)
return STACK_SUCCESS;
}
-int SSTACK_Grow(SSTACK stack)
-{
-
+int SSTACK_Grow(SSTACK stack) {
SDataWord_T *new_data;
if ((stack->len * 2) > R_STACK_SIZE_LIMIT) {
-
CON_Print(S_ERROR_PREFIX "Stack fault: growing beyond limit.");
return STACK_OVERFLOW;
}
new_data = (SDataWord_T *)realloc(stack->data, (stack->len * 2) * sizeof *new_data);
if (new_data == NULL) {
-
return STACK_MEM;
}
diff --git a/saga/sstack.h b/saga/sstack.h
index 669d0b0423..f5b1c3181b 100644
--- a/saga/sstack.h
+++ b/saga/sstack.h
@@ -20,14 +20,8 @@
* $Header$
*
*/
-/*
- Description:
-
- Scripting engine stack component header file
-
- Notes:
-*/
+// Scripting engine stack component header file
#ifndef SAGA_SSTACK_H
#define SAGA_SSTACK_H
@@ -60,22 +54,15 @@ typedef enum SSTACK_FLAGS_enum {
STACK_GROW = 0x01
} SSTACK_FLAGS;
-int SSTACK_Create(SSTACK * stack, int stack_len, int flags);
-
+int SSTACK_Create(SSTACK *stack, int stack_len, int flags);
int SSTACK_Destroy(SSTACK stack);
-
int SSTACK_Clear(SSTACK stack);
-
int SSTACK_Push(SSTACK stack, SDataWord_T value);
-
int SSTACK_PushNull(SSTACK stack);
-
-int SSTACK_Pop(SSTACK stack, SDataWord_T * value);
-
-int SSTACK_Top(SSTACK stack, SDataWord_T * value);
-
+int SSTACK_Pop(SSTACK stack, SDataWord_T *value);
+int SSTACK_Top(SSTACK stack, SDataWord_T *value);
int SSTACK_Grow(SSTACK stack);
} // End of namespace Saga
-#endif /* SAGA_SSTACK_H */
+#endif
diff --git a/saga/sthread.cpp b/saga/sthread.cpp
index c63e3088ed..e4b52272e7 100644
--- a/saga/sthread.cpp
+++ b/saga/sthread.cpp
@@ -20,14 +20,8 @@
* $Header$
*
*/
-/*
- Description:
-
- Scripting module thread management component
-
- Notes:
-*/
+// Scripting module thread management component
#include "reinherit.h"
@@ -35,16 +29,10 @@
#include <limits.h>
-/*
- * Uses the following modules:
-\*--------------------------------------------------------------------------*/
#include "actor_mod.h"
#include "console_mod.h"
#include "text_mod.h"
-/*
- * Begin module component
-\*--------------------------------------------------------------------------*/
#include "script.h"
#include "script_mod.h"
@@ -55,15 +43,13 @@
namespace Saga {
-R_SCRIPT_THREAD *STHREAD_Create(void)
-{
+R_SCRIPT_THREAD *STHREAD_Create() {
YS_DL_NODE *new_node;
R_SCRIPT_THREAD *new_thread;
int result;
if (!ScriptModule.initialized) {
-
return NULL;
}
@@ -72,24 +58,20 @@ R_SCRIPT_THREAD *STHREAD_Create(void)
return NULL;
}
- result = SSTACK_Create(&(new_thread->stack),
- R_DEF_THREAD_STACKSIZE, STACK_GROW);
+ result = SSTACK_Create(&(new_thread->stack), R_DEF_THREAD_STACKSIZE, STACK_GROW);
if (result != STACK_SUCCESS) {
return NULL;
}
- new_node = ys_dll_add_head(ScriptModule.thread_list,
- new_thread, sizeof *new_thread);
+ new_node = ys_dll_add_head(ScriptModule.thread_list, new_thread, sizeof *new_thread);
free(new_thread);
return (R_SCRIPT_THREAD *)ys_dll_get_data(new_node);
-
}
-int STHREAD_Destroy(R_SCRIPT_THREAD * thread)
-{
+int STHREAD_Destroy(R_SCRIPT_THREAD *thread) {
if (thread == NULL) {
return R_FAILURE;
}
@@ -99,23 +81,17 @@ int STHREAD_Destroy(R_SCRIPT_THREAD * thread)
return R_SUCCESS;
}
-int STHREAD_ExecThreads(int msec)
-{
+int STHREAD_ExecThreads(int msec) {
YS_DL_NODE *walk_p;
R_SCRIPT_THREAD *thread;
if (!ScriptModule.initialized) {
-
return R_FAILURE;
}
- for (walk_p = ys_dll_head(ScriptModule.thread_list);
- walk_p != NULL; walk_p = ys_dll_next(walk_p)) {
-
+ for (walk_p = ys_dll_head(ScriptModule.thread_list); walk_p != NULL; walk_p = ys_dll_next(walk_p)) {
thread = (R_SCRIPT_THREAD *)ys_dll_get_data(walk_p);
-
if (thread->executing) {
-
STHREAD_Run(thread, STHREAD_DEF_INSTR_COUNT, msec);
}
}
@@ -123,9 +99,7 @@ int STHREAD_ExecThreads(int msec)
return R_SUCCESS;
}
-int STHREAD_SetEntrypoint(R_SCRIPT_THREAD * thread, int ep_num)
-{
-
+int STHREAD_SetEntrypoint(R_SCRIPT_THREAD *thread, int ep_num) {
R_SCRIPT_BYTECODE *bytecode;
int max_entrypoint;
@@ -144,14 +118,10 @@ int STHREAD_SetEntrypoint(R_SCRIPT_THREAD * thread, int ep_num)
return R_SUCCESS;
}
-int STHREAD_Execute(R_SCRIPT_THREAD * thread, int ep_num)
-{
-
+int STHREAD_Execute(R_SCRIPT_THREAD *thread, int ep_num) {
assert(ScriptModule.initialized);
- if ((ScriptModule.current_script == NULL) ||
- (!ScriptModule.current_script->loaded)) {
-
+ if ((ScriptModule.current_script == NULL) || (!ScriptModule.current_script->loaded)) {
return R_FAILURE;
}
@@ -163,22 +133,15 @@ int STHREAD_Execute(R_SCRIPT_THREAD * thread, int ep_num)
return R_SUCCESS;
}
-unsigned char *GetReadPtr(R_SCRIPT_THREAD * thread)
-{
-
- return ScriptModule.current_script->bytecode->bytecode_p +
- thread->i_offset;
+unsigned char *GetReadPtr(R_SCRIPT_THREAD *thread) {
+ return ScriptModule.current_script->bytecode->bytecode_p + thread->i_offset;
}
-unsigned long GetReadOffset(const byte * read_p)
-{
-
- return (unsigned long)(read_p - (unsigned char *)
- ScriptModule.current_script->bytecode->bytecode_p);
+unsigned long GetReadOffset(const byte *read_p) {
+ return (unsigned long)(read_p - (unsigned char *)ScriptModule.current_script->bytecode->bytecode_p);
}
-int STHREAD_HoldSem(R_SEMAPHORE * sem)
-{
+int STHREAD_HoldSem(R_SEMAPHORE *sem) {
if (sem == NULL) {
return R_FAILURE;
}
@@ -188,8 +151,7 @@ int STHREAD_HoldSem(R_SEMAPHORE * sem)
return R_SUCCESS;
}
-int STHREAD_ReleaseSem(R_SEMAPHORE * sem)
-{
+int STHREAD_ReleaseSem(R_SEMAPHORE *sem) {
if (sem == NULL) {
return R_FAILURE;
}
@@ -202,9 +164,7 @@ int STHREAD_ReleaseSem(R_SEMAPHORE * sem)
return R_SUCCESS;
}
-int STHREAD_DebugStep(void)
-{
-
+int STHREAD_DebugStep() {
if (ScriptModule.dbg_singlestep) {
ScriptModule.dbg_dostep = 1;
}
@@ -212,51 +172,38 @@ int STHREAD_DebugStep(void)
return R_SUCCESS;
}
-int STHREAD_Run(R_SCRIPT_THREAD * thread, int instr_limit, int msec)
-{
-
+int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) {
int instr_count;
-
const byte *read_p;
uint32 saved_offset;
-
SDataWord_T param1;
SDataWord_T param2;
-
long iparam1;
long iparam2;
long iresult;
SDataWord_T data;
-
int debug_print = 0;
int n_buf;
int bitstate;
-
int result;
int in_char;
int i;
-
int unhandled = 0;
- /* Handle debug single-stepping */
+ // Handle debug single-stepping
if ((thread == ScriptModule.dbg_thread) && ScriptModule.dbg_singlestep) {
-
if (ScriptModule.dbg_dostep) {
-
debug_print = 1;
-
thread->sleep_time = 0;
instr_limit = 1;
ScriptModule.dbg_dostep = 0;
} else {
-
return R_SUCCESS;
}
}
for (instr_count = 0; instr_count < instr_limit; instr_count++) {
-
if ((!thread->executing) || (thread->sem.hold_count)) {
break;
}
@@ -272,336 +219,220 @@ int STHREAD_Run(R_SCRIPT_THREAD * thread, int instr_limit, int msec)
saved_offset = thread->i_offset;
#if 0
- R_printf(R_STDOUT, "Executing thread offset: %lu",
- thread->i_offset);
+ R_printf(R_STDOUT, "Executing thread offset: %lu", thread->i_offset);
#endif
read_p = GetReadPtr(thread);
in_char = ys_read_u8(read_p, &read_p);
switch (in_char) {
-
- /* Align (ALGN) */
+ // Align (ALGN)
case 0x01:
break;
- /*-------------------------------------------------------------*\
- * STACK INSTRUCTIONS
- \*-------------------------------------------------------------*/
+// STACK INSTRUCTIONS
- /* Push nothing (PSHN) */
+ // Push nothing (PSHN)
case 0x02:
-
SSTACK_PushNull(thread->stack);
-
break;
-
- /* Pop nothing (POPN) */
+ // Pop nothing (POPN)
case 0x03:
-
SSTACK_Pop(thread->stack, NULL);
-
break;
-
- /* Push false (PSHF) */
+ // Push false (PSHF)
case 0x04:
-
SSTACK_Push(thread->stack, 0);
-
break;
-
- /* Push true (PSHT) */
+ // Push true (PSHT)
case 0x05:
-
SSTACK_Push(thread->stack, 1);
-
break;
-
- /* Push word (PUSH) */
+ // Push word (PUSH)
case 0x06:
-
param1 = (SDataWord_T) ys_read_u16_le(read_p, &read_p);
SSTACK_Push(thread->stack, param1);
-
break;
-
- /* Push word (PSHD) (dialogue string index) */
+ // Push word (PSHD) (dialogue string index)
case 0x08:
-
param1 = (SDataWord_T) ys_read_u16_le(read_p, &read_p);
SSTACK_Push(thread->stack, param1);
-
break;
- /*-------------------------------------------------------------*\
- * DATA INSTRUCTIONS
- \*-------------------------------------------------------------*/
+// DATA INSTRUCTIONS
- /* Test flag (TSTF) */
+ // Test flag (TSTF)
case 0x0B:
-
n_buf = *read_p++;
param1 = (SDataWord_T) ys_read_u16_le(read_p, &read_p);
-
SDATA_GetBit(n_buf, param1, &bitstate);
SSTACK_Push(thread->stack, bitstate);
-
break;
-
- /* Get word (GETW) */
+ // Get word (GETW)
case 0x0C:
-
n_buf = *read_p++;
param1 = ys_read_u16_le(read_p, &read_p);
-
SDATA_GetWord(n_buf, param1, &data);
SSTACK_Push(thread->stack, data);
-
break;
-
- /* Modify flag (MODF) */
+ // Modify flag (MODF)
case 0x0F:
-
n_buf = *read_p++;
param1 = (SDataWord_T) ys_read_u16_le(read_p, &read_p);
-
bitstate = SDATA_ReadWordU(param1);
-
SSTACK_Top(thread->stack, &data);
-
if (bitstate) {
SDATA_SetBit(n_buf, data, 1);
} else {
SDATA_SetBit(n_buf, data, 0);
}
-
break;
-
- /* Put word (PUTW) */
+ // Put word (PUTW)
case 0x10:
-
n_buf = *read_p++;
param1 = (SDataWord_T) ys_read_u16_le(read_p, &read_p);
-
SSTACK_Top(thread->stack, &data);
SDATA_PutWord(n_buf, param1, data);
-
break;
-
- /* Modify flag and pop (MDFP) */
+ // Modify flag and pop (MDFP)
case 0x13:
-
n_buf = *read_p++;
param1 = (SDataWord_T) ys_read_u16_le(read_p, &read_p);
-
SSTACK_Pop(thread->stack, &param1);
-
bitstate = SDATA_ReadWordU(param1);
-
if (bitstate) {
SDATA_SetBit(n_buf, param1, 1);
} else {
SDATA_SetBit(n_buf, param1, 0);
}
-
break;
-
- /* Put word and pop (PTWP) */
+ // Put word and pop (PTWP)
case 0x14:
-
n_buf = *read_p++;
param1 = (SDataWord_T) ys_read_u16_le(read_p, &read_p);
-
SSTACK_Top(thread->stack, &data);
SDATA_PutWord(n_buf, param1, data);
-
break;
- /*-------------------------------------------------------------*\
- * CONTROL INSTRUCTIONS
- \*-------------------------------------------------------------*/
+// CONTROL INSTRUCTIONS
- /* (GOSB): Call subscript ? */
+ // (GOSB): Call subscript ?
case 0x17:
{
-
int temp;
int temp2;
temp = *read_p++;
temp2 = *read_p++;
-
- param1 =
- (SDataWord_T) ys_read_u16_le(read_p,
- &read_p);
+ param1 = (SDataWord_T) ys_read_u16_le(read_p, &read_p);
data = GetReadOffset(read_p);
-
- /*SSTACK_Push( thread->stack, (SDataWord_T)temp ); */
+ //SSTACK_Push(thread->stack, (SDataWord_T)temp);
SSTACK_Push(thread->stack, data);
-
thread->i_offset = (unsigned long)param1;
}
break;
-
- /* (CALL): Call function */
+ // (CALL): Call function
case 0x19:
case 0x18:
{
int n_args;
uint16 func_num;
int FIXME_SHADOWED_result;
-
SFunc_T sfunc;
n_args = ys_read_u8(read_p, &read_p);
func_num = ys_read_u16_le(read_p, &read_p);
-
if (func_num >= R_SFUNC_NUM) {
-
- CON_Print(S_ERROR_PREFIX
- "Invalid script function number: (%X)\n",
- func_num);
-
+ CON_Print(S_ERROR_PREFIX "Invalid script function number: (%X)\n", func_num);
thread->executing = 0;
break;
}
sfunc = SFuncList[func_num].sfunc_fp;
-
if (sfunc == NULL) {
-
- CON_Print(S_WARN_PREFIX
- "%X: Undefined script function number: (%X)\n",
- thread->i_offset, func_num);
-
- CON_Print(S_WARN_PREFIX
- "Removing %d operand(s) from stack.\n",
- n_args);
-
+ CON_Print(S_WARN_PREFIX "%X: Undefined script function number: (%X)\n",
+ thread->i_offset, func_num);
+ CON_Print(S_WARN_PREFIX "Removing %d operand(s) from stack.\n", n_args);
for (i = 0; i < n_args; i++) {
-
- SSTACK_Pop(thread->stack,
- NULL);
+ SSTACK_Pop(thread->stack, NULL);
}
} else {
-
FIXME_SHADOWED_result = sfunc(thread);
-
if (FIXME_SHADOWED_result != R_SUCCESS) {
- CON_Print(S_WARN_PREFIX
- "%X: Script function %d failed.\n",
- thread->i_offset,
- func_num);
+ CON_Print(S_WARN_PREFIX "%X: Script function %d failed.\n", thread->i_offset, func_num);
}
}
-
}
break;
-
- /* (ENTR) Enter the dragon */
+ // (ENTR) Enter the dragon
case 0x1A:
-
param1 = ys_read_u16_le(read_p, &read_p);
-
break;
-
- /* (?) Unknown */
+ // (?) Unknown
case 0x1B:
-
unhandled = 1;
break;
-
- /* (EXIT) End subscript */
+ // (EXIT) End subscript
case 0x1C:
-
result = SSTACK_Pop(thread->stack, &data);
-
if (result != STACK_SUCCESS) {
-
CON_Print("Script execution complete.");
thread->executing = 0;
} else {
-
thread->i_offset = data;
}
break;
- /*-------------------------------------------------------------*\
- * BRANCH INSTRUCTIONS
- \*-------------------------------------------------------------*/
+// BRANCH INSTRUCTIONS
- /* (JMP): Unconditional jump */
+ // (JMP): Unconditional jump
case 0x1D:
-
param1 = ys_read_u16_le(read_p, &read_p);
thread->i_offset = (unsigned long)param1;
-
break;
-
- /* (JNZP): Jump if nonzero + POP */
+ // (JNZP): Jump if nonzero + POP
case 0x1E:
-
param1 = ys_read_u16_le(read_p, &read_p);
-
SSTACK_Pop(thread->stack, &data);
if (data) {
thread->i_offset = (unsigned long)param1;
}
-
break;
-
- /* (JZP): Jump if zero + POP */
+ // (JZP): Jump if zero + POP
case 0x1F:
-
param1 = ys_read_u16_le(read_p, &read_p);
-
SSTACK_Pop(thread->stack, &data);
if (!data) {
thread->i_offset = (unsigned long)param1;
}
-
break;
-
- /* (JNZ): Jump if nonzero */
+ // (JNZ): Jump if nonzero
case 0x20:
-
param1 = ys_read_u16_le(read_p, &read_p);
-
SSTACK_Top(thread->stack, &data);
if (data) {
thread->i_offset = (unsigned long)param1;
}
-
break;
-
- /* (JZ): Jump if zero */
+ // (JZ): Jump if zero
case 0x21:
-
param1 = ys_read_u16_le(read_p, &read_p);
-
SSTACK_Top(thread->stack, &data);
if (!data) {
thread->i_offset = (unsigned long)param1;
}
-
break;
-
- /* (JMPR): Relative jump */
+ // (JMPR): Relative jump
case 0x57:
-
- /* ignored? */
+ // ignored?
ys_read_u16_le(read_p, &read_p);
ys_read_u16_le(read_p, &read_p);
-
iparam1 = (long)*read_p++;
-
thread->i_offset += iparam1;
break;
-
- /* (SWCH): Switch */
+ // (SWCH): Switch
case 0x22:
{
-
int n_switch;
unsigned int switch_num;
unsigned int switch_jmp;
@@ -609,132 +440,95 @@ int STHREAD_Run(R_SCRIPT_THREAD * thread, int instr_limit, int msec)
int case_found = 0;
SSTACK_Pop(thread->stack, &data);
-
n_switch = ys_read_u16_le(read_p, &read_p);
-
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);
-
- /* Found the specified case */
+ switch_num = ys_read_u16_le(read_p, &read_p);
+ switch_jmp = ys_read_u16_le(read_p, &read_p);
+ // Found the specified case
if (data == (SDataWord_T) switch_num) {
-
thread->i_offset = switch_jmp;
case_found = 1;
break;
}
}
- /* Jump to default case */
+ // Jump to default case
if (!case_found) {
-
- default_jmp =
- ys_read_u16_le(read_p, &read_p);
+ default_jmp = ys_read_u16_le(read_p, &read_p);
thread->i_offset = default_jmp;
}
-
}
break;
-
- /* (RJMP): Random branch */
+ // (RJMP): Random branch
case 0x24:
{
int n_branch;
unsigned int branch_wt;
unsigned int branch_jmp;
-
int rand_sel = 0;
int branch_found = 0;
- /* Ignored? */
+ // Ignored?
ys_read_u16_le(read_p, &read_p);
-
n_branch = ys_read_u16_le(read_p, &read_p);
-
for (i = 0; i < n_branch; i++) {
-
- branch_wt =
- ys_read_u16_le(read_p, &read_p);
- branch_jmp =
- ys_read_u16_le(read_p, &read_p);
-
+ branch_wt = ys_read_u16_le(read_p, &read_p);
+ branch_jmp = ys_read_u16_le(read_p, &read_p);
if (rand_sel == i) {
-
thread->i_offset = branch_jmp;
branch_found = 1;
break;
}
}
-
if (!branch_found) {
- CON_Print(S_ERROR_PREFIX
- "%X: Random jump target out of "
- "bounds.", thread->i_offset);
+ CON_Print(S_ERROR_PREFIX "%X: Random jump target out of " "bounds.", thread->i_offset);
}
-
}
break;
- /*-------------------------------------------------------------*\
- * MISC. INSTRUCTIONS
- \*-------------------------------------------------------------*/
+// MISC. INSTRUCTIONS
- /* (NEG) Negate stack by 2's complement */
+ // (NEG) Negate stack by 2's complement
case 0x25:
-
SSTACK_Pop(thread->stack, &data);
data = ~data;
data++;
SSTACK_Push(thread->stack, data);
-
break;
-
- /* (TSTZ) Test for zero */
+ // (TSTZ) Test for zero
case 0x26:
-
SSTACK_Pop(thread->stack, &data);
data = data ? 0 : 1;
SSTACK_Push(thread->stack, data);
-
break;
-
- /* (NOT) Binary not */
+ // (NOT) Binary not
case 0x27:
-
SSTACK_Pop(thread->stack, &data);
data = ~data;
SSTACK_Push(thread->stack, data);
-
break;
-
- /* (?) */
+ // (?)
case 0x28:
unhandled = 1;
printf("??? ");
read_p++;
ys_read_u16_le(read_p, &read_p);
break;
-
- /* (?) */
+ // (?)
case 0x29:
unhandled = 1;
printf("??? ");
read_p++;
ys_read_u16_le(read_p, &read_p);
break;
-
- /* (?) */
+ // (?)
case 0x2A:
unhandled = 1;
printf("??? ");
read_p++;
ys_read_u16_le(read_p, &read_p);
break;
-
- /* (?) */
+ // (?)
case 0x2B:
unhandled = 1;
printf("??? ");
@@ -742,264 +536,180 @@ int STHREAD_Run(R_SCRIPT_THREAD * thread, int instr_limit, int msec)
ys_read_u16_le(read_p, &read_p);
break;
- /*-------------------------------------------------------------*\
- * ARITHMETIC INSTRUCTIONS
- \*-------------------------------------------------------------*/
+// ARITHMETIC INSTRUCTIONS
- /* (ADD): Addition */
+ // (ADD): Addition
case 0x2C:
-
SSTACK_Pop(thread->stack, &param2);
SSTACK_Pop(thread->stack, &param1);
iparam2 = (long)param2;
iparam1 = (long)param1;
-
iresult = iparam1 + iparam2;
-
SSTACK_Push(thread->stack, (SDataWord_T) iresult);
break;
- /* (SUB): Subtraction */
+ // (SUB): Subtraction
case 0x2D:
-
SSTACK_Pop(thread->stack, &param2);
SSTACK_Pop(thread->stack, &param1);
iparam2 = (long)param2;
iparam1 = (long)param1;
-
iresult = iparam1 - iparam2;
-
SSTACK_Push(thread->stack, (SDataWord_T) iresult);
break;
-
- /* (MULT): Integer multiplication */
+ // (MULT): Integer multiplication
case 0x2E:
-
SSTACK_Pop(thread->stack, &param2);
SSTACK_Pop(thread->stack, &param1);
iparam2 = (long)param2;
iparam1 = (long)param1;
-
iresult = iparam1 * iparam2;
-
SSTACK_Push(thread->stack, (SDataWord_T) iresult);
break;
-
- /* (DIB): Integer division */
+ // (DIB): Integer division
case 0x2F:
-
SSTACK_Pop(thread->stack, &param2);
SSTACK_Pop(thread->stack, &param1);
iparam2 = (long)param2;
iparam1 = (long)param1;
-
iresult = iparam1 / iparam2;
-
SSTACK_Push(thread->stack, (SDataWord_T) iresult);
break;
-
- /* (MOD) Modulus */
+ // (MOD) Modulus
case 0x30:
-
SSTACK_Pop(thread->stack, &param2);
SSTACK_Pop(thread->stack, &param1);
iparam2 = (long)param2;
iparam1 = (long)param1;
-
iresult = iparam1 % iparam2;
-
SSTACK_Push(thread->stack, (SDataWord_T) iresult);
break;
-
- /* (EQU) Test equality */
+ // (EQU) Test equality
case 0x33:
-
SSTACK_Pop(thread->stack, &param2);
SSTACK_Pop(thread->stack, &param1);
iparam2 = (long)param2;
iparam1 = (long)param1;
-
data = (iparam1 == iparam2) ? 1 : 0;
-
SSTACK_Push(thread->stack, data);
break;
-
- /* (NEQU) Test inequality */
+ // (NEQU) Test inequality
case 0x34:
-
SSTACK_Pop(thread->stack, &param2);
SSTACK_Pop(thread->stack, &param1);
iparam2 = (long)param2;
iparam1 = (long)param1;
-
data = (iparam1 != iparam2) ? 1 : 0;
-
SSTACK_Push(thread->stack, data);
break;
-
- /* (GRT) Test Greater-than */
+ // (GRT) Test Greater-than
case 0x35:
-
SSTACK_Pop(thread->stack, &param2);
SSTACK_Pop(thread->stack, &param1);
iparam2 = (long)param2;
iparam1 = (long)param1;
-
data = (iparam1 > iparam2) ? 1 : 0;
-
SSTACK_Push(thread->stack, data);
break;
-
- /* (LST) Test Less-than */
+ // (LST) Test Less-than
case 0x36:
-
SSTACK_Pop(thread->stack, &param2);
SSTACK_Pop(thread->stack, &param1);
iparam2 = (long)param2;
iparam1 = (long)param1;
-
data = (iparam1 < iparam2) ? 1 : 0;
-
SSTACK_Push(thread->stack, data);
break;
-
- /* (GRTE) Test Greater-than or Equal to */
+ // (GRTE) Test Greater-than or Equal to
case 0x37:
-
SSTACK_Pop(thread->stack, &param2);
SSTACK_Pop(thread->stack, &param1);
iparam2 = (long)param2;
iparam1 = (long)param1;
-
data = (iparam1 >= iparam2) ? 1 : 0;
-
SSTACK_Push(thread->stack, data);
break;
-
- /* (LSTE) Test Less-than or Equal to */
+ // (LSTE) Test Less-than or Equal to
case 0x38:
-
SSTACK_Pop(thread->stack, &param2);
SSTACK_Pop(thread->stack, &param1);
iparam2 = (long)param2;
iparam1 = (long)param1;
-
data = (iparam1 <= iparam2) ? 1 : 0;
-
SSTACK_Push(thread->stack, data);
break;
-
- /* (SHR): Arithmetic binary shift right */
+ // (SHR): Arithmetic binary shift right
case 0x3F:
-
SSTACK_Pop(thread->stack, &param2);
SSTACK_Pop(thread->stack, &param1);
-
iparam2 = (long)param2;
-
- /* Preserve most significant bit */
- data =
- (0x01 << ((sizeof param1 * CHAR_BIT) -
- 1)) & param1;
-
+ // Preserve most significant bit
+ data = (0x01 << ((sizeof param1 * CHAR_BIT) - 1)) & param1;
for (i = 0; i < (int)iparam2; i++) {
param1 >>= 1;
param1 |= data;
}
-
SSTACK_Push(thread->stack, param1);
break;
- /*-------------------------------------------------------------*\
- * BITWISE INSTRUCTIONS
- \*-------------------------------------------------------------*/
+// BITWISE INSTRUCTIONS
- /* (SHL) Binary shift left */
+ // (SHL) Binary shift left
case 0x40:
-
SSTACK_Pop(thread->stack, &param2);
SSTACK_Pop(thread->stack, &param1);
-
param1 <<= param2;
-
SSTACK_Push(thread->stack, param1);
break;
-
- /* (AND) Binary AND */
+ // (AND) Binary AND
case 0x41:
-
SSTACK_Pop(thread->stack, &param2);
SSTACK_Pop(thread->stack, &param1);
-
param1 &= param2;
-
SSTACK_Push(thread->stack, param1);
break;
-
- /* (OR) Binary OR */
+ // (OR) Binary OR
case 0x42:
-
SSTACK_Pop(thread->stack, &param2);
SSTACK_Pop(thread->stack, &param1);
-
param1 |= param2;
-
SSTACK_Push(thread->stack, param1);
break;
-
- /* (XOR) Binary XOR */
+ // (XOR) Binary XOR
case 0x43:
-
SSTACK_Pop(thread->stack, &param2);
SSTACK_Pop(thread->stack, &param1);
-
param1 ^= param2;
-
SSTACK_Push(thread->stack, param1);
break;
- /*-------------------------------------------------------------*\
- * BOOLEAN LOGIC INSTRUCTIONS
- \*-------------------------------------------------------------*/
+// BOOLEAN LOGIC INSTRUCTIONS
- /* (LAND): Logical AND */
+ // (LAND): Logical AND
case 0x44:
-
SSTACK_Pop(thread->stack, &param2);
SSTACK_Pop(thread->stack, &param1);
-
data = (param1 && param2) ? 1 : 0;
-
SSTACK_Push(thread->stack, data);
break;
-
- /* (LOR): Logical OR */
+ // (LOR): Logical OR
case 0x45:
-
SSTACK_Pop(thread->stack, &param2);
SSTACK_Pop(thread->stack, &param1);
-
data = (param1 || param2) ? 1 : 0;
-
SSTACK_Push(thread->stack, data);
break;
-
- /* (LXOR): Logical XOR */
+ // (LXOR): Logical XOR
case 0x46:
-
SSTACK_Pop(thread->stack, &param2);
SSTACK_Pop(thread->stack, &param1);
-
data = ((param1) ? !(param2) : !!(param2));
-
SSTACK_Push(thread->stack, data);
break;
- /*-------------------------------------------------------------*\
- * GAME INSTRUCTIONS
- \*-------------------------------------------------------------*/
+// GAME INSTRUCTIONS
- /* (DLGP): Play Character Dialogue */
+ // (DLGP): Play Character Dialogue
case 0x53:
{
int n_voices;
@@ -1007,56 +717,36 @@ int STHREAD_Run(R_SCRIPT_THREAD * thread, int instr_limit, int msec)
int voice_rn;
n_voices = *read_p++;
- param1 =
- (SDataWord_T) ys_read_u16_le(read_p,
- &read_p);
-
- /* ignored ? */
+ param1 = (SDataWord_T) ys_read_u16_le(read_p, &read_p);
+ // ignored ?
*read_p++;
ys_read_u16_le(read_p, &read_p);
a_index = ACTOR_GetActorIndex(param1);
-
if (a_index < 0) {
- CON_Print(S_WARN_PREFIX
- "%X: DLGP Actor id not found.",
- thread->i_offset);
+ CON_Print(S_WARN_PREFIX "%X: DLGP Actor id not found.", thread->i_offset);
}
for (i = 0; i < n_voices; i++) {
-
SSTACK_Pop(thread->stack, &data);
-
if (a_index < 0)
continue;
-
if (!ScriptModule.voice_lut_present) {
voice_rn = -1;
} else {
- voice_rn =
- ScriptModule.
- current_script->voice->
- voices[data];
+ voice_rn = ScriptModule. current_script->voice->voices[data];
}
-
- ACTOR_Speak(a_index,
- ScriptModule.current_script->diag->
- str[data], voice_rn, &thread->sem);
-
+ ACTOR_Speak(a_index, ScriptModule.current_script->diag-> str[data], voice_rn, &thread->sem);
}
-
}
break;
-
- /* (DLGS): Initialize dialogue interface */
+ // (DLGS): Initialize dialogue interface
case 0x54:
break;
-
- /* (DLGX): Run dialogue interface */
+ // (DLGX): Run dialogue interface
case 0x55:
break;
-
- /* (DLGO): Add a dialogue option to interface */
+ // (DLGO): Add a dialogue option to interface
case 0x56:
{
int FIXME_SHADOWED_param1;
@@ -1066,51 +756,35 @@ int STHREAD_Run(R_SCRIPT_THREAD * thread, int instr_limit, int msec)
printf("DLGO | ");
FIXME_SHADOWED_param1 = *read_p++;
FIXME_SHADOWED_param2 = *read_p++;
-
printf("%02X %02X ", FIXME_SHADOWED_param1, FIXME_SHADOWED_param2);
if (FIXME_SHADOWED_param2 > 0) {
- FIXME_SHADOWED_param3 =
- ys_read_u16_le(read_p, &read_p);
-
+ FIXME_SHADOWED_param3 = ys_read_u16_le(read_p, &read_p);
printf("%04X", FIXME_SHADOWED_param3);
}
}
break;
- /*-------------------------------------------------------------*\
- * End instruction list
- \*-------------------------------------------------------------*/
+// End instruction list
default:
- CON_Print(S_ERROR_PREFIX
- "%X: Invalid opcode encountered: " "(%X).\n",
- thread->i_offset, in_char);
+ CON_Print(S_ERROR_PREFIX "%X: Invalid opcode encountered: " "(%X).\n", thread->i_offset, in_char);
thread->executing = 0;
-
break;
+ }
- } /* end switch( in_char ) */
-
- /* Set instruction offset only if a previous instruction didn't
- * branch */
+ // Set instruction offset only if a previous instruction didn't branch
if (saved_offset == thread->i_offset) {
-
thread->i_offset = GetReadOffset(read_p);
}
-
if (unhandled) {
-
- CON_Print(S_ERROR_PREFIX "%X: Unhandled opcode.\n",
- thread->i_offset);
+ CON_Print(S_ERROR_PREFIX "%X: Unhandled opcode.\n", thread->i_offset);
thread->executing = 0;
}
-
if (thread->executing && debug_print) {
SDEBUG_PrintInstr(thread);
}
-
}
return R_SUCCESS;
diff --git a/saga/sthread.h b/saga/sthread.h
index e796da0a95..f6b77f2544 100644
--- a/saga/sthread.h
+++ b/saga/sthread.h
@@ -20,14 +20,8 @@
* $Header$
*
*/
-/*
- Description:
-
- Scripting module thread management component header file
-
- Notes:
-*/
+// Scripting module thread management component header file
#ifndef SAGA_STHREAD_H__
#define SAGA_STHREAD_H__
@@ -46,16 +40,15 @@ struct R_SCRIPT_THREAD_tag {
int executing;
int sleep_time;
- int ep_num; /* Entrypoint number */
- unsigned long ep_offset; /* Entrypoint offset */
- unsigned long i_offset; /* Instruction offset */
+ int ep_num; // Entrypoint number
+ unsigned long ep_offset; // Entrypoint offset
+ unsigned long i_offset; // Instruction offset
R_SEMAPHORE sem;
-
SSTACK stack;
};
-R_SCRIPT_THREAD *STHREAD_Create(void);
+R_SCRIPT_THREAD *STHREAD_Create();
int STHREAD_Destroy(R_SCRIPT_THREAD *thread);
int STHREAD_SetEntrypoint(R_SCRIPT_THREAD *thread, int ep_num);
int STHREAD_Execute(R_SCRIPT_THREAD *thread, int ep_num);
@@ -66,4 +59,4 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread);
} // End of namespace Saga
-#endif /* SAGA_STHREAD_H__ */
+#endif
diff --git a/saga/sys_interface.h b/saga/sys_interface.h
index 815cb29809..6658e80523 100644
--- a/saga/sys_interface.h
+++ b/saga/sys_interface.h
@@ -20,6 +20,7 @@
* $Header$
*
*/
+
#ifndef REINHERIT_SYSINTERFACE_H
#define REINHERIT_SYSINTERFACE_H
@@ -32,4 +33,4 @@ namespace Saga {
} // End of namespace Saga
-#endif /* REINHERIT_SYSTYPES_H */
+#endif
diff --git a/saga/sysinput.cpp b/saga/sysinput.cpp
index f68ae8d459..772a8352e0 100644
--- a/saga/sysinput.cpp
+++ b/saga/sysinput.cpp
@@ -20,13 +20,10 @@
* $Header$
*
*/
+
#include "reinherit.h"
#include <SDL.h>
-
-/*
- * Uses the following modules:
-\*--------------------------------------------------------------------------*/
#include "actor_mod.h"
#include "console_mod.h"
#include "interface_mod.h"
@@ -36,21 +33,14 @@
namespace Saga {
-/*
- * Begin module component
-\*--------------------------------------------------------------------------*/
-
-int SYSINPUT_Init(void)
-{
-
+int SYSINPUT_Init() {
SDL_EnableUNICODE(1);
SDL_EnableKeyRepeat(200, 30);
return R_SUCCESS;
}
-int SYSINPUT_ProcessInput(void)
-{
+int SYSINPUT_ProcessInput() {
SDL_Event sdl_event;
int mouse_x, mouse_y;
@@ -62,128 +52,92 @@ int SYSINPUT_ProcessInput(void)
imouse_pt.y = mouse_y;
while (SDL_PollEvent(&sdl_event)) {
-
int in_char;
switch (sdl_event.type) {
-
case SDL_KEYDOWN:
-
if (CON_IsActive()) {
-
in_char = sdl_event.key.keysym.sym;
-
switch (sdl_event.key.keysym.sym) {
-
case SDLK_BACKQUOTE:
CON_Deactivate();
break;
-
case SDLK_PAGEUP:
CON_PageUp();
break;
-
case SDLK_PAGEDOWN:
CON_PageDown();
break;
-
case SDLK_UP:
case SDLK_KP8:
CON_CmdUp();
break;
-
case SDLK_DOWN:
case SDLK_KP2:
CON_CmdDown();
break;
-
default:
-
if ((sdl_event.key.keysym.
unicode & 0xFF80) == 0) {
-
- in_char =
- sdl_event.key.keysym.
- unicode & 0x7F;
+ in_char = sdl_event.key.keysym. unicode & 0x7F;
if (in_char) {
CON_Type(in_char);
}
} else {
- R_printf(R_STDOUT,
- "Ignored UNICODE character.\n");
+ R_printf(R_STDOUT, "Ignored UNICODE character.\n");
}
-
break;
}
-
break;
}
switch (sdl_event.key.keysym.sym) {
-
case SDLK_BACKQUOTE:
CON_Activate();
break;
-
case SDLK_q:
R_printf(R_STDOUT, "Quit key pressed.\n");
- /*goto done; */
+ //goto done;
break;
-
case SDLK_r:
INTERFACE_Draw();
break;
-
case SDLK_F1:
RENDER_ToggleFlag(RF_SHOW_FPS);
break;
-
case SDLK_F2:
RENDER_ToggleFlag(RF_PALETTE_TEST);
break;
-
case SDLK_F3:
RENDER_ToggleFlag(RF_TEXT_TEST);
break;
-
case SDLK_F4:
RENDER_ToggleFlag(RF_OBJECTMAP_TEST);
break;
-
case SDLK_TAB:
STHREAD_DebugStep();
break;
-
- /* Actual game keys */
-
+ // Actual game keys
case SDLK_SPACE:
-
ACTOR_SkipDialogue();
break;
-
case SDLK_PAUSE:
case SDLK_p:
RENDER_ToggleFlag(RF_RENDERPAUSE);
break;
-
case SDLK_ESCAPE:
- /* Skip to next scene skip target */
+ // Skip to next scene skip target
SCENE_Skip();
break;
-
default:
break;
}
-
break;
-
case SDL_KEYUP:
break;
-
case SDL_MOUSEBUTTONDOWN:
INTERFACE_Update(&imouse_pt, UPDATE_MOUSECLICK);
break;
-
default:
break;
}
@@ -192,25 +146,19 @@ int SYSINPUT_ProcessInput(void)
return R_SUCCESS;
}
-int SYSINPUT_GetMousePos(int *mouse_x, int *mouse_y)
-{
-
+int SYSINPUT_GetMousePos(int *mouse_x, int *mouse_y) {
SDL_GetMouseState(mouse_x, mouse_y);
return R_SUCCESS;
}
-int SYSINPUT_HideMouse(void)
-{
-
+int SYSINPUT_HideMouse() {
SDL_ShowCursor(SDL_DISABLE);
return R_SUCCESS;
}
-int SYSINPUT_ShowMouse(void)
-{
-
+int SYSINPUT_ShowMouse() {
SDL_ShowCursor(SDL_ENABLE);
return R_SUCCESS;
diff --git a/saga/systimer.cpp b/saga/systimer.cpp
index ce383ebda3..f8b926dbc5 100644
--- a/saga/systimer.cpp
+++ b/saga/systimer.cpp
@@ -20,45 +20,35 @@
* $Header$
*
*/
+
#include "reinherit.h"
#include <SDL.h>
-/*
- * Begin module
-\*--------------------------------------------------------------------------*/
#include "systimer.h"
namespace Saga {
struct R_SYSTIMER {
-
int t_running;
-
unsigned long t_interval;
void *t_param;
-
R_SYSTIMER_CALLBACK t_callback_f;
SDL_TimerID t_sdl_timerid;
};
struct R_SYSTIMER_DATA {
-
- int initialized;
-
- Uint32 t_start_ticks;
-
- Uint32 t_current_ticks;
- Uint32 t_previous_ticks;
-
+ int initialized;
+ uint32 t_start_ticks;
+ uint32 t_current_ticks;
+ uint32 t_previous_ticks;
};
static R_SYSTIMER_DATA R_TimerData;
-static Uint32 SYSTIMER_Callback(Uint32 interval, void *param);
+static Uint32 SYSTIMER_Callback(Uint32 interval, void *param);
-int SYSTIMER_InitMSCounter(void)
-{
+int SYSTIMER_InitMSCounter() {
if (R_TimerData.initialized) {
return R_FAILURE;
diff --git a/saga/systimer.h b/saga/systimer.h
index 7ddc1a260f..5861ba7463 100644
--- a/saga/systimer.h
+++ b/saga/systimer.h
@@ -29,16 +29,15 @@ typedef void (*R_SYSTIMER_CALLBACK) (unsigned long, void *);
struct R_SYSTIMER;
-int SYSTIMER_InitMSCounter(void);
-unsigned long SYSTIMER_ReadMSCounter(void);
-
-int SYSTIMER_ResetMSCounter(void);
+int SYSTIMER_InitMSCounter();
+unsigned long SYSTIMER_ReadMSCounter();
+int SYSTIMER_ResetMSCounter();
int SYSTIMER_Sleep(uint16 msec);
int SYSTIMER_CreateTimer(R_SYSTIMER **,
- unsigned long, void *, R_SYSTIMER_CALLBACK);
+unsigned long, void *, R_SYSTIMER_CALLBACK);
int SYSTIMER_DestroyTimer(R_SYSTIMER *);
} // End of namespace Saga
-#endif /* SAGA_SYSTIMER_H__ */
+#endif
diff --git a/saga/text.cpp b/saga/text.cpp
index 80367169c9..958a9ca9f3 100644
--- a/saga/text.cpp
+++ b/saga/text.cpp
@@ -20,43 +20,25 @@
* $Header$
*
*/
-/*
- Description:
-
- Text / dialogue display management module
- Notes:
-*/
+// Text / dialogue display management module
#include "reinherit.h"
#include "yslib.h"
-/*
- * Uses the following modules:
-\*--------------------------------------------------------------------------*/
#include "font_mod.h"
-/*
- * Begin module
-\*--------------------------------------------------------------------------*/
#include "text_mod.h"
#include "text.h"
namespace Saga {
-int
-TEXT_Draw(int font_id,
- R_SURFACE * ds,
- const char *string,
- int text_x, int text_y, int color, int effect_color, int flags)
-{
-
+int TEXT_Draw(int font_id, R_SURFACE *ds, const char *string, int text_x, int text_y, int color,
+ int effect_color, int flags) {
int string_w;
int string_len;
-
int fit_w;
-
const char *start_p;
const char *search_p;
const char *measure_p;
@@ -66,17 +48,14 @@ TEXT_Draw(int font_id,
const char *end_p;
int h;
int wc;
-
int w_total;
int len_total;
string_len = strlen(string);
if (flags & FONT_CENTERED) {
-
- /* Text is centered... format output */
-
- /* Enforce minimum and maximum center points for centered text */
+ // Text is centered... format output
+ // Enforce minimum and maximum center points for centered text
if (text_x < R_TEXT_CENTERLIMIT) {
text_x = R_TEXT_CENTERLIMIT;
}
@@ -86,37 +65,28 @@ TEXT_Draw(int font_id,
}
if (text_x < (R_TEXT_MARGIN * 2)) {
- /* Text can't be centered if it's too close to the margin */
+ // Text can't be centered if it's too close to the margin
return R_FAILURE;
}
- string_w =
- FONT_GetStringWidth(font_id, string, string_len, flags);
+ string_w = FONT_GetStringWidth(font_id, string, string_len, flags);
if (text_x < (ds->buf_w / 2)) {
- /* Fit to right side */
+ // Fit to right side
fit_w = (text_x - R_TEXT_MARGIN) * 2;
} else {
- /* Fit to left side */
+ // Fit to left side
fit_w = ((ds->buf_w - R_TEXT_MARGIN) - text_x) * 2;
}
if (fit_w >= string_w) {
-
- /* Entire string fits, draw it */
+ // Entire string fits, draw it
text_x = text_x - (string_w / 2);
-
- FONT_Draw(font_id,
- ds,
- string,
- string_len,
- text_x, text_y, color, effect_color, flags);
-
+ FONT_Draw(font_id, ds, string, string_len, text_x, text_y, color, effect_color, flags);
return R_SUCCESS;
}
- /* String won't fit on one line ... */
-
+ // String won't fit on one line
h = FONT_GetHeight(font_id);
w_total = 0;
len_total = 0;
@@ -128,81 +98,56 @@ TEXT_Draw(int font_id,
end_p = string + string_len;
for (;;) {
-
found_p = strchr(search_p, ' ');
-
if (found_p == NULL) {
- /* Ran to the end of the buffer */
+ // Ran to the end of the buffer
len = end_p - measure_p;
} else {
len = found_p - measure_p;
}
- w = FONT_GetStringWidth(font_id, measure_p, len,
- flags);
+ w = FONT_GetStringWidth(font_id, measure_p, len, flags);
measure_p = found_p;
if ((w_total + w) > fit_w) {
- /* This word won't fit */
+ // This word won't fit
if (wc == 0) {
- /* The first word in the line didn't fit. abort */
+ // The first word in the line didn't fit. abort
return R_SUCCESS;
}
- /* Wrap what we've got and restart */
- FONT_Draw(font_id,
- ds,
- start_p,
- len_total,
- text_x - (w_total / 2),
- text_y, color, effect_color, flags);
-
+ // Wrap what we've got and restart
+ FONT_Draw(font_id, ds, start_p, len_total, text_x - (w_total / 2), text_y, color,
+ effect_color, flags);
text_y += h + R_TEXT_LINESPACING;
w_total = 0;
len_total = 0;
wc = 0;
measure_p = search_p;
start_p = search_p;
-
} else {
- /* Word will fit ok */
+ // Word will fit ok
w_total += w;
len_total += len;
wc++;
-
if (found_p == NULL) {
- /* Since word hit NULL but fit, we are done */
- FONT_Draw(font_id,
- ds,
- start_p,
- len_total,
- text_x - (w_total / 2),
- text_y,
- color, effect_color, flags);
-
+ // Since word hit NULL but fit, we are done
+ FONT_Draw(font_id, ds, start_p, len_total, text_x - (w_total / 2), text_y, color,
+ effect_color, flags);
return R_SUCCESS;
}
-
search_p = measure_p + 1;
}
- } /* End for (;;) */
-
+ }
} else {
-
- /* Text is not centered; No formatting required */
-
- FONT_Draw(font_id,
- ds,
- string,
- string_len, text_x, text_y, color, effect_color, flags);
-
+ // Text is not centered; No formatting required
+ FONT_Draw(font_id, ds, string, string_len, text_x, text_y, color, effect_color, flags);
}
return R_SUCCESS;
}
-R_TEXTLIST *TEXT_CreateList(void)
-{
+R_TEXTLIST *TEXT_CreateList() {
R_TEXTLIST *new_textlist;
new_textlist = (R_TEXTLIST *)malloc(sizeof *new_textlist);
@@ -221,8 +166,7 @@ R_TEXTLIST *TEXT_CreateList(void)
return new_textlist;
}
-void TEXT_ClearList(R_TEXTLIST * tlist)
-{
+void TEXT_ClearList(R_TEXTLIST *tlist) {
if (tlist != NULL) {
ys_dll_delete_all(tlist->list);
}
@@ -230,8 +174,7 @@ void TEXT_ClearList(R_TEXTLIST * tlist)
return;
}
-void TEXT_DestroyList(R_TEXTLIST * tlist)
-{
+void TEXT_DestroyList(R_TEXTLIST *tlist) {
if (tlist != NULL) {
ys_dll_destroy(tlist->list);
}
@@ -240,52 +183,34 @@ void TEXT_DestroyList(R_TEXTLIST * tlist)
return;
}
-int TEXT_DrawList(R_TEXTLIST * textlist, R_SURFACE * ds)
-{
-
+int TEXT_DrawList(R_TEXTLIST *textlist, R_SURFACE *ds) {
R_TEXTLIST_ENTRY *entry_p;
YS_DL_NODE *walk_p;
assert((textlist != NULL) && (ds != NULL));
- for (walk_p = ys_dll_head(textlist->list);
- walk_p != NULL; walk_p = ys_dll_next(walk_p)) {
-
+ for (walk_p = ys_dll_head(textlist->list); walk_p != NULL; walk_p = ys_dll_next(walk_p)) {
entry_p = (R_TEXTLIST_ENTRY *)ys_dll_get_data(walk_p);
-
if (entry_p->display != 0) {
-
- TEXT_Draw(entry_p->font_id,
- ds,
- entry_p->string,
- entry_p->text_x,
- entry_p->text_y,
- entry_p->color,
- entry_p->effect_color, entry_p->flags);
+ TEXT_Draw(entry_p->font_id, ds, entry_p->string, entry_p->text_x, entry_p->text_y, entry_p->color,
+ entry_p->effect_color, entry_p->flags);
}
}
return R_SUCCESS;
}
-int TEXT_ProcessList(R_TEXTLIST * textlist, long ms)
-{
+int TEXT_ProcessList(R_TEXTLIST *textlist, long ms) {
R_TEXTLIST_ENTRY *entry_p;
YS_DL_NODE *walk_p;
YS_DL_NODE *temp_p;
- for (walk_p = ys_dll_head(textlist->list);
- walk_p != NULL; walk_p = temp_p) {
-
+ for (walk_p = ys_dll_head(textlist->list); walk_p != NULL; walk_p = temp_p) {
temp_p = ys_dll_next(walk_p);
-
entry_p = (R_TEXTLIST_ENTRY *)ys_dll_get_data(walk_p);
-
if (entry_p->flags & TEXT_TIMEOUT) {
-
entry_p->time -= ms;
if (entry_p->time <= 0) {
-
ys_dll_delete(walk_p);
}
}
@@ -295,21 +220,17 @@ int TEXT_ProcessList(R_TEXTLIST * textlist, long ms)
}
-R_TEXTLIST_ENTRY *TEXT_AddEntry(R_TEXTLIST * textlist,
- R_TEXTLIST_ENTRY * entry)
-{
+R_TEXTLIST_ENTRY *TEXT_AddEntry(R_TEXTLIST *textlist, R_TEXTLIST_ENTRY *entry) {
YS_DL_NODE *new_node = NULL;
if (entry != NULL) {
- new_node =
- ys_dll_add_tail(textlist->list, entry, sizeof *entry);
+ new_node = ys_dll_add_tail(textlist->list, entry, sizeof *entry);
}
return (new_node != NULL) ? (R_TEXTLIST_ENTRY *)new_node->data : NULL;
}
-int TEXT_SetDisplay(R_TEXTLIST_ENTRY * entry, int val)
-{
+int TEXT_SetDisplay(R_TEXTLIST_ENTRY *entry, int val) {
if (entry != NULL) {
entry->display = !!val;
return R_SUCCESS;
@@ -318,17 +239,14 @@ int TEXT_SetDisplay(R_TEXTLIST_ENTRY * entry, int val)
return R_FAILURE;
}
-int TEXT_DeleteEntry(R_TEXTLIST * textlist, R_TEXTLIST_ENTRY * entry)
-{
+int TEXT_DeleteEntry(R_TEXTLIST *textlist, R_TEXTLIST_ENTRY *entry) {
YS_DL_NODE *walk_p;
if (entry == NULL) {
return R_FAILURE;
}
- for (walk_p = ys_dll_head(textlist->list);
- walk_p != NULL; walk_p = ys_dll_next(walk_p)) {
-
+ for (walk_p = ys_dll_head(textlist->list); walk_p != NULL; walk_p = ys_dll_next(walk_p)) {
if (entry == ys_dll_get_data(walk_p)) {
ys_dll_delete(walk_p);
break;
diff --git a/saga/text.h b/saga/text.h
index 49adac7053..ddd33fa358 100644
--- a/saga/text.h
+++ b/saga/text.h
@@ -20,14 +20,8 @@
* $Header$
*
*/
-/*
- Description:
-
- Text / dialogue display management module private header
-
- Notes:
-*/
+// Text / dialogue display management module private header
#ifndef SAGA_TEXT_H__
#define SAGA_TEXT_H__
@@ -43,4 +37,4 @@ struct R_TEXTLIST_tag {
};
} // End of namespace Saga
-#endif /* SAGA_TEXT_H__ */
+#endif
diff --git a/saga/text_mod.h b/saga/text_mod.h
index 27893fda12..1e54d3c8ba 100644
--- a/saga/text_mod.h
+++ b/saga/text_mod.h
@@ -20,13 +20,8 @@
* $Header$
*
*/
-/*
- Description:
-
- Text / dialogue display management module public header
- Notes:
-*/
+// Text / dialogue display management module public header
#ifndef SAGA_TEXT_MOD_H_
#define SAGA_TEXT_MOD_H_
@@ -50,23 +45,22 @@ struct R_TEXTLIST_ENTRY {
int font_id;
long time;
const char *string;
-
R_TEXTLIST_ENTRY() { memset(this, 0, sizeof(*this)); }
};
typedef struct R_TEXTLIST_tag R_TEXTLIST;
-R_TEXTLIST *TEXT_CreateList(void);
+R_TEXTLIST *TEXT_CreateList();
void TEXT_DestroyList(R_TEXTLIST *textlist);
void TEXT_ClearList(R_TEXTLIST *textlist);
int TEXT_DrawList(R_TEXTLIST *textlist, R_SURFACE *ds);
R_TEXTLIST_ENTRY *TEXT_AddEntry(R_TEXTLIST *textlist, R_TEXTLIST_ENTRY *entry);
int TEXT_DeleteEntry(R_TEXTLIST *textlist, R_TEXTLIST_ENTRY *entry);
int TEXT_SetDisplay(R_TEXTLIST_ENTRY *entry, int val);
-int TEXT_Draw(int font_id, R_SURFACE *ds, const char *string, int text_x,
- int text_y, int color, int effect_color, int flags);
+int TEXT_Draw(int font_id, R_SURFACE *ds, const char *string, int text_x, int text_y, int color,
+ int effect_color, int flags);
int TEXT_ProcessList(R_TEXTLIST *textlist, long ms);
} // End of namespace Saga
-#endif /* SAGA_TEXT_MOD_H_ */
+#endif
diff --git a/saga/transitions.cpp b/saga/transitions.cpp
index 1e267de599..c97b3a46fa 100644
--- a/saga/transitions.cpp
+++ b/saga/transitions.cpp
@@ -20,13 +20,8 @@
* $Header$
*
*/
-/*
- Description:
-
- Background transition routines
- Notes:
-*/
+//Background transition routines
#include <stdio.h>
#include <stdlib.h>
@@ -37,17 +32,11 @@
namespace Saga {
-int
-TRANSITION_Dissolve(byte * dst_img,
- int dst_w,
- int dst_h,
- int dst_p, const byte * src_img, int src_p, int flags, double percent)
-{
+int TRANSITION_Dissolve(byte *dst_img, int dst_w, int dst_h, int dst_p, const byte *src_img,
+ int src_p, int flags, double percent) {
#define XOR_MASK 0xB400;
-
int pixelcount = dst_w * dst_h;
int seqlimit = (int)(65535 * percent);
-
int seq = 1;
int i;
@@ -56,7 +45,6 @@ TRANSITION_Dissolve(byte * dst_img,
YS_IGNORE_PARAM(dst_p);
for (i = 0; i < seqlimit; i++) {
-
if (seq & 1) {
seq = (seq >> 1) ^ XOR_MASK;
} else {
@@ -70,9 +58,7 @@ TRANSITION_Dissolve(byte * dst_img,
if (seq >= pixelcount) {
continue;
} else {
-
dst_img[seq] = src_img[seq];
-
}
}
diff --git a/saga/ys_binread.cpp b/saga/ys_binread.cpp
index ddc028a43a..021a0a8436 100644
--- a/saga/ys_binread.cpp
+++ b/saga/ys_binread.cpp
@@ -20,36 +20,29 @@
* $Header$
*
*/
+
#include <stdio.h>
#include "yslib.h"
namespace Saga {
-void
-ys_read_4cc(char *fourcc,
- const unsigned char *data_p, const unsigned char **data_pp)
-{
+void ys_read_4cc(char *fourcc, const unsigned char *data_p, const unsigned char **data_pp) {
fourcc[0] = (char)data_p[0];
fourcc[1] = (char)data_p[1];
fourcc[2] = (char)data_p[2];
fourcc[3] = (char)data_p[3];
if (data_pp) {
-
*data_pp = data_p + 4;
}
return;
}
-unsigned int
-ys_read_u8(const unsigned char *data_p, const unsigned char **data_pp)
-/*---------------------------------------------------------------------------*\
- * Reads an unsigned 8 bit integer in from the array of bytes pointed to by
- * 'data_p'. If 'data_pp' is not null, it will set '*data_pp' to point past
- * the integer read.
-\*---------------------------------------------------------------------------*/
-{
+// Reads an unsigned 8 bit integer in from the array of bytes pointed to by
+// 'data_p'. If 'data_pp' is not null, it will set '*data_pp' to point past
+// the integer read.
+unsigned int ys_read_u8(const unsigned char *data_p, const unsigned char **data_pp) {
unsigned int u8 = *data_p;
if (data_pp != NULL) {
@@ -59,13 +52,10 @@ ys_read_u8(const unsigned char *data_p, const unsigned char **data_pp)
return u8;
}
-int ys_read_s8(const unsigned char *data_p, const unsigned char **data_pp)
-/*---------------------------------------------------------------------------*\
- * Reads a signed 8 bit integer in two's complement notation from the array
- * of bytes pointed to by 'data_p'. If 'data_pp' is not null, it will set
- * '*data_pp' to point past the integer read.
-\*---------------------------------------------------------------------------*/
-{
+// Reads a signed 8 bit integer in two's complement notation from the array
+// of bytes pointed to by 'data_p'. If 'data_pp' is not null, it will set
+//'*data_pp' to point past the integer read.
+int ys_read_s8(const unsigned char *data_p, const unsigned char **data_pp) {
unsigned int u8 = *data_p;
int s8;
@@ -83,14 +73,10 @@ int ys_read_s8(const unsigned char *data_p, const unsigned char **data_pp)
return s8;
}
-unsigned int
-ys_read_u16_be(const unsigned char *data_p, const unsigned char **data_pp)
-/*---------------------------------------------------------------------------*\
- * Reads an unsigned 16 bit integer in big-endian format from the array of
- * bytes pointed to by 'data_p'. If 'data_pp' is not null, it will set
- * '*data_pp' to point past the integer read.
-\*---------------------------------------------------------------------------*/
-{
+// Reads a signed 8 bit integer in two's complement notation from the array
+// of bytes pointed to by 'data_p'. If 'data_pp' is not null, it will set
+// '*data_pp' to point past the integer read.
+unsigned int ys_read_u16_be(const unsigned char *data_p, const unsigned char **data_pp) {
unsigned int u16_be = ((unsigned int)data_p[0] << 8) | data_p[1];
if (data_pp != NULL) {
@@ -100,14 +86,10 @@ ys_read_u16_be(const unsigned char *data_p, const unsigned char **data_pp)
return u16_be;
}
-unsigned int
-ys_read_u16_le(const unsigned char *data_p, const unsigned char **data_pp)
-/*---------------------------------------------------------------------------*\
- * Reads an unsigned 16 bit integer in little-endian format from the array of
- * bytes pointed to by 'data_p'. If 'data_pp' is not null, it will set
- * '*data_pp' to point past the integer read.
-\*---------------------------------------------------------------------------*/
-{
+// Reads an unsigned 16 bit integer in little-endian format from the array of
+// bytes pointed to by 'data_p'. If 'data_pp' is not null, it will set
+// '*data_pp' to point past the integer read.
+unsigned int ys_read_u16_le(const unsigned char *data_p, const unsigned char **data_pp) {
unsigned int u16_le = ((unsigned int)data_p[1] << 8) | data_p[0];
if (data_pp != NULL) {
@@ -117,14 +99,10 @@ ys_read_u16_le(const unsigned char *data_p, const unsigned char **data_pp)
return u16_le;
}
-int ys_read_s16_be(const unsigned char *data_p, const unsigned char **data_pp)
-/*---------------------------------------------------------------------------*\
- * Reads a signed 16 bit integer in big-endian, 2's complement format from
- * the array of bytes pointed to by 'data_p'.
- * If 'data_pp' is not null, it will set '*data_pp' to point past the integer
- * read.
-\*---------------------------------------------------------------------------*/
-{
+// Reads a signed 16 bit integer in big-endian, 2's complement format from
+// the array of bytes pointed to by 'data_p'.
+// If 'data_pp' is not null, it will set '*data_pp' to point past the integer read.
+int ys_read_s16_be(const unsigned char *data_p, const unsigned char **data_pp) {
unsigned int u16_be = ((unsigned int)data_p[0] << 8) | data_p[1];
int s16_be;
@@ -142,14 +120,10 @@ int ys_read_s16_be(const unsigned char *data_p, const unsigned char **data_pp)
return s16_be;
}
-int ys_read_s16_le(const unsigned char *data_p, const unsigned char **data_pp)
-/*---------------------------------------------------------------------------*\
- * Reads a signed 16 bit integer in little-endian, 2's complement format from
- * the array of bytes pointed to by 'data_p'.
- * If 'data_pp' is not null, it will set '*data_pp' to point past the integer
- * read.
-\*---------------------------------------------------------------------------*/
-{
+// Reads a signed 16 bit integer in little-endian, 2's complement format from
+// the array of bytes pointed to by 'data_p'.
+// If 'data_pp' is not null, it will set '*data_pp' to point past the integer read.
+int ys_read_s16_le(const unsigned char *data_p, const unsigned char **data_pp) {
unsigned int u16_le = ((unsigned int)data_p[1] << 8) | data_p[0];
int s16_le;
@@ -167,16 +141,11 @@ int ys_read_s16_le(const unsigned char *data_p, const unsigned char **data_pp)
return s16_le;
}
-unsigned long
-ys_read_u24_le(const unsigned char *data_p, const unsigned char **data_pp)
-/*---------------------------------------------------------------------------*\
- * Reads an unsigned 24 bit integer in big-endian format from the array of
- * bytes pointed to by 'data_p'. If 'data_pp' is not null, it will set
- * '*data_pp' to point past the integer read.
-\*---------------------------------------------------------------------------*/
-{
- unsigned long u24_le = ((unsigned long)data_p[3] << 16) |
- ((unsigned long)data_p[2] << 8) | data_p[0];
+// Reads an unsigned 24 bit integer in big-endian format from the array of
+// bytes pointed to by 'data_p'. If 'data_pp' is not null, it will set
+// '*data_pp' to point past the integer read.
+unsigned long ys_read_u24_le(const unsigned char *data_p, const unsigned char **data_pp) {
+ unsigned long u24_le = ((unsigned long)data_p[3] << 16) | ((unsigned long)data_p[2] << 8) | data_p[0];
if (data_pp != NULL) {
*data_pp = data_p + 3;
@@ -185,17 +154,12 @@ ys_read_u24_le(const unsigned char *data_p, const unsigned char **data_pp)
return u24_le;
}
-unsigned long
-ys_read_u32_be(const unsigned char *data_p, const unsigned char **data_pp)
-/*---------------------------------------------------------------------------*\
- * Reads an unsigned 32 bit integer in big-endian format from the array of
- * bytes pointed to by 'data_p'. If 'data_pp' is not null, it will set
- * '*data_pp' to point past the integer read.
-\*---------------------------------------------------------------------------*/
-{
- unsigned long u32_be = ((unsigned long)data_p[0] << 24) |
- ((unsigned long)data_p[1] << 16) |
- ((unsigned long)data_p[2] << 8) | data_p[3];
+// Reads an unsigned 32 bit integer in big-endian format from the array of
+// bytes pointed to by 'data_p'. If 'data_pp' is not null, it will set
+// '*data_pp' to point past the integer read.
+unsigned long ys_read_u32_be(const unsigned char *data_p, const unsigned char **data_pp) {
+ unsigned long u32_be = ((unsigned long)data_p[0] << 24) | ((unsigned long)data_p[1] << 16) |
+ ((unsigned long)data_p[2] << 8) | data_p[3];
if (data_pp != NULL) {
*data_pp = data_p + 4;
@@ -204,17 +168,12 @@ ys_read_u32_be(const unsigned char *data_p, const unsigned char **data_pp)
return u32_be;
}
-unsigned long
-ys_read_u32_le(const unsigned char *data_p, const unsigned char **data_pp)
-/*---------------------------------------------------------------------------*\
- * Reads an unsigned 32 bit integer in little-endian format from the array of
- * bytes pointed to by 'data_p'. If 'data_pp' is not null, it will set
- * '*data_pp' to point past the integer read.
-\*---------------------------------------------------------------------------*/
-{
- unsigned long u32_le = ((unsigned long)data_p[3] << 24) |
- ((unsigned long)data_p[2] << 16) |
- ((unsigned long)data_p[1] << 8) | data_p[0];
+// Reads an unsigned 32 bit integer in little-endian format from the array of
+// bytes pointed to by 'data_p'. If 'data_pp' is not null, it will set
+// '*data_pp' to point past the integer read.
+unsigned long ys_read_u32_le(const unsigned char *data_p, const unsigned char **data_pp) {
+ unsigned long u32_le = ((unsigned long)data_p[3] << 24) | ((unsigned long)data_p[2] << 16) |
+ ((unsigned long)data_p[1] << 8) | data_p[0];
if (data_pp != NULL) {
*data_pp = data_p + 4;
diff --git a/saga/ys_binwrite.cpp b/saga/ys_binwrite.cpp
index 2b01dc5017..4ea81d7d11 100644
--- a/saga/ys_binwrite.cpp
+++ b/saga/ys_binwrite.cpp
@@ -20,20 +20,16 @@
* $Header$
*
*/
+
#include <stddef.h>
namespace Saga {
-void
-ys_write_u16_be(unsigned int u16_be,
- unsigned char *data_p, unsigned char **data_pp)
-/*---------------------------------------------------------------------------*\
- * Writes an unsigned 16 bit integer in big-endian format to the buffer
- * pointed to by 'data_p'.
- * If 'data_pp' is not null, the function will set it to point just beyond
- * the integer written.
-\*---------------------------------------------------------------------------*/
-{
+// Writes an unsigned 16 bit integer in big-endian format to the buffer
+// pointed to by 'data_p'.
+// If 'data_pp' is not null, the function will set it to point just beyond
+// the integer written.
+void ys_write_u16_be(unsigned int u16_be, unsigned char *data_p, unsigned char **data_pp) {
data_p[0] = (unsigned char)((u16_be >> 8) & 0xFFU);
data_p[1] = (unsigned char)(u16_be & 0xFFU);
@@ -44,16 +40,11 @@ ys_write_u16_be(unsigned int u16_be,
return;
}
-void
-ys_write_u32_be(unsigned long u32_be,
- unsigned char *data_p, unsigned char **data_pp)
-/*---------------------------------------------------------------------------*\
- * Writes an unsigned 32 bit integer in big-endian format to the buffer
- * pointed to by 'data_p'.
- * If 'data_pp' is not null, the function will set it to point just beyond
- * the integer written.
-\*---------------------------------------------------------------------------*/
-{
+// Writes an unsigned 32 bit integer in big-endian format to the buffer
+// pointed to by 'data_p'.
+// If 'data_pp' is not null, the function will set it to point just beyond
+// the integer written.
+void ys_write_u32_be(unsigned long u32_be, unsigned char *data_p, unsigned char **data_pp) {
data_p[0] = (unsigned char)((u32_be >> 24) & 0xFFU);
data_p[1] = (unsigned char)((u32_be >> 16) & 0xFFU);
data_p[2] = (unsigned char)((u32_be >> 8) & 0xFFU);
diff --git a/saga/ys_dl_list.cpp b/saga/ys_dl_list.cpp
index f07f5491f5..02b166d739 100644
--- a/saga/ys_dl_list.cpp
+++ b/saga/ys_dl_list.cpp
@@ -26,9 +26,7 @@
namespace Saga {
-YS_DL_LIST *ys_dll_create(void)
-{
-
+YS_DL_LIST *ys_dll_create() {
YS_DL_LIST *new_list;
new_list = (YS_DL_LIST *)malloc(sizeof *new_list);
@@ -37,22 +35,20 @@ YS_DL_LIST *ys_dll_create(void)
new_list->next = new_list;
new_list->prev = new_list;
- /* Sentinel is marked by self-referential node data.
- * No other link is permitted to do this */
+ // Sentinel is marked by self-referential node data.
+ // No other link is permitted to do this
new_list->data = new_list;
}
return new_list;
}
-void ys_dll_destroy(YS_DL_LIST * list)
-{
+void ys_dll_destroy(YS_DL_LIST *list) {
YS_DL_NODE *walk_p;
YS_DL_NODE *temp_p;
for (walk_p = list->next; walk_p != list; walk_p = temp_p) {
temp_p = walk_p->next;
-
free(walk_p->data);
free(walk_p);
}
@@ -62,35 +58,27 @@ void ys_dll_destroy(YS_DL_LIST * list)
return;
}
-void *ys_dll_get_data(YS_DL_NODE * node)
-{
+void *ys_dll_get_data(YS_DL_NODE *node) {
return node->data;
}
-YS_DL_NODE *ys_dll_head(YS_DL_LIST * list)
-{
+YS_DL_NODE *ys_dll_head(YS_DL_LIST *list) {
return (list->next != list) ? list->next : NULL;
}
-YS_DL_NODE *ys_dll_tail(YS_DL_LIST * list)
-{
+YS_DL_NODE *ys_dll_tail(YS_DL_LIST *list) {
return (list->prev != list) ? list->prev : NULL;
}
-YS_DL_NODE *ys_dll_next(YS_DL_NODE *node)
-{
- return (node->next !=
- (YS_DL_LIST *) node->next->data) ? node->next : NULL;
+YS_DL_NODE *ys_dll_next(YS_DL_NODE *node) {
+ return (node->next != (YS_DL_LIST *) node->next->data) ? node->next : NULL;
}
-YS_DL_NODE *ys_dll_prev(YS_DL_NODE * node)
-{
- return (node->prev !=
- (YS_DL_LIST *) node->prev->data) ? node->prev : NULL;
+YS_DL_NODE *ys_dll_prev(YS_DL_NODE *node) {
+ return (node->prev != (YS_DL_LIST *) node->prev->data) ? node->prev : NULL;
}
-YS_DL_NODE *ys_dll_add_head(YS_DL_LIST * list, void *data, size_t size)
-{
+YS_DL_NODE *ys_dll_add_head(YS_DL_LIST *list, void *data, size_t size) {
YS_DL_NODE *new_node;
void *new_data;
@@ -102,7 +90,6 @@ YS_DL_NODE *ys_dll_add_head(YS_DL_LIST * list, void *data, size_t size)
if (new_data) {
memcpy(new_data, data, size);
new_node->data = new_data;
-
new_node->prev = list;
new_node->next = list->next;
new_node->next->prev = new_node;
@@ -112,8 +99,7 @@ YS_DL_NODE *ys_dll_add_head(YS_DL_LIST * list, void *data, size_t size)
return new_node;
}
-YS_DL_NODE *ys_dll_add_tail(YS_DL_LIST * list, void *data, size_t size)
-{
+YS_DL_NODE *ys_dll_add_tail(YS_DL_LIST *list, void *data, size_t size) {
YS_DL_NODE *new_node;
void *new_data;
@@ -123,10 +109,8 @@ YS_DL_NODE *ys_dll_add_tail(YS_DL_LIST * list, void *data, size_t size)
new_data = malloc(size);
if (new_data != NULL) {
-
memcpy(new_data, data, size);
new_node->data = new_data;
-
new_node->next = list;
new_node->prev = list->prev;
new_node->prev->next = new_node;
@@ -136,15 +120,12 @@ YS_DL_NODE *ys_dll_add_tail(YS_DL_LIST * list, void *data, size_t size)
return new_node;
}
-YS_DL_NODE *ys_dll_insert(YS_DL_NODE * list,
- void *data, size_t size, YS_COMPARE_FUNC * compare)
-{
+YS_DL_NODE *ys_dll_insert(YS_DL_NODE *list, void *data, size_t size, YS_COMPARE_FUNC *compare) {
YS_DL_NODE *walk_p;
YS_DL_NODE *new_node;
int result;
for (walk_p = list->next; walk_p != list; walk_p = walk_p->next) {
-
result = compare(data, walk_p->data);
if (result < 0) {
new_node = ys_dll_preinsert(walk_p, data, size);
@@ -156,9 +137,7 @@ YS_DL_NODE *ys_dll_insert(YS_DL_NODE * list,
return new_node;
}
-int ys_dll_delete(YS_DL_NODE * node)
-{
-
+int ys_dll_delete(YS_DL_NODE *node) {
if (node == NULL) {
return YS_E_FAILURE;
}
@@ -172,26 +151,21 @@ int ys_dll_delete(YS_DL_NODE * node)
return YS_E_SUCCESS;
}
-void ys_dll_delete_all(YS_DL_LIST * list)
-{
+void ys_dll_delete_all(YS_DL_LIST *list) {
YS_DL_NODE *walk_p;
YS_DL_NODE *temp_p;
for (walk_p = list->next; walk_p != list; walk_p = temp_p) {
temp_p = walk_p->next;
-
free(walk_p->data);
free(walk_p);
}
list->next = list;
list->prev = list;
-
- return;
}
-YS_DL_NODE *ys_dll_replace(YS_DL_NODE * node, void *data, size_t size)
-{
+YS_DL_NODE *ys_dll_replace(YS_DL_NODE *node, void *data, size_t size) {
void *new_data;
if ((node == NULL) || (data == NULL) || (!size)) {
@@ -211,10 +185,7 @@ YS_DL_NODE *ys_dll_replace(YS_DL_NODE * node, void *data, size_t size)
return node;
}
-int
-ys_dll_reorder_up(YS_DL_NODE * list,
- YS_DL_NODE * olink, YS_COMPARE_FUNC * compare)
-{
+int ys_dll_reorder_up(YS_DL_NODE *list, YS_DL_NODE *olink, YS_COMPARE_FUNC *compare) {
YS_DL_NODE *walk_p;
int result;
int reorder = 0;
@@ -228,11 +199,10 @@ ys_dll_reorder_up(YS_DL_NODE * list,
}
if (reorder) {
- /* Unlink original link */
+ // Unlink original link
olink->next->prev = olink->prev;
olink->prev->next = olink->next;
-
- /* Reinsert after walk link */
+ // Reinsert after walk link
olink->prev = walk_p;
olink->next = walk_p->next;
olink->next->prev = olink;
@@ -241,10 +211,7 @@ ys_dll_reorder_up(YS_DL_NODE * list,
return YS_E_SUCCESS;
}
-int
-ys_dll_reorder_down(YS_DL_NODE * list,
- YS_DL_NODE * olink, YS_COMPARE_FUNC * compare)
-{
+int ys_dll_reorder_down(YS_DL_NODE *list, YS_DL_NODE *olink, YS_COMPARE_FUNC *compare) {
YS_DL_NODE *walk_p;
int result;
int reorder = 0;
@@ -258,11 +225,10 @@ ys_dll_reorder_down(YS_DL_NODE * list,
}
if (reorder) {
- /* Unlink original link */
+ // Unlink original link
olink->next->prev = olink->prev;
olink->prev->next = olink->next;
-
- /* Reinsert before walk link */
+ //Reinsert before walk link
olink->next = walk_p;
olink->prev = walk_p->prev;
olink->prev->next = olink;
diff --git a/saga/yslib.h b/saga/yslib.h
index 25d19c0e60..5fca102cdd 100644
--- a/saga/yslib.h
+++ b/saga/yslib.h
@@ -26,84 +26,69 @@
namespace Saga {
enum YS_ERROR_STATES {
-
YS_E_SUCCESS = 0,
YS_E_FAILURE,
YS_E_MEM
};
enum YS_CONFIRM_STATES {
-
YS_CONFIRM_NO = 0,
YS_CONFIRM_YES,
YS_CONFIRM_CANCEL
};
-/* General purpose quantity-comparison function */
+// General purpose quantity-comparison function
typedef int (YS_COMPARE_FUNC) (const void *, const void *);
-/* General-purpose utility macros
-\*------------------------------------------------------------------*/
+// General-purpose utility macros
-/* Ignore a parameter (Supress warnings) */
+// Ignore a parameter (Supress warnings)
#define YS_IGNORE_PARAM( param ) ( void )( param )
-/* ys_binread.c : Binary input functions (buffer oriented)
-\*------------------------------------------------------------------*/
-
-/* #define YS_ASSUME_2S_COMP */
+//#define YS_ASSUME_2S_COMP
-/* Read a 4CC ( Four characater code ) */
-void
-ys_read_4cc(char *fourcc,
- const unsigned char *data_p, const unsigned char **data_pp);
+// Read a 4CC ( Four characater code )
+void ys_read_4cc(char *fourcc, const unsigned char *data_p, const unsigned char **data_pp);
-/* Read 8 bit unsigned integer */
+// Read 8 bit unsigned integer
unsigned int ys_read_u8(const unsigned char *, const unsigned char **);
-/* Read 8 bit signed integer */
+// Read 8 bit signed integer
int ys_read_s8(const unsigned char *, const unsigned char **);
-/* Read 16 bit unsigned integer, big-endian */
+// Read 16 bit unsigned integer, big-endian
unsigned int ys_read_u16_be(const unsigned char *, const unsigned char **);
-/* Read 16 bit unsigned integer, little-endian */
+// Read 16 bit unsigned integer, little-endian
unsigned int ys_read_u16_le(const unsigned char *, const unsigned char **);
-/* Read 16 bit signed integer, 2's complement, big-endian */
+// Read 16 bit signed integer, 2's complement, big-endian
int ys_read_s16_be(const unsigned char *, const unsigned char **);
-/* Read 16 bit signed integer, 2's complement, little-endian */
+// Read 16 bit signed integer, 2's complement, little-endian
int ys_read_s16_le(const unsigned char *, const unsigned char **);
-/* Read 24 bit unsigned integer, little-endian */
+// Read 24 bit unsigned integer, little-endian
unsigned long ys_read_u24_le(const unsigned char *, const unsigned char **);
-/* Read 32 bit unsigned integer, big-endian */
+// Read 32 bit unsigned integer, big-endian
unsigned long ys_read_u32_be(const unsigned char *, const unsigned char **);
-/* Read 32 bit unsigned integer, little-endian */
+// Read 32 bit unsigned integer, little-endian
unsigned long ys_read_u32_le(const unsigned char *, const unsigned char **);
-/* ys_binwrite.c : Binary output functions ( buffer oriented )
-\*------------------------------------------------------------------*/
-
-/* Write 16 bit unsigned integer, big-endian */
+// Write 16 bit unsigned integer, big-endian
void ys_write_u16_be(unsigned int, unsigned char *, unsigned char **);
-/* Write 32 bit unsigned integer, big-endian */
+// Write 32 bit unsigned integer, big-endian
void ys_write_u32_be(unsigned long, unsigned char *, unsigned char **);
-
-/* Shared declarations for list modules
-\*------------------------------------------------------------------*/
+// Shared declarations for list modules
enum YS_WALK_DIRECTIONS {
YS_WALK_BACKWARD = 0,
YS_WALK_FORWARD
};
-/* ys_dl_list.c : Doubly-linked list functions
-\*------------------------------------------------------------------*/
typedef struct ys_dl_node_tag YS_DL_NODE;
typedef struct ys_dl_node_tag YS_DL_LIST;
@@ -113,7 +98,7 @@ struct ys_dl_node_tag {
struct ys_dl_node_tag *prev;
};
-YS_DL_LIST *ys_dll_create(void);
+YS_DL_LIST *ys_dll_create();
void ys_dll_destroy(YS_DL_LIST *);
void *ys_dll_get_data(YS_DL_NODE *);
@@ -141,4 +126,4 @@ int ys_dll_reorder_down(YS_DL_LIST *, YS_DL_NODE *, YS_COMPARE_FUNC *);
} // End of namespace Saga
-#endif /* YSLIB_MAIN_H__ */
+#endif