mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-19 08:25:35 +00:00
indent
svn-id: r13715
This commit is contained in:
parent
d84d93b5d0
commit
0af53f3c97
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
23
saga/sound.h
23
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
|
||||
|
173
saga/sprite.cpp
173
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 );
|
||||
{
|
||||
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 );
|
||||
}
|
||||
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++;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
558
saga/sthread.cpp
558
saga/sthread.cpp
File diff suppressed because it is too large
Load Diff
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
162
saga/text.cpp
162
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;
|
||||
|
10
saga/text.h
10
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
|
||||
|
@ -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
|
||||
|
@ -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];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
55
saga/yslib.h
55
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user