diff options
Diffstat (limited to 'saga')
62 files changed, 2268 insertions, 2268 deletions
diff --git a/saga/actionmap.cpp b/saga/actionmap.cpp index 1bbe07f273..c424743728 100644 --- a/saga/actionmap.cpp +++ b/saga/actionmap.cpp @@ -34,8 +34,8 @@ namespace Saga { ActionMap::ActionMap(SagaEngine *vm, const byte * exmap_res, size_t exmap_res_len) : _vm(vm) { // Loads exit map data from specified exit map resource - R_ACTIONMAP_ENTRY *exmap_entry; - R_CLICKAREA *clickarea; + ACTIONMAP_ENTRY *exmap_entry; + CLICKAREA *clickarea; Point *point; assert(exmap_res != NULL); @@ -48,7 +48,7 @@ ActionMap::ActionMap(SagaEngine *vm, const byte * exmap_res, size_t exmap_res_le return; } - _exitsTbl = (R_ACTIONMAP_ENTRY *)malloc(_nExits * sizeof *_exitsTbl); + _exitsTbl = (ACTIONMAP_ENTRY *)malloc(_nExits * sizeof *_exitsTbl); if (_exitsTbl == NULL) { warning("Memory allocation failure"); return; @@ -63,7 +63,7 @@ ActionMap::ActionMap(SagaEngine *vm, const byte * exmap_res, size_t exmap_res_le exmap_entry->exitScene = readS.readUint16LE(); exmap_entry->entranceNum = readS.readUint16LE(); - exmap_entry->clickareas = (R_CLICKAREA *)malloc(exmap_entry->nClickareas * sizeof *(exmap_entry->clickareas)); + exmap_entry->clickareas = (CLICKAREA *)malloc(exmap_entry->nClickareas * sizeof *(exmap_entry->clickareas)); if (exmap_entry->clickareas == NULL) { warning("Error: Memory allocation failed"); @@ -94,8 +94,8 @@ ActionMap::ActionMap(SagaEngine *vm, const byte * exmap_res, size_t exmap_res_le ActionMap::~ActionMap(void) { // Frees the currently loaded exit map data - R_ACTIONMAP_ENTRY *exmap_entry; - R_CLICKAREA *clickarea; + ACTIONMAP_ENTRY *exmap_entry; + CLICKAREA *clickarea; int i; if (_exitsTbl) { @@ -121,8 +121,8 @@ const int ActionMap::getExitScene(int exitNum) { int ActionMap::hitTest(const Point& imouse) { - R_ACTIONMAP_ENTRY *exmap_entry; - R_CLICKAREA *clickarea; + ACTIONMAP_ENTRY *exmap_entry; + CLICKAREA *clickarea; Point *points; int n_points; @@ -157,9 +157,9 @@ int ActionMap::hitTest(const Point& imouse) { return -1; } -int ActionMap::draw(R_SURFACE *ds, int color) { - R_ACTIONMAP_ENTRY *exmap_entry; - R_CLICKAREA *clickarea; +int ActionMap::draw(SURFACE *ds, int color) { + ACTIONMAP_ENTRY *exmap_entry; + CLICKAREA *clickarea; int i, k; @@ -178,7 +178,7 @@ int ActionMap::draw(R_SURFACE *ds, int color) { } } - return R_SUCCESS; + return SUCCESS; } void ActionMap::info(void) { diff --git a/saga/actionmap.h b/saga/actionmap.h index 817d466ad6..fa2f8dc887 100644 --- a/saga/actionmap.h +++ b/saga/actionmap.h @@ -42,14 +42,14 @@ enum ACTION_FLAGS { ACTION_TERMINUS = (1<<3) }; -struct R_ACTIONMAP_ENTRY { +struct ACTIONMAP_ENTRY { int flags; int nClickareas; int defaultVerb; int exitScene; int entranceNum; - R_CLICKAREA *clickareas; + CLICKAREA *clickareas; }; class ActionMap { @@ -60,7 +60,7 @@ class ActionMap { const int getExitScene(int exitNum); int hitTest(const Point& imousePt); - int draw(R_SURFACE *ds, int color); + int draw(SURFACE *ds, int color); void info(void); @@ -68,7 +68,7 @@ private: SagaEngine *_vm; int _nExits; - R_ACTIONMAP_ENTRY *_exitsTbl; + ACTIONMAP_ENTRY *_exitsTbl; }; } // End of namespace Saga diff --git a/saga/actor.cpp b/saga/actor.cpp index 7a9f6cb883..f99c3acce2 100644 --- a/saga/actor.cpp +++ b/saga/actor.cpp @@ -51,21 +51,21 @@ static void CF_actor_moverel(int argc, char *argv[], void *refCon); static void CF_actor_seto(int argc, char *argv[], void *refCon); static void CF_actor_setact(int argc, char *argv[], void *refCon); -R_ACTIONTIMES ActionTDeltas[] = { +ACTIONTIMES ActionTDeltas[] = { { ACTION_IDLE, 80 }, { ACTION_WALK, 80 }, { ACTION_SPEAK, 200 } }; int Actor::reg() { - CVAR_RegisterFunc(CF_actor_add, "actor_add", "<Actor id> <lx> <ly>", R_CVAR_NONE, 3, 3, this); - CVAR_RegisterFunc(CF_actor_del, "actor_del", "<Actor id>", R_CVAR_NONE, 1, 1, this); - CVAR_RegisterFunc(CF_actor_move, "actor_move", "<Actor id> <lx> <ly>", R_CVAR_NONE, 3, 3, this); - CVAR_RegisterFunc(CF_actor_moverel, "actor_moverel", "<Actor id> <lx> <ly>", R_CVAR_NONE, 3, 3, this); - CVAR_RegisterFunc(CF_actor_seto, "actor_seto", "<Actor id> <Orientation>", R_CVAR_NONE, 2, 2, this); - CVAR_RegisterFunc(CF_actor_setact, "actor_setact", "<Actor id> <Action #>", R_CVAR_NONE, 2, 2, this); - - return R_SUCCESS; + CVAR_RegisterFunc(CF_actor_add, "actor_add", "<Actor id> <lx> <ly>", CVAR_NONE, 3, 3, this); + CVAR_RegisterFunc(CF_actor_del, "actor_del", "<Actor id>", CVAR_NONE, 1, 1, this); + CVAR_RegisterFunc(CF_actor_move, "actor_move", "<Actor id> <lx> <ly>", CVAR_NONE, 3, 3, this); + CVAR_RegisterFunc(CF_actor_moverel, "actor_moverel", "<Actor id> <lx> <ly>", CVAR_NONE, 3, 3, this); + CVAR_RegisterFunc(CF_actor_seto, "actor_seto", "<Actor id> <Orientation>", CVAR_NONE, 2, 2, this); + CVAR_RegisterFunc(CF_actor_setact, "actor_setact", "<Actor id> <Action #>", CVAR_NONE, 2, 2, this); + + return SUCCESS; } Actor::Actor(SagaEngine *vm) : _vm(vm), _initialized(false) { @@ -73,24 +73,24 @@ Actor::Actor(SagaEngine *vm) : _vm(vm), _initialized(false) { int i; // Get actor resource file context - result = GAME_GetFileContext(&_actorContext, R_GAME_RESOURCEFILE, 0); - if (result != R_SUCCESS) { + result = GAME_GetFileContext(&_actorContext, GAME_RESOURCEFILE, 0); + if (result != SUCCESS) { error("Actor::Actor(): Couldn't load actor module resource context."); } // Create actor lookup table - _tbl = (YS_DL_NODE **)malloc(R_ACTORCOUNT * sizeof(*_tbl)); + _tbl = (YS_DL_NODE **)malloc(ACTORCOUNT * sizeof(*_tbl)); if (_tbl == NULL) { error("Actor::Actor(): Memory allocation error."); return; } - for (i = 0; i < R_ACTORCOUNT; i++) { + for (i = 0; i < ACTORCOUNT; i++) { _tbl[i] = NULL; } // Create actor alias table - _aliasTbl = (int *)malloc(R_ACTORCOUNT * sizeof *_aliasTbl); + _aliasTbl = (int *)malloc(ACTORCOUNT * sizeof *_aliasTbl); if (_aliasTbl == NULL) { free(_tbl); error("Actor::Actor(): Memory allocation error."); @@ -98,7 +98,7 @@ Actor::Actor(SagaEngine *vm) : _vm(vm), _initialized(false) { } // Initialize alias table so each index contains itself - for (i = 0; i < R_ACTORCOUNT; i++) { + for (i = 0; i < ACTORCOUNT; i++) { _aliasTbl[i] = i; } @@ -121,21 +121,21 @@ Actor::~Actor() { int Actor::direct(int msec) { YS_DL_NODE *walk_p; - R_ACTOR *actor; + ACTOR *actor; YS_DL_NODE *a_inode; - R_ACTORINTENT *a_intent; + ACTORINTENT *a_intent; int o_idx; int action_tdelta; // Walk down the actor list and direct each actor for (walk_p = ys_dll_head(_list); walk_p != NULL; walk_p = ys_dll_next(walk_p)) { - actor = (R_ACTOR *)ys_dll_get_data(walk_p); + actor = (ACTOR *)ys_dll_get_data(walk_p); // Process the actor intent list a_inode = ys_dll_head(actor->a_intentlist); if (a_inode != NULL) { - a_intent = (R_ACTORINTENT *)ys_dll_get_data(a_inode); + a_intent = (ACTORINTENT *)ys_dll_get_data(a_inode); switch (a_intent->a_itype) { case INTENT_NONE: // Actor doesn't really feel like doing anything at all @@ -143,16 +143,16 @@ int Actor::direct(int msec) { case INTENT_PATH: // Actor intends to go somewhere. Well good for him { - R_WALKINTENT *a_walkint; - a_walkint = (R_WALKINTENT *)a_intent->a_data; + WALKINTENT *a_walkint; + a_walkint = (WALKINTENT *)a_intent->a_data; handleWalkIntent(actor, a_walkint, &a_intent->a_idone, msec); } break; case INTENT_SPEAK: // Actor wants to blab { - R_SPEAKINTENT *a_speakint; - a_speakint = (R_SPEAKINTENT *)a_intent->a_data; + SPEAKINTENT *a_speakint; + a_speakint = (SPEAKINTENT *)a_intent->a_data; handleSpeakIntent(actor, a_speakint, &a_intent->a_idone, msec); } break; @@ -198,31 +198,31 @@ int Actor::direct(int msec) { } } - return R_SUCCESS; + return SUCCESS; } int Actor::drawList() { YS_DL_NODE *walk_p; - R_ACTOR *actor; + ACTOR *actor; YS_DL_NODE *a_inode; - R_ACTORINTENT *a_intent; - R_SPEAKINTENT *a_speakint; + ACTORINTENT *a_intent; + SPEAKINTENT *a_speakint; YS_DL_NODE *a_dnode; - R_ACTORDIALOGUE *a_dialogue; + ACTORDIALOGUE *a_dialogue; int o_idx; //Orientation index int sprite_num; int diag_x, diag_y; // dialog coordinates - R_SURFACE *back_buf; + SURFACE *back_buf; back_buf = _vm->_gfx->getBackBuffer(); for (walk_p = ys_dll_head(_list); walk_p != NULL; walk_p = ys_dll_next(walk_p)) { - actor = (R_ACTOR *)ys_dll_get_data(walk_p); + actor = (ACTOR *)ys_dll_get_data(walk_p); o_idx = ActorOrientationLUT[actor->orient]; sprite_num = actor->act_tbl[actor->action].dir[o_idx].frame_index; sprite_num += actor->action_frame; @@ -232,12 +232,12 @@ int Actor::drawList() { // displaying his dialogue a_inode = ys_dll_head(actor->a_intentlist); if (a_inode != NULL) { - a_intent = (R_ACTORINTENT *)ys_dll_get_data(a_inode); + a_intent = (ACTORINTENT *)ys_dll_get_data(a_inode); if (a_intent->a_itype == INTENT_SPEAK) { - a_speakint = (R_SPEAKINTENT *)a_intent->a_data; + a_speakint = (SPEAKINTENT *)a_intent->a_data; a_dnode = ys_dll_head(a_speakint->si_diaglist); if (a_dnode != NULL) { - a_dialogue = (R_ACTORDIALOGUE *)ys_dll_get_data(a_dnode); + a_dialogue = (ACTORDIALOGUE *)ys_dll_get_data(a_dnode); diag_x = actor->s_pt.x; diag_y = actor->s_pt.y; diag_y -= ACTOR_DIALOGUE_HEIGHT; @@ -248,7 +248,7 @@ int Actor::drawList() { } } - return R_SUCCESS; + return SUCCESS; } // Called if the user wishes to skip a line of dialogue (spacebar in the @@ -257,32 +257,32 @@ int Actor::drawList() { int Actor::skipDialogue() { YS_DL_NODE *walk_p; - R_ACTOR *actor; + ACTOR *actor; YS_DL_NODE *a_inode; - R_ACTORINTENT *a_intent; - R_SPEAKINTENT *a_speakint; + ACTORINTENT *a_intent; + SPEAKINTENT *a_speakint; YS_DL_NODE *a_dnode; - R_ACTORDIALOGUE *a_dialogue; + ACTORDIALOGUE *a_dialogue; if (!_initialized) { - return R_FAILURE; + return FAILURE; } for (walk_p = ys_dll_head(_list); walk_p != NULL; walk_p = ys_dll_next(walk_p)) { - actor = (R_ACTOR *)ys_dll_get_data(walk_p); + actor = (ACTOR *)ys_dll_get_data(walk_p); // Check the actor's current intent for a speak intent a_inode = ys_dll_head(actor->a_intentlist); if (a_inode != NULL) { - a_intent = (R_ACTORINTENT *)ys_dll_get_data(a_inode); + a_intent = (ACTORINTENT *)ys_dll_get_data(a_inode); if (a_intent->a_itype == INTENT_SPEAK) { // Okay, found a speak intent. Remove one dialogue entry // from it, releasing any semaphore */ - a_speakint = (R_SPEAKINTENT *)a_intent->a_data; + a_speakint = (SPEAKINTENT *)a_intent->a_data; a_dnode = ys_dll_head(a_speakint->si_diaglist); if (a_dnode != NULL) { - a_dialogue = (R_ACTORDIALOGUE *)ys_dll_get_data(a_dnode); + a_dialogue = (ACTORDIALOGUE *)ys_dll_get_data(a_dnode); if (a_dialogue->d_sem != NULL) { _vm->_script->SThreadReleaseSem(a_dialogue->d_sem); } @@ -294,11 +294,11 @@ int Actor::skipDialogue() { } } - return R_SUCCESS; + return SUCCESS; } int Actor::create(int actor_id, int x, int y) { - R_ACTOR actor; + ACTOR actor; if (actor_id == 1) { actor_id = 0; @@ -310,29 +310,29 @@ int Actor::create(int actor_id, int x, int y) { actor.a_pt.x = x; actor.a_pt.y = y; - if (addActor(&actor) != R_SUCCESS) { + if (addActor(&actor) != SUCCESS) { - return R_FAILURE; + return FAILURE; } - return R_SUCCESS; + return SUCCESS; } -int Actor::addActor(R_ACTOR * actor) { +int Actor::addActor(ACTOR * actor) { YS_DL_NODE *new_node; int last_frame; int i; if (!_initialized) { - return R_FAILURE; + return FAILURE; } - if ((actor->id < 0) || (actor->id >= R_ACTORCOUNT)) { - return R_FAILURE; + if ((actor->id < 0) || (actor->id >= ACTORCOUNT)) { + return FAILURE; } if (_tbl[actor->id] != NULL) { - return R_FAILURE; + return FAILURE; } AtoS(&actor->s_pt, &actor->a_pt); @@ -344,15 +344,15 @@ int Actor::addActor(R_ACTOR * actor) { loadActorSpriteIndex(actor, actor->si_rn, &last_frame); - if (_vm->_sprite->loadList(actor->sl_rn, &actor->sl_p) != R_SUCCESS) { - return R_FAILURE; + if (_vm->_sprite->loadList(actor->sl_rn, &actor->sl_p) != SUCCESS) { + return FAILURE; } if (last_frame >= _vm->_sprite->getListLen(actor->sl_p)) { debug(0, "Appending to sprite list %d.", actor->sl_rn); if (_vm->_sprite->appendList(actor->sl_rn + 1, - actor->sl_p) != R_SUCCESS) { - return R_FAILURE; + actor->sl_p) != SUCCESS) { + return FAILURE; } } @@ -370,16 +370,16 @@ int Actor::addActor(R_ACTOR * actor) { new_node = ys_dll_insert(_list, actor, sizeof *actor, zCompare); if (new_node == NULL) { - return R_FAILURE; + return FAILURE; } - actor = (R_ACTOR *)ys_dll_get_data(new_node); + actor = (ACTOR *)ys_dll_get_data(new_node); actor->node = new_node; _tbl[i] = new_node; _count++; - return R_SUCCESS; + return SUCCESS; } int Actor::getActorIndex(uint16 actor_id) { @@ -414,15 +414,15 @@ int Actor::actorExists(uint16 actor_id) { return 1; } -int Actor::speak(int index, const char *d_string, uint16 d_voice_rn, R_SEMAPHORE *sem) { +int Actor::speak(int index, const char *d_string, uint16 d_voice_rn, SEMAPHORE *sem) { YS_DL_NODE *node; - R_ACTOR *actor; + ACTOR *actor; YS_DL_NODE *a_inode; - R_ACTORINTENT *a_intent_p = NULL; - R_SPEAKINTENT *a_speakint; - R_ACTORINTENT a_intent; + ACTORINTENT *a_intent_p = NULL; + SPEAKINTENT *a_speakint; + ACTORINTENT a_intent; int use_existing_ai = 0; - R_ACTORDIALOGUE a_dialogue; + ACTORDIALOGUE a_dialogue; a_dialogue.d_string = d_string; a_dialogue.d_voice_rn = d_voice_rn; @@ -432,10 +432,10 @@ int Actor::speak(int index, const char *d_string, uint16 d_voice_rn, R_SEMAPHORE node = _tbl[index]; if (node == NULL) { - return R_FAILURE; + return FAILURE; } - actor = (R_ACTOR *)ys_dll_get_data(node); + actor = (ACTOR *)ys_dll_get_data(node); // If actor's last registered intent is to speak, we can queue the // requested dialogue on that intent context; so examine the last @@ -443,7 +443,7 @@ int Actor::speak(int index, const char *d_string, uint16 d_voice_rn, R_SEMAPHORE a_inode = ys_dll_tail(actor->a_intentlist); if (a_inode != NULL) { - a_intent_p = (R_ACTORINTENT *)ys_dll_get_data(a_inode); + a_intent_p = (ACTORINTENT *)ys_dll_get_data(a_inode); if (a_intent_p->a_itype == INTENT_SPEAK) { use_existing_ai = 1; } @@ -451,7 +451,7 @@ int Actor::speak(int index, const char *d_string, uint16 d_voice_rn, R_SEMAPHORE if (use_existing_ai) { // Store the current dialogue off the existing actor intent - a_speakint = (R_SPEAKINTENT *)a_intent_p->a_data; + a_speakint = (SPEAKINTENT *)a_intent_p->a_data; ys_dll_add_tail(a_speakint->si_diaglist, &a_dialogue, sizeof a_dialogue); } else { // Create a new actor intent @@ -459,9 +459,9 @@ int Actor::speak(int index, const char *d_string, uint16 d_voice_rn, R_SEMAPHORE a_intent.a_idone = 0; a_intent.a_iflags = 0; - a_speakint = (R_SPEAKINTENT *)malloc(sizeof *a_speakint); + a_speakint = (SPEAKINTENT *)malloc(sizeof *a_speakint); if (a_speakint == NULL) { - return R_FAILURE; + return FAILURE; } a_speakint->si_init = 0; @@ -477,14 +477,14 @@ int Actor::speak(int index, const char *d_string, uint16 d_voice_rn, R_SEMAPHORE _vm->_script->SThreadHoldSem(sem); } - return R_SUCCESS; + return SUCCESS; } -int Actor::handleSpeakIntent(R_ACTOR *actor, R_SPEAKINTENT *a_speakint, int *complete_p, int msec) { +int Actor::handleSpeakIntent(ACTOR *actor, SPEAKINTENT *a_speakint, int *complete_p, int msec) { YS_DL_NODE *a_dnode; YS_DL_NODE *a_dnext; - R_ACTORDIALOGUE *a_dialogue; - R_ACTORDIALOGUE *a_dialogue2; + ACTORDIALOGUE *a_dialogue; + ACTORDIALOGUE *a_dialogue2; long carry_time; int intent_complete = 0; @@ -500,7 +500,7 @@ int Actor::handleSpeakIntent(R_ACTOR *actor, R_SPEAKINTENT *a_speakint, int *com // Process actor dialogue list a_dnode = ys_dll_head(a_speakint->si_diaglist); if (a_dnode != NULL) { - a_dialogue = (R_ACTORDIALOGUE *)ys_dll_get_data(a_dnode); + a_dialogue = (ACTORDIALOGUE *)ys_dll_get_data(a_dnode); if (!a_dialogue->d_playing) { // Dialogue voice hasn't played yet - play it now _vm->_sndRes->playVoice(a_dialogue->d_voice_rn); @@ -523,7 +523,7 @@ int Actor::handleSpeakIntent(R_ACTOR *actor, R_SPEAKINTENT *a_speakint, int *com a_dnext = ys_dll_next(a_dnode); if (a_dnext != NULL) { - a_dialogue2 = (R_ACTORDIALOGUE *)ys_dll_get_data(a_dnode); + a_dialogue2 = (ACTORDIALOGUE *)ys_dll_get_data(a_dnode); a_dialogue2->d_time -= carry_time; } @@ -545,7 +545,7 @@ int Actor::handleSpeakIntent(R_ACTOR *actor, R_SPEAKINTENT *a_speakint, int *com *complete_p = 1; } - return R_SUCCESS; + return SUCCESS; } int Actor::getSpeechTime(const char *d_string, uint16 d_voice_rn) { @@ -561,41 +561,41 @@ int Actor::getSpeechTime(const char *d_string, uint16 d_voice_rn) { } int Actor::setOrientation(int index, int orient) { - R_ACTOR *actor; + ACTOR *actor; if (!_initialized) { - return R_FAILURE; + return FAILURE; } if ((orient < 0) || (orient > 7)) { - return R_FAILURE; + return FAILURE; } actor = lookupActor(index); if (actor == NULL) { - return R_FAILURE; + return FAILURE; } actor->orient = orient; - return R_SUCCESS; + return SUCCESS; } int Actor::setAction(int index, int action_n, uint16 action_flags) { - R_ACTOR *actor; + ACTOR *actor; if (!_initialized) { - return R_FAILURE; + return FAILURE; } actor = lookupActor(index); if (actor == NULL) { - return R_FAILURE; + return FAILURE; } if ((action_n < 0) || (action_n >= actor->action_ct)) { - return R_FAILURE; + return FAILURE; } actor->action = action_n; @@ -603,40 +603,40 @@ int Actor::setAction(int index, int action_n, uint16 action_flags) { actor->action_frame = 0; actor->action_time = 0; - return R_SUCCESS; + return SUCCESS; } int Actor::setDefaultAction(int index, int action_n, uint16 action_flags) { - R_ACTOR *actor; + ACTOR *actor; if (!_initialized) { - return R_FAILURE; + return FAILURE; } actor = lookupActor(index); if (actor == NULL) { - return R_FAILURE; + return FAILURE; } if ((action_n < 0) || (action_n >= actor->action_ct)) { - return R_FAILURE; + return FAILURE; } actor->def_action = action_n; actor->def_action_flags = action_flags; - return R_SUCCESS; + return SUCCESS; } -R_ACTOR *Actor::lookupActor(int index) { +ACTOR *Actor::lookupActor(int index) { YS_DL_NODE *node; - R_ACTOR *actor; + ACTOR *actor; if (!_initialized) { return NULL; } - if ((index < 0) || (index >= R_ACTORCOUNT)) { + if ((index < 0) || (index >= ACTORCOUNT)) { return NULL; } @@ -645,36 +645,36 @@ R_ACTOR *Actor::lookupActor(int index) { } node = _tbl[index]; - actor = (R_ACTOR *)ys_dll_get_data(node); + actor = (ACTOR *)ys_dll_get_data(node); return actor; } -int Actor::loadActorSpriteIndex(R_ACTOR * actor, int si_rn, int *last_frame_p) { +int Actor::loadActorSpriteIndex(ACTOR * actor, int si_rn, int *last_frame_p) { byte *res_p; size_t res_len; int s_action_ct; - R_ACTORACTION *action_p; + ACTORACTION *action_p; int last_frame; int i, orient; int result; result = RSC_LoadResource(_actorContext, si_rn, &res_p, &res_len); - if (result != R_SUCCESS) { + if (result != SUCCESS) { warning("Couldn't load sprite action index resource"); - return R_FAILURE; + return FAILURE; } s_action_ct = res_len / 16; debug(0, "Sprite resource contains %d sprite actions.", s_action_ct); - action_p = (R_ACTORACTION *)malloc(sizeof(R_ACTORACTION) * s_action_ct); + action_p = (ACTORACTION *)malloc(sizeof(ACTORACTION) * s_action_ct); MemoryReadStream readS(res_p, res_len); if (action_p == NULL) { warning("Couldn't allocate memory for sprite actions"); RSC_FreeResource(res_p); - return R_MEM; + return MEM; } last_frame = 0; @@ -699,27 +699,27 @@ int Actor::loadActorSpriteIndex(R_ACTOR * actor, int si_rn, int *last_frame_p) { *last_frame_p = last_frame; } - return R_SUCCESS; + return SUCCESS; } int Actor::deleteActor(int index) { YS_DL_NODE *node; - R_ACTOR *actor; + ACTOR *actor; if (!_initialized) { - return R_FAILURE; + return FAILURE; } - if ((index < 0) || (index >= R_ACTORCOUNT)) { - return R_FAILURE; + if ((index < 0) || (index >= ACTORCOUNT)) { + return FAILURE; } if (_tbl[index] == NULL) { - return R_FAILURE; + return FAILURE; } node = _tbl[index]; - actor = (R_ACTOR *)ys_dll_get_data(node); + actor = (ACTOR *)ys_dll_get_data(node); _vm->_sprite->freeSprite(actor->sl_p); @@ -727,33 +727,33 @@ int Actor::deleteActor(int index) { _tbl[index] = NULL; - return R_SUCCESS; + return SUCCESS; } -int Actor::walkTo(int id, const Point *walk_pt, uint16 flags, R_SEMAPHORE *sem) { - R_ACTORINTENT actor_intent; - R_WALKINTENT *walk_intent; - R_WALKINTENT zero_intent; +int Actor::walkTo(int id, const Point *walk_pt, uint16 flags, SEMAPHORE *sem) { + ACTORINTENT actor_intent; + WALKINTENT *walk_intent; + WALKINTENT zero_intent; YS_DL_NODE *node; - R_ACTOR *actor; + ACTOR *actor; assert(_initialized); assert(walk_pt != NULL); - if ((id < 0) || (id >= R_ACTORCOUNT)) { - return R_FAILURE; + if ((id < 0) || (id >= ACTORCOUNT)) { + return FAILURE; } if (_tbl[id] == NULL) { - return R_FAILURE; + return FAILURE; } node = _tbl[id]; - actor = (R_ACTOR *)ys_dll_get_data(node); + actor = (ACTOR *)ys_dll_get_data(node); - walk_intent = (R_WALKINTENT *)malloc(sizeof *walk_intent); + walk_intent = (WALKINTENT *)malloc(sizeof *walk_intent); if (walk_intent == NULL) { - return R_MEM; + return MEM; } *walk_intent = zero_intent; @@ -776,11 +776,11 @@ int Actor::walkTo(int id, const Point *walk_pt, uint16 flags, R_SEMAPHORE *sem) _vm->_script->SThreadHoldSem(sem); } - return R_SUCCESS; + return SUCCESS; } -int Actor::setPathNode(R_WALKINTENT *walk_int, Point *src_pt, Point *dst_pt, R_SEMAPHORE *sem) { - R_WALKNODE new_node; +int Actor::setPathNode(WALKINTENT *walk_int, Point *src_pt, Point *dst_pt, SEMAPHORE *sem) { + WALKNODE new_node; walk_int->wi_active = 1; walk_int->org = *src_pt; @@ -793,14 +793,14 @@ int Actor::setPathNode(R_WALKINTENT *walk_int, Point *src_pt, Point *dst_pt, R_S ys_dll_add_tail(walk_int->nodelist, &new_node, sizeof new_node); - return R_SUCCESS; + return SUCCESS; } -int Actor::handleWalkIntent(R_ACTOR *actor, R_WALKINTENT *a_walkint, int *complete_p, int delta_time) { +int Actor::handleWalkIntent(ACTOR *actor, WALKINTENT *a_walkint, int *complete_p, int delta_time) { YS_DL_NODE *walk_p; YS_DL_NODE *next_p; - R_WALKNODE *node_p; + WALKNODE *node_p; int dx; int dy; @@ -833,7 +833,7 @@ int Actor::handleWalkIntent(R_ACTOR *actor, R_WALKINTENT *a_walkint, int *comple walk_p = ys_dll_head(a_walkint->nodelist); next_p = ys_dll_next(walk_p); - node_p = (R_WALKNODE *)ys_dll_get_data(walk_p); + node_p = (WALKNODE *)ys_dll_get_data(walk_p); if (node_p->calc_flag == 0) { @@ -855,7 +855,7 @@ int Actor::handleWalkIntent(R_ACTOR *actor, R_WALKINTENT *a_walkint, int *comple } *complete_p = 1; - return R_FAILURE; + return FAILURE; } a_walkint->slope = (float)dy / dx; @@ -926,14 +926,14 @@ int Actor::handleWalkIntent(R_ACTOR *actor, R_WALKINTENT *a_walkint, int *comple actor->action_frame = 0; actor->action = ACTION_IDLE; - endpoint.x = (int)new_a_x / R_ACTOR_LMULT; - endpoint.y = (int)new_a_y / R_ACTOR_LMULT; + endpoint.x = (int)new_a_x / ACTOR_LMULT; + endpoint.y = (int)new_a_y / ACTOR_LMULT; if ((exitNum = _vm->_scene->_actionMap->hitTest(endpoint)) != -1) { if (actor->flags & kProtagonist) _vm->_scene->changeScene(_vm->_scene->_actionMap->getExitScene(exitNum)); } *complete_p = 1; - return R_FAILURE; + return FAILURE; } actor_x = (int)new_a_x; @@ -952,21 +952,21 @@ int Actor::handleWalkIntent(R_ACTOR *actor, R_WALKINTENT *a_walkint, int *comple ys_dll_reorder_down(_list, actor->node, zCompare); } - return R_SUCCESS; + return SUCCESS; } int Actor::move(int index, const Point *move_pt) { YS_DL_NODE *node; - R_ACTOR *actor; + ACTOR *actor; int move_up = 0; node = _tbl[index]; if (node == NULL) { - return R_FAILURE; + return FAILURE; } - actor = (R_ACTOR *)ys_dll_get_data(node); + actor = (ACTOR *)ys_dll_get_data(node); if (move_pt->y < actor->a_pt.y) { move_up = 1; @@ -984,19 +984,19 @@ int Actor::move(int index, const Point *move_pt) { ys_dll_reorder_down(_list, actor->node, zCompare); } - return R_SUCCESS; + return SUCCESS; } int Actor::moveRelative(int index, const Point *move_pt) { YS_DL_NODE *node; - R_ACTOR *actor; + ACTOR *actor; node = _tbl[index]; if (node == NULL) { - return R_FAILURE; + return FAILURE; } - actor = (R_ACTOR *)ys_dll_get_data(node); + actor = (ACTOR *)ys_dll_get_data(node); actor->a_pt.x += move_pt->x; actor->a_pt.y += move_pt->y; @@ -1012,12 +1012,12 @@ int Actor::moveRelative(int index, const Point *move_pt) { } - return R_SUCCESS; + return SUCCESS; } static int zCompare(const void *elem1, const void *elem2) { - const R_ACTOR *actor1 = (const R_ACTOR *) elem1; - const R_ACTOR *actor2 = (const R_ACTOR *) elem2; + const ACTOR *actor1 = (const ACTOR *) elem1; + const ACTOR *actor2 = (const ACTOR *) elem2; if (actor1->a_pt.y == actor2->a_pt.y) { return 0; @@ -1029,21 +1029,21 @@ static int zCompare(const void *elem1, const void *elem2) { } int Actor::AtoS(Point *screen, const Point *actor) { - screen->x = (actor->x / R_ACTOR_LMULT); - screen->y = (actor->y / R_ACTOR_LMULT); + screen->x = (actor->x / ACTOR_LMULT); + screen->y = (actor->y / ACTOR_LMULT); - return R_SUCCESS; + return SUCCESS; } int Actor::StoA(Point *actor, const Point screen) { - actor->x = (screen.x * R_ACTOR_LMULT); - actor->y = (screen.y * R_ACTOR_LMULT); + actor->x = (screen.x * ACTOR_LMULT); + actor->y = (screen.y * ACTOR_LMULT); - return R_SUCCESS; + return SUCCESS; } static void CF_actor_add(int argc, char *argv[], void *refCon) { - R_ACTOR actor; + ACTOR actor; if (argc < 3) return; @@ -1124,7 +1124,7 @@ static void CF_actor_setact(int argc, char *argv[], void *refCon) { int index = 0; int action_n = 0; - R_ACTOR *actor; + ACTOR *actor; if (argc < 2) return; diff --git a/saga/actor.h b/saga/actor.h index d4cf8c173b..a8311a128c 100644 --- a/saga/actor.h +++ b/saga/actor.h @@ -42,20 +42,20 @@ namespace Saga { #define ACTOR_DIALOGUE_LETTERTIME 50 #define ACTOR_DIALOGUE_HEIGHT 100 -#define R_ACTOR_LMULT 4 +#define ACTOR_LMULT 4 -enum R_ACTOR_INTENTS { +enum ACTOR_INTENTS { INTENT_NONE = 0, INTENT_PATH = 1, INTENT_SPEAK = 2 }; -enum R_ACTOR_WALKFLAGS { +enum ACTOR_WALKFLAGS { WALK_NONE = 0x00, WALK_NOREORIENT = 0x01 }; -enum R_ACTOR_ORIENTATIONS { +enum ACTOR_ORIENTATIONS { ORIENT_N = 0, ORIENT_NE = 1, ORIENT_E = 2, @@ -66,28 +66,28 @@ enum R_ACTOR_ORIENTATIONS { ORIENT_NW = 7 }; -enum R_ACTOR_ACTIONS { +enum ACTOR_ACTIONS { ACTION_IDLE = 0, ACTION_WALK = 1, ACTION_SPEAK = 2, ACTION_COUNT }; -enum R_ACTOR_ACTIONFLAGS { +enum ACTOR_ACTIONFLAGS { ACTION_NONE = 0x00, ACTION_LOOP = 0x01 }; -struct R_ACTORACTIONITEM { +struct ACTORACTIONITEM { int frame_index; int frame_count; }; -struct R_ACTORACTION { - R_ACTORACTIONITEM dir[4]; +struct ACTORACTION { + ACTORACTIONITEM dir[4]; }; -struct R_WALKINTENT { +struct WALKINTENT { int wi_active; uint16 wi_flags; int wi_init; @@ -102,33 +102,33 @@ struct R_WALKINTENT { YS_DL_LIST *nodelist; int sem_held; - R_SEMAPHORE *sem; + SEMAPHORE *sem; - R_WALKINTENT() { memset(this, 0, sizeof(*this)); } + WALKINTENT() { memset(this, 0, sizeof(*this)); } }; -struct R_WALKNODE { +struct WALKNODE { int calc_flag; Point node_pt; }; -struct R_SPEAKINTENT { +struct SPEAKINTENT { int si_init; uint16 si_flags; int si_last_action; YS_DL_LIST *si_diaglist; /* Actor dialogue list */ }; -struct R_ACTORINTENT { +struct ACTORINTENT { int a_itype; uint16 a_iflags; int a_idone; void *a_data; - R_ACTORINTENT() { memset(this, 0, sizeof(*this)); } + ACTORINTENT() { memset(this, 0, sizeof(*this)); } }; -struct R_ACTOR { +struct ACTOR { int id; // Actor id int name_i; // Actor's index in actor name string list uint16 flags; @@ -138,7 +138,7 @@ struct R_ACTOR { int sl_rn; // Actor's sprite list res # int si_rn; // Actor's sprite index res # - R_SPRITELIST *sl_p;// Actor's sprite list data + SPRITELIST *sl_p;// Actor's sprite list data int idle_time; int orient; @@ -153,7 +153,7 @@ struct R_ACTOR { YS_DL_LIST *a_intentlist; -// R_WALKPATH path; +// WALKPATH path; int def_action; uint16 def_action_flags; @@ -163,23 +163,23 @@ struct R_ACTOR { int action_frame; int action_time; - R_ACTORACTION *act_tbl; // Action lookup table + ACTORACTION *act_tbl; // Action lookup table int action_ct; // Number of actions in the action LUT YS_DL_NODE *node; // Actor's node in the actor list - R_ACTOR() { memset(this, 0, sizeof(*this)); } + ACTOR() { memset(this, 0, sizeof(*this)); } }; -struct R_ACTORDIALOGUE { +struct ACTORDIALOGUE { int d_playing; const char *d_string; uint16 d_voice_rn; long d_time; int d_sem_held; - R_SEMAPHORE *d_sem; - R_ACTORDIALOGUE() { memset(this, 0, sizeof(*this)); } + SEMAPHORE *d_sem; + ACTORDIALOGUE() { memset(this, 0, sizeof(*this)); } }; -struct R_ACTIONTIMES { +struct ACTIONTIMES { int action; int time; }; @@ -202,11 +202,11 @@ class Actor { int move(int index, const Point *move_pt); int moveRelative(int index, const Point *move_pt); - int walkTo(int index, const Point *walk_pt, uint16 flags, R_SEMAPHORE *sem); + int walkTo(int index, const Point *walk_pt, uint16 flags, SEMAPHORE *sem); int getActorIndex(uint16 actor_id); - int speak(int index, const char *d_string, uint16 d_voice_rn, R_SEMAPHORE *sem); + int speak(int index, const char *d_string, uint16 d_voice_rn, SEMAPHORE *sem); int skipDialogue(); @@ -215,19 +215,19 @@ class Actor { int setAction(int index, int action_n, uint16 action_flags); int setDefaultAction(int index, int action_n, uint16 action_flags); - int addActor(R_ACTOR * actor); + int addActor(ACTOR * actor); int deleteActor(int index); - R_ACTOR *lookupActor(int index); + ACTOR *lookupActor(int index); private: - int handleWalkIntent(R_ACTOR *actor, R_WALKINTENT *a_walk_int, int *complete_p, int msec); - int handleSpeakIntent(R_ACTOR *actor, R_SPEAKINTENT *a_speakint, int *complete_p, int msec); - int setPathNode(R_WALKINTENT *walk_int, Point *src_pt, Point *dst_pt, R_SEMAPHORE *sem); - int loadActorSpriteIndex(R_ACTOR *actor, int si_rn, int *last_frame_p); + int handleWalkIntent(ACTOR *actor, WALKINTENT *a_walk_int, int *complete_p, int msec); + int handleSpeakIntent(ACTOR *actor, SPEAKINTENT *a_speakint, int *complete_p, int msec); + int setPathNode(WALKINTENT *walk_int, Point *src_pt, Point *dst_pt, SEMAPHORE *sem); + int loadActorSpriteIndex(ACTOR *actor, int si_rn, int *last_frame_p); SagaEngine *_vm; bool _initialized; - R_RSCFILE_CONTEXT *_actorContext; + RSCFILE_CONTEXT *_actorContext; uint16 _count; int *_aliasTbl; YS_DL_NODE **_tbl; diff --git a/saga/actordata.cpp b/saga/actordata.cpp index cf0e22e8ca..e3bffe3e5e 100644 --- a/saga/actordata.cpp +++ b/saga/actordata.cpp @@ -30,7 +30,7 @@ namespace Saga { // Lookup table to convert 8 cardinal directions to 4 int ActorOrientationLUT[] = { 2, 0, 0, 0, 3, 1, 1, 1 }; -R_ACTORTABLE ActorTable[R_ACTORCOUNT] = { + ACTORTABLE ActorTable[ACTORCOUNT] = { // namei sl_rn si_rn col // ----- ----- ----- --- diff --git a/saga/actordata.h b/saga/actordata.h index a533e7cb7f..99698cbe64 100644 --- a/saga/actordata.h +++ b/saga/actordata.h @@ -40,7 +40,7 @@ enum { // TODO: This doesn't quite correspond to the original Actor struct, so I'm not // sure if I got it right. -struct R_ACTORTABLE { +struct ACTORTABLE { byte type; // Always 1 (remove this?) byte flags; byte name_index; @@ -57,10 +57,10 @@ struct R_ACTORTABLE { byte action_dir; }; -#define R_ACTORCOUNT 181 +#define ACTORCOUNT 181 extern int ActorOrientationLUT[]; -extern R_ACTORTABLE ActorTable[R_ACTORCOUNT]; +extern ACTORTABLE ActorTable[ACTORCOUNT]; } // End of namespace Saga diff --git a/saga/animation.cpp b/saga/animation.cpp index 2c12afafcd..7dde34908b 100644 --- a/saga/animation.cpp +++ b/saga/animation.cpp @@ -38,17 +38,17 @@ namespace Saga { static void CF_anim_info(int argc, char *argv[], void *refCon); int Anim::reg() { - CVAR_RegisterFunc(CF_anim_info, "anim_info", NULL, R_CVAR_NONE, 0, 0, this); - return R_SUCCESS; + CVAR_RegisterFunc(CF_anim_info, "anim_info", NULL, CVAR_NONE, 0, 0, this); + return SUCCESS; } Anim::Anim(SagaEngine *vm) : _vm(vm) { int i; - _anim_limit = R_MAX_ANIMATIONS; + _anim_limit = MAX_ANIMATIONS; _anim_count = 0; - for (i = 0; i < R_MAX_ANIMATIONS; i++) + for (i = 0; i < MAX_ANIMATIONS; i++) _anim_tbl[i] = NULL; _initialized = true; @@ -57,56 +57,56 @@ Anim::Anim(SagaEngine *vm) : _vm(vm) { Anim::~Anim(void) { uint16 i; - for (i = 0; i < R_MAX_ANIMATIONS; i++) + for (i = 0; i < MAX_ANIMATIONS; i++) free(_anim_tbl[i]); _initialized = false; } int Anim::load(const byte *anim_resdata, size_t anim_resdata_len, uint16 *anim_id_p) { - R_ANIMATION *new_anim; + ANIMATION *new_anim; uint16 anim_id = 0; uint16 i; if (!_initialized) { warning("Anim::load not initialised"); - return R_FAILURE; + return FAILURE; } // Find an unused animation slot - for (i = 0; i < R_MAX_ANIMATIONS; i++) { + for (i = 0; i < MAX_ANIMATIONS; i++) { if (_anim_tbl[i] == NULL) { anim_id = i; break; } } - if (i == R_MAX_ANIMATIONS) { + if (i == MAX_ANIMATIONS) { warning("Anim::load could not find unused animation slot"); - return R_FAILURE; + return FAILURE; } - new_anim = (R_ANIMATION *)malloc(sizeof *new_anim); + new_anim = (ANIMATION *)malloc(sizeof *new_anim); if (new_anim == NULL) { warning("Anim::load Allocation failure"); - return R_MEM; + return MEM; } new_anim->resdata = anim_resdata; new_anim->resdata_len = anim_resdata_len; if (GAME_GetGameType() == GID_ITE) { - if (getNumFrames(anim_resdata, anim_resdata_len, &new_anim->n_frames) != R_SUCCESS) { + if (getNumFrames(anim_resdata, anim_resdata_len, &new_anim->n_frames) != SUCCESS) { warning("Anim::load Couldn't get animation frame count"); - return R_FAILURE; + return FAILURE; } // Cache frame offsets new_anim->frame_offsets = (size_t *)malloc(new_anim->n_frames * sizeof *new_anim->frame_offsets); if (new_anim->frame_offsets == NULL) { warning("Anim::load Allocation failure"); - return R_MEM; + return MEM; } for (i = 0; i < new_anim->n_frames; i++) { @@ -123,7 +123,7 @@ int Anim::load(const byte *anim_resdata, size_t anim_resdata_len, uint16 *anim_i new_anim->end_frame = new_anim->n_frames; new_anim->stop_frame = new_anim->end_frame; - new_anim->frame_time = R_DEFAULT_FRAME_TIME; + new_anim->frame_time = DEFAULT_FRAME_TIME; new_anim->flags = 0; new_anim->play_flag = 0; new_anim->link_flag = 0; @@ -135,22 +135,22 @@ int Anim::load(const byte *anim_resdata, size_t anim_resdata_len, uint16 *anim_i _anim_count++; - return R_SUCCESS; + return SUCCESS; } int Anim::link(uint16 anim_id1, uint16 anim_id2) { - R_ANIMATION *anim1; - R_ANIMATION *anim2; + ANIMATION *anim1; + ANIMATION *anim2; if ((anim_id1 >= _anim_count) || (anim_id2 >= _anim_count)) { - return R_FAILURE; + return FAILURE; } anim1 = _anim_tbl[anim_id1]; anim2 = _anim_tbl[anim_id2]; if ((anim1 == NULL) || (anim2 == NULL)) { - return R_FAILURE; + return FAILURE; } anim1->link_id = anim_id2; @@ -158,16 +158,16 @@ int Anim::link(uint16 anim_id1, uint16 anim_id2) { anim2->frame_time = anim1->frame_time; - return R_SUCCESS; + return SUCCESS; } int Anim::play(uint16 anim_id, int vector_time) { - R_EVENT event; - R_ANIMATION *anim; - R_ANIMATION *link_anim; + EVENT event; + ANIMATION *anim; + ANIMATION *link_anim; uint16 link_anim_id; - R_BUFFER_INFO buf_info; + BUFFER_INFO buf_info; byte *display_buf; @@ -177,47 +177,47 @@ int Anim::play(uint16 anim_id, int vector_time) { uint16 frame; int result; - R_GAME_DISPLAYINFO disp_info; + GAME_DISPLAYINFO disp_info; if (anim_id >= _anim_count) { - return R_FAILURE; + return FAILURE; } GAME_GetDisplayInfo(&disp_info); _vm->_render->getBufferInfo(&buf_info); - display_buf = buf_info.r_bg_buf; + display_buf = buf_info.bg_buf; anim = _anim_tbl[anim_id]; if (anim == NULL) { - return R_FAILURE; + return FAILURE; } if (anim->flags & ANIM_PAUSE) - return R_SUCCESS; + return SUCCESS; if (anim->play_flag) { frame = anim->current_frame; if (GAME_GetGameType() == GID_ITE) { result = ITE_DecodeFrame(anim->resdata, anim->resdata_len, anim->frame_offsets[frame - 1], display_buf, disp_info.logical_w * disp_info.logical_h); - if (result != R_SUCCESS) { + if (result != SUCCESS) { warning("ANIM::play: Error decoding frame %u", anim->current_frame); anim->play_flag = 0; - return R_FAILURE; + return FAILURE; } } else { if (anim->cur_frame_p == NULL) { warning("ANIM::play: Frames exhausted"); - return R_FAILURE; + return FAILURE; } result = IHNM_DecodeFrame(display_buf, disp_info.logical_w * disp_info.logical_h, anim->cur_frame_p, anim->cur_frame_len, &nextf_p, &nextf_len); - if (result != R_SUCCESS) { + if (result != SUCCESS) { warning("ANIM::play: Error decoding frame %u", anim->current_frame); anim->play_flag = 0; - return R_FAILURE; + return FAILURE; } anim->cur_frame_p = nextf_p; @@ -256,101 +256,101 @@ int Anim::play(uint16 anim_id, int vector_time) { if (anim->flags & ANIM_ENDSCENE) { // This animation ends the scene - event.type = R_ONESHOT_EVENT; - event.code = R_SCENE_EVENT; + event.type = ONESHOT_EVENT; + event.code = SCENE_EVENT; event.op = EVENT_END; event.time = anim->frame_time + vector_time; _vm->_events->queue(&event); } - return R_SUCCESS; + return SUCCESS; } } - event.type = R_ONESHOT_EVENT; - event.code = R_ANIM_EVENT; + event.type = ONESHOT_EVENT; + event.code = ANIM_EVENT; event.op = EVENT_FRAME; event.param = anim_id; event.time = anim->frame_time + vector_time; _vm->_events->queue(&event); - return R_SUCCESS; + return SUCCESS; } int Anim::reset() { uint16 i; - for (i = 0; i < R_MAX_ANIMATIONS; i++) { + for (i = 0; i < MAX_ANIMATIONS; i++) { freeId(i); } _anim_count = 0; - return R_SUCCESS; + return SUCCESS; } int Anim::setFlag(uint16 anim_id, uint16 flag) { - R_ANIMATION *anim; + ANIMATION *anim; if (anim_id > _anim_count) { - return R_FAILURE; + return FAILURE; } anim = _anim_tbl[anim_id]; if (anim == NULL) { - return R_FAILURE; + return FAILURE; } anim->flags |= flag; - return R_SUCCESS; + return SUCCESS; } int Anim::clearFlag(uint16 anim_id, uint16 flag) { - R_ANIMATION *anim; + ANIMATION *anim; if (anim_id > _anim_count) { - return R_FAILURE; + return FAILURE; } anim = _anim_tbl[anim_id]; if (anim == NULL) { - return R_FAILURE; + return FAILURE; } anim->flags &= ~flag; - return R_SUCCESS; + return SUCCESS; } int Anim::setFrameTime(uint16 anim_id, int time) { - R_ANIMATION *anim; + ANIMATION *anim; if (anim_id > _anim_count) { - return R_FAILURE; + return FAILURE; } anim = _anim_tbl[anim_id]; if (anim == NULL) { - return R_FAILURE; + return FAILURE; } anim->frame_time = time; - return R_SUCCESS; + return SUCCESS; } int Anim::freeId(uint16 anim_id) { - R_ANIMATION *anim; + ANIMATION *anim; if (anim_id > _anim_count) { - return R_FAILURE; + return FAILURE; } anim = _anim_tbl[anim_id]; if (anim == NULL) { - return R_FAILURE; + return FAILURE; } if (GAME_GetGameType() == GID_ITE) { @@ -362,7 +362,7 @@ int Anim::freeId(uint16 anim_id) { _anim_tbl[anim_id] = NULL; _anim_count--; - return R_SUCCESS; + return SUCCESS; } // The actual number of frames present in an animation resource is @@ -370,7 +370,7 @@ int Anim::freeId(uint16 anim_id) { // animation header. For this reason, the function attempts to find // the last valid frame number, which it returns via 'n_frames' int Anim::getNumFrames(const byte *anim_resource, size_t anim_resource_len, uint16 *n_frames) { - R_ANIMATION_HEADER ah; + ANIMATION_HEADER ah; size_t offset; int magic; @@ -378,7 +378,7 @@ int Anim::getNumFrames(const byte *anim_resource, size_t anim_resource_len, uint int x; if (!_initialized) { - return R_FAILURE; + return FAILURE; } MemoryReadStream readS(anim_resource, anim_resource_len); @@ -397,26 +397,26 @@ int Anim::getNumFrames(const byte *anim_resource, size_t anim_resource_len, uint if (ah.magic == 68) { for (x = ah.nframes; x > 0; x--) { - if (getFrameOffset(anim_resource, anim_resource_len, x, &offset) != R_SUCCESS) { - return R_FAILURE; + if (getFrameOffset(anim_resource, anim_resource_len, x, &offset) != SUCCESS) { + return FAILURE; } magic = *(anim_resource + offset); if (magic == SAGA_FRAME_HEADER_MAGIC) { *n_frames = x; - return R_SUCCESS; + return SUCCESS; } } - return R_FAILURE; + return FAILURE; } - return R_FAILURE; + return FAILURE; } int Anim::ITE_DecodeFrame(const byte *resdata, size_t resdata_len, size_t frame_offset, byte *buf, size_t buf_len) { - R_ANIMATION_HEADER ah; - R_FRAME_HEADER fh; + ANIMATION_HEADER ah; + FRAME_HEADER fh; byte *write_p; @@ -440,7 +440,7 @@ int Anim::ITE_DecodeFrame(const byte *resdata, size_t resdata_len, size_t frame_ uint16 i; if (!_initialized) { - return R_FAILURE; + return FAILURE; } MemoryReadStream headerReadS(resdata, resdata_len); @@ -461,7 +461,7 @@ int Anim::ITE_DecodeFrame(const byte *resdata, size_t resdata_len, size_t frame_ if ((screen_w * screen_h) > buf_len) { // Buffer argument is too small to hold decoded frame, abort. warning("ITE_DecodeFrame: Buffer size inadequate"); - return R_FAILURE; + return FAILURE; } // Read frame header @@ -471,7 +471,7 @@ int Anim::ITE_DecodeFrame(const byte *resdata, size_t resdata_len, size_t frame_ magic = readS.readByte(); if (magic != SAGA_FRAME_HEADER_MAGIC) { warning("ITE_DecodeFrame: Invalid frame offset"); - return R_FAILURE; + return FAILURE; } // For some strange reason, the animation header is in little @@ -528,7 +528,7 @@ int Anim::ITE_DecodeFrame(const byte *resdata, size_t resdata_len, size_t frame_ continue; break; case 0x3F: // End of frame marker - return R_SUCCESS; + return SUCCESS; break; default: break; @@ -568,12 +568,12 @@ int Anim::ITE_DecodeFrame(const byte *resdata, size_t resdata_len, size_t frame_ default: // Unknown marker found - abort warning("ITE_DecodeFrame: Invalid RLE marker encountered"); - return R_FAILURE; + return FAILURE; break; } } while (mark_byte != 63); // end of frame marker - return R_SUCCESS; + return SUCCESS; } int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte *thisf_p, @@ -600,7 +600,7 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * byte *outbuf_endp = (decode_buf + decode_buf_len) - 1; size_t outbuf_remain = decode_buf_len; - R_GAME_DISPLAYINFO di; + GAME_DISPLAYINFO di; GAME_GetDisplayInfo(&di); @@ -621,7 +621,7 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * if (thisf_len - readS.pos() < 13) { warning("0x%02X: Input buffer underrun", in_ch); - return R_FAILURE; + return FAILURE; } param1 = readS.readUint16BE(); @@ -640,7 +640,7 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * if (outbuf_p > outbuf_endp) { warning("0x%02X: (0x%X) Invalid output position. (x: %d, y: %d)", in_ch, in_ch_offset, x_origin, y_origin); - return R_FAILURE; + return FAILURE; } outbuf_remain = (outbuf_endp - outbuf_p) + 1; @@ -651,11 +651,11 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * runcount = readS.readSint16BE(); if (thisf_len - readS.pos() < runcount) { warning("0x%02X: Input buffer underrun", in_ch); - return R_FAILURE; + return FAILURE; } if (outbuf_remain < runcount) { warning("0x%02X: Output buffer overrun", in_ch); - return R_FAILURE; + return FAILURE; } for (c = 0; c < runcount; c++) { @@ -672,7 +672,7 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * case 0x1F: // 31: Unusued? if (thisf_len - readS.pos() < 3) { warning("0x%02X: Input buffer underrun", in_ch); - return R_FAILURE; + return FAILURE; } readS.readByte(); @@ -683,7 +683,7 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * case 0x20: // Long compressed run if (thisf_len - readS.pos() <= 3) { warning("0x%02X: Input buffer underrun", in_ch); - return R_FAILURE; + return FAILURE; } runcount = readS.readSint16BE(); @@ -699,7 +699,7 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * case 0x2F: // End of row if (thisf_len - readS.pos() <= 4) { - return R_FAILURE; + return FAILURE; } x_vector = readS.readSint16BE(); @@ -711,14 +711,14 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * break; case 0x30: // Reposition command if (thisf_len - readS.pos() < 2) { - return R_FAILURE; + return FAILURE; } x_vector = readS.readSint16BE(); if (((x_vector > 0) && ((size_t) x_vector > outbuf_remain)) || (-x_vector > outbuf_p - decode_buf)) { warning("0x30: Invalid x_vector"); - return R_FAILURE; + return FAILURE; } outbuf_p += x_vector; @@ -751,7 +751,7 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * case 0xC0: // Run of empty pixels runcount = param_ch + 1; if (outbuf_remain < runcount) { - return R_FAILURE; + return FAILURE; } outbuf_p += runcount; @@ -761,7 +761,7 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * case 0x80: // Run of compressed data runcount = param_ch + 1; if ((outbuf_remain < runcount) || (thisf_len - readS.pos() <= 1)) { - return R_FAILURE; + return FAILURE; } data_pixel = readS.readByte(); @@ -776,7 +776,7 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * case 0x40: // Uncompressed run runcount = param_ch + 1; if ((outbuf_remain < runcount) || (thisf_len - readS.pos() < runcount)) { - return R_FAILURE; + return FAILURE; } for (c = 0; c < runcount; c++) { @@ -797,11 +797,11 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * } } - return R_SUCCESS; + return SUCCESS; } int Anim::getFrameOffset(const byte *resdata, size_t resdata_len, uint16 find_frame, size_t *frame_offset_p) { - R_ANIMATION_HEADER ah; + ANIMATION_HEADER ah; uint16 num_frames; uint16 current_frame; @@ -814,7 +814,7 @@ int Anim::getFrameOffset(const byte *resdata, size_t resdata_len, uint16 find_fr int i; if (!_initialized) { - return R_FAILURE; + return FAILURE; } MemoryReadStream readS(resdata, resdata_len); @@ -833,14 +833,14 @@ int Anim::getFrameOffset(const byte *resdata, size_t resdata_len, uint16 find_fr num_frames = ah.nframes; if ((find_frame < 1) || (find_frame > num_frames)) { - return R_FAILURE; + return FAILURE; } for (current_frame = 1; current_frame < find_frame; current_frame++) { magic = readS.readByte(); if (magic != SAGA_FRAME_HEADER_MAGIC) { // Frame sync failure. Magic Number not found - return R_FAILURE; + return FAILURE; } // skip header @@ -905,14 +905,14 @@ int Anim::getFrameOffset(const byte *resdata, size_t resdata_len, uint16 find_fr break; default: // Encountered unknown RLE marker, abort - return R_FAILURE; + return FAILURE; break; } } while (mark_byte != 63); } *frame_offset_p = readS.pos(); - return R_SUCCESS; + return SUCCESS; } void Anim::animInfo(int argc, char *argv[]) { diff --git a/saga/animation.h b/saga/animation.h index 52ba1c2937..d6a2627303 100644 --- a/saga/animation.h +++ b/saga/animation.h @@ -28,8 +28,8 @@ namespace Saga { -#define R_MAX_ANIMATIONS 7 -#define R_DEFAULT_FRAME_TIME 140 +#define MAX_ANIMATIONS 7 +#define DEFAULT_FRAME_TIME 140 #define SAGA_FRAME_HEADER_MAGIC 15 #define SAGA_FRAME_HEADER_LEN 12 @@ -37,7 +37,7 @@ namespace Saga { // All animation resources begin with an ANIMATION_HEADER // at 0x00, followed by a RLE code stream -struct R_ANIMATION_HEADER { +struct ANIMATION_HEADER { uint16 magic; uint16 screen_w; @@ -54,7 +54,7 @@ struct R_ANIMATION_HEADER { }; -struct R_FRAME_HEADER { +struct FRAME_HEADER { int x_start; int y_start; @@ -66,7 +66,7 @@ struct R_FRAME_HEADER { }; // Animation info array member -struct R_ANIMATION { +struct ANIMATION { const byte *resdata; size_t resdata_len; @@ -119,11 +119,11 @@ private: uint16 _anim_count; uint16 _anim_limit; - R_ANIMATION *_anim_tbl[R_MAX_ANIMATIONS]; + ANIMATION *_anim_tbl[MAX_ANIMATIONS]; }; } // End of namespace Saga -#endif /* R_ANIMATION_H_ */ +#endif /* ANIMATION_H_ */ /* end "r_animation.h" */ diff --git a/saga/console.cpp b/saga/console.cpp index 8b4626e9d9..98ddf9061d 100644 --- a/saga/console.cpp +++ b/saga/console.cpp @@ -34,23 +34,23 @@ namespace Saga { int Console::reg() { - CVAR_Register_I(&_resize, "con_h", NULL, R_CVAR_NONE, 12, R_CON_DEFAULTPOS); - CVAR_Register_I(&_droptime, "con_droptime", NULL, R_CVAR_NONE, 0, 5000); - CVAR_Register_I(&_lineMax, "con_lines", NULL, R_CVAR_NONE, 5, 5000); - return R_SUCCESS; + CVAR_Register_I(&_resize, "con_h", NULL, CVAR_NONE, 12, CON_DEFAULTPOS); + CVAR_Register_I(&_droptime, "con_droptime", NULL, CVAR_NONE, 0, 5000); + CVAR_Register_I(&_lineMax, "con_lines", NULL, CVAR_NONE, 5, 5000); + return SUCCESS; } Console::Console(SagaEngine *vm) : _vm(vm) { memset(&_scrollback, 0, sizeof(_scrollback)); memset(&_history, 0, sizeof(_history)); - _resize = R_CON_DEFAULTPOS; - _droptime = R_CON_DROPTIME; + _resize = CON_DEFAULTPOS; + _droptime = CON_DROPTIME; _active = false; - _yMax = R_CON_DEFAULTPOS; - _lineMax = R_CON_DEFAULTLINES; - _histMax = R_CON_DEFAULTCMDS; + _yMax = CON_DEFAULTPOS; + _lineMax = CON_DEFAULTLINES; + _histMax = CON_DEFAULTCMDS; _histPos = 0; _linePos = 0; _yPos = 0; @@ -68,14 +68,14 @@ Console::~Console() { } int Console::activate() { - R_EVENT con_event; + EVENT con_event; if (_active) { - return R_FAILURE; + return FAILURE; } - con_event.type = R_CONTINUOUS_EVENT; - con_event.code = R_CONSOLE_EVENT | R_NODESTROY; + con_event.type = CONTINUOUS_EVENT; + con_event.code = CONSOLE_EVENT | NODESTROY; con_event.op = EVENT_ACTIVATE; con_event.time = 0; con_event.duration = _droptime; @@ -84,25 +84,25 @@ int Console::activate() { _active = true; - return R_SUCCESS; + return SUCCESS; } int Console::deactivate() { - R_EVENT con_event; + EVENT con_event; if (!_active) { - return R_FAILURE; + return FAILURE; } - con_event.type = R_CONTINUOUS_EVENT; - con_event.code = R_CONSOLE_EVENT | R_NODESTROY; + con_event.type = CONTINUOUS_EVENT; + con_event.code = CONSOLE_EVENT | NODESTROY; con_event.op = EVENT_DEACTIVATE; con_event.time = 0; con_event.duration = _droptime; _vm->_events->queue(&con_event); - return R_SUCCESS; + return SUCCESS; } bool Console::isActive(void) { @@ -121,19 +121,19 @@ int Console::type(int in_char) { //char *lvalue; char *rvalue = NULL; - R_CVAR_P con_cvar = NULL; + CVAR_P con_cvar = NULL; const char *expr_err; const char *err_str; if (_yPos != _yMax) { // Ignore keypress until console fully down - return R_SUCCESS; + return SUCCESS; } if ((in_char > 127) || (!in_char)) { // Ignore non-ascii codes - return R_SUCCESS; + return SUCCESS; } switch (in_char) { @@ -143,10 +143,10 @@ int Console::type(int in_char) { expr_len = strlen(_inputBuf); result = EXPR_Parse(&expr, &expr_len, &con_cvar, &rvalue); _vm->_console->addLine(&_history, _histMax, _inputBuf); - memset(_inputBuf, 0, R_CON_INPUTBUF_LEN); + memset(_inputBuf, 0, CON_INPUTBUF_LEN); _inputPos = 0; _histPos = 0; - if (result != R_SUCCESS) { + if (result != SUCCESS) { EXPR_GetError(&expr_err); _vm->_console->print("Parse error: %s", expr_err); break; @@ -159,7 +159,7 @@ int Console::type(int in_char) { if (CVAR_IsFunc(con_cvar)) { CVAR_Exec(con_cvar, rvalue); - } else if (CVAR_SetValue(con_cvar, rvalue) != R_SUCCESS) { + } else if (CVAR_SetValue(con_cvar, rvalue) != SUCCESS) { CVAR_GetError(&err_str); _vm->_console->print("Illegal assignment: %s.", err_str); } @@ -172,7 +172,7 @@ int Console::type(int in_char) { } break; default: - if (input_pos < R_CON_INPUTBUF_LEN) { + if (input_pos < CON_INPUTBUF_LEN) { _inputBuf[input_pos] = (char)in_char; _inputPos++; } @@ -182,20 +182,20 @@ int Console::type(int in_char) { if (rvalue) free(rvalue); - return R_SUCCESS; + return SUCCESS; } -int Console::draw(R_SURFACE *ds) { +int Console::draw(SURFACE *ds) { int line_y; - R_CONSOLE_LINE *walk_ptr; - R_CONSOLE_LINE *start_ptr; + CONSOLE_LINE *walk_ptr; + CONSOLE_LINE *start_ptr; int txt_fgcolor; int txt_shcolor; Rect fill_rect; int i; if (!_active) { - return R_FAILURE; + return FAILURE; } if (_resize != _yMax) { @@ -208,15 +208,15 @@ int Console::draw(R_SURFACE *ds) { fill_rect.bottom = _yPos + 1; fill_rect.right = ds->buf_w; - _vm->_gfx->drawRect(ds, &fill_rect, _vm->_gfx->matchColor(R_CONSOLE_BGCOLOR)); - txt_fgcolor = _vm->_gfx->matchColor(R_CONSOLE_TXTCOLOR); - txt_shcolor = _vm->_gfx->matchColor(R_CONSOLE_TXTSHADOW); + _vm->_gfx->drawRect(ds, &fill_rect, _vm->_gfx->matchColor(CONSOLE_BGCOLOR)); + txt_fgcolor = _vm->_gfx->matchColor(CONSOLE_TXTCOLOR); + txt_shcolor = _vm->_gfx->matchColor(CONSOLE_TXTSHADOW); _vm->_font->draw(SMALL_FONT_ID, ds, ">", 1, 2, _yPos - 10, txt_fgcolor, txt_shcolor, FONT_SHADOW); _vm->_font->draw(SMALL_FONT_ID, ds, _inputBuf, strlen(_inputBuf), 10, _yPos - 10, txt_fgcolor, txt_shcolor, FONT_SHADOW); - line_y = _yPos - (R_CON_INPUT_H + R_CON_LINE_H); + line_y = _yPos - (CON_INPUT_H + CON_LINE_H); start_ptr = _scrollback.head; for (i = 0; i < _linePos; i++) { @@ -229,16 +229,16 @@ int Console::draw(R_SURFACE *ds) { for (walk_ptr = start_ptr; walk_ptr; walk_ptr = walk_ptr->next) { _vm->_font->draw(SMALL_FONT_ID, ds, walk_ptr->str_p, walk_ptr->str_len, 2, line_y, txt_fgcolor, txt_shcolor, FONT_SHADOW); - line_y -= R_CON_LINE_H; - if (line_y < -R_CON_LINE_H) + line_y -= CON_LINE_H; + if (line_y < -CON_LINE_H) break; } - return R_SUCCESS; + return SUCCESS; } int Console::print(const char *fmt_str, ...) { - char vsstr_p[R_CON_PRINTFLIMIT + 1]; + char vsstr_p[CON_PRINTFLIMIT + 1]; va_list argptr; int ret_val; @@ -253,11 +253,11 @@ int Console::print(const char *fmt_str, ...) { } int Console::cmdUp() { - R_CONSOLE_LINE *start_ptr = _history.head; + CONSOLE_LINE *start_ptr = _history.head; int i; if (!start_ptr) { - return R_SUCCESS; + return SUCCESS; } if (_histPos < _history.lines) { @@ -272,29 +272,29 @@ int Console::cmdUp() { } } - memset(_inputBuf, 0, R_CON_INPUTBUF_LEN); + memset(_inputBuf, 0, CON_INPUTBUF_LEN); strcpy(_inputBuf, start_ptr->str_p); _inputPos = start_ptr->str_len - 1; debug(0, "History pos: %d/%d", _histPos, _history.lines); - return R_SUCCESS; + return SUCCESS; } int Console::cmdDown(void) { - R_CONSOLE_LINE *start_ptr = _history.head; + CONSOLE_LINE *start_ptr = _history.head; int i; if (_histPos == 1) { debug(0, "Erased input buffer."); - memset(_inputBuf, 0, R_CON_INPUTBUF_LEN); + memset(_inputBuf, 0, CON_INPUTBUF_LEN); _inputPos = 0; _histPos--; - return R_SUCCESS; + return SUCCESS; } else if (_histPos) { _histPos--; } else { - return R_SUCCESS; + return SUCCESS; } for (i = 1; i < _histPos; i++) { @@ -305,30 +305,30 @@ int Console::cmdDown(void) { } } - memset(_inputBuf, 0, R_CON_INPUTBUF_LEN); + memset(_inputBuf, 0, CON_INPUTBUF_LEN); strcpy(_inputBuf, start_ptr->str_p); _inputPos = start_ptr->str_len - 1; debug(0, "History pos: %d/%d", _histPos, _history.lines); - return R_SUCCESS; + return SUCCESS; } int Console::pageUp() { int n_lines; - n_lines = (_yMax - R_CON_INPUT_H) / R_CON_LINE_H; + n_lines = (_yMax - CON_INPUT_H) / CON_LINE_H; if (_linePos < (_scrollback.lines - n_lines)) { _linePos += n_lines; } debug(0, "Line pos: %d", _linePos); - return R_SUCCESS; + return SUCCESS; } int Console::pageDown() { int n_lines; - n_lines = (_yMax - R_CON_INPUT_H) / R_CON_LINE_H; + n_lines = (_yMax - CON_INPUT_H) / CON_LINE_H; if (_linePos > n_lines) { _linePos -= n_lines; @@ -336,11 +336,11 @@ int Console::pageDown() { _linePos = 0; } - return R_SUCCESS; + return SUCCESS; } int Console::dropConsole(double percent) { - R_SURFACE *back_buf; + SURFACE *back_buf; if (percent > 1.0) { percent = 1.0; @@ -350,11 +350,11 @@ int Console::dropConsole(double percent) { _vm->_console->setDropPos(percent); _vm->_console->draw(back_buf); - return R_SUCCESS; + return SUCCESS; } int Console::raiseConsole(double percent) { - R_SURFACE *back_buf; + SURFACE *back_buf; if (percent >= 1.0) { percent = 1.0; @@ -365,7 +365,7 @@ int Console::raiseConsole(double percent) { _vm->_console->setDropPos(1.0 - percent); _vm->_console->draw(back_buf); - return R_SUCCESS; + return SUCCESS; } int Console::setDropPos(double percent) { @@ -379,25 +379,25 @@ int Console::setDropPos(double percent) { exp_percent = percent * percent; _yPos = (int)(_yMax * exp_percent); - return R_SUCCESS; + return SUCCESS; } -int Console::addLine(R_CON_SCROLLBACK *scroll, int line_max, const char *constr_p) { +int Console::addLine(CON_SCROLLBACK *scroll, int line_max, const char *constr_p) { int constr_len; char *newstr_p; - R_CONSOLE_LINE *newline_p; + CONSOLE_LINE *newline_p; int del_lines; int i; constr_len = strlen(constr_p) + 1; newstr_p = (char *)malloc(constr_len); if (newstr_p == NULL) { - return R_MEM; + return MEM; } - newline_p = (R_CONSOLE_LINE *)malloc(sizeof(R_CONSOLE_LINE)); + newline_p = (CONSOLE_LINE *)malloc(sizeof(CONSOLE_LINE)); if (newline_p == NULL) { - return R_MEM; + return MEM; } newline_p->next = NULL; newline_p->prev = NULL; @@ -425,11 +425,11 @@ int Console::addLine(R_CON_SCROLLBACK *scroll, int line_max, const char *constr_ } } - return R_SUCCESS; + return SUCCESS; } -int Console::deleteLine(R_CON_SCROLLBACK *scroll) { - R_CONSOLE_LINE *temp_p = scroll->tail; +int Console::deleteLine(CON_SCROLLBACK *scroll) { + CONSOLE_LINE *temp_p = scroll->tail; if (temp_p->prev == NULL) { scroll->head = NULL; @@ -444,12 +444,12 @@ int Console::deleteLine(R_CON_SCROLLBACK *scroll) { free(temp_p); scroll->lines--; - return R_SUCCESS; + return SUCCESS; } -int Console::deleteScroll(R_CON_SCROLLBACK * scroll) { - R_CONSOLE_LINE *walk_ptr; - R_CONSOLE_LINE *temp_ptr; +int Console::deleteScroll(CON_SCROLLBACK * scroll) { + CONSOLE_LINE *walk_ptr; + CONSOLE_LINE *temp_ptr; for (walk_ptr = scroll->head; walk_ptr; walk_ptr = temp_ptr) { @@ -459,7 +459,7 @@ int Console::deleteScroll(R_CON_SCROLLBACK * scroll) { free(walk_ptr); } - return R_SUCCESS; + return SUCCESS; } } // End of namespace Saga diff --git a/saga/console.h b/saga/console.h index b24f2540c1..c6b99c2a7e 100644 --- a/saga/console.h +++ b/saga/console.h @@ -28,32 +28,32 @@ namespace Saga { -#define R_CON_INPUTBUF_LEN 80 +#define CON_INPUTBUF_LEN 80 -#define R_CONSOLE_BGCOLOR 0x00A0A0A0UL -#define R_CONSOLE_TXTCOLOR 0x00FFFFFFUL -#define R_CONSOLE_TXTSHADOW 0x00202020UL +#define CONSOLE_BGCOLOR 0x00A0A0A0UL +#define CONSOLE_TXTCOLOR 0x00FFFFFFUL +#define CONSOLE_TXTSHADOW 0x00202020UL -struct R_CONSOLE_LINE { - R_CONSOLE_LINE *next; - R_CONSOLE_LINE *prev; +struct CONSOLE_LINE { + CONSOLE_LINE *next; + CONSOLE_LINE *prev; char *str_p; int str_len; }; -struct R_CON_SCROLLBACK { - R_CONSOLE_LINE *head; - R_CONSOLE_LINE *tail; +struct CON_SCROLLBACK { + CONSOLE_LINE *head; + CONSOLE_LINE *tail; int lines; }; -#define R_CON_DEFAULTPOS 136 -#define R_CON_DEFAULTLINES 100 -#define R_CON_DEFAULTCMDS 10 -#define R_CON_DROPTIME 400 -#define R_CON_PRINTFLIMIT 1024 -#define R_CON_LINE_H 10 -#define R_CON_INPUT_H 10 +#define CON_DEFAULTPOS 136 +#define CON_DEFAULTLINES 100 +#define CON_DEFAULTCMDS 10 +#define CON_DROPTIME 400 +#define CON_PRINTFLIMIT 1024 +#define CON_LINE_H 10 +#define CON_INPUT_H 10 class Console { public: @@ -66,7 +66,7 @@ class Console { bool isActive(void); int type(int in_char); - int draw(R_SURFACE *ds); + int draw(SURFACE *ds); int print(const char *fmt_str, ...); int cmdUp(void); @@ -78,16 +78,16 @@ class Console { int raiseConsole(double percent); private: - int addLine(R_CON_SCROLLBACK *scroll, int line_max, const char *constr_p); - int deleteLine(R_CON_SCROLLBACK *scroll); - int deleteScroll(R_CON_SCROLLBACK *scroll); + int addLine(CON_SCROLLBACK *scroll, int line_max, const char *constr_p); + int deleteLine(CON_SCROLLBACK *scroll); + int deleteScroll(CON_SCROLLBACK *scroll); int setDropPos(double percent); private: SagaEngine *_vm; - R_CON_SCROLLBACK _scrollback; - R_CON_SCROLLBACK _history; + CON_SCROLLBACK _scrollback; + CON_SCROLLBACK _history; int _resize; int _droptime; @@ -101,7 +101,7 @@ class Console { int _yPos; char *_prompt; int _promptW; - char _inputBuf[R_CON_INPUTBUF_LEN + 1]; + char _inputBuf[CON_INPUTBUF_LEN + 1]; int _inputPos; }; diff --git a/saga/cvar.cpp b/saga/cvar.cpp index dcb64757d9..8856a018b3 100644 --- a/saga/cvar.cpp +++ b/saga/cvar.cpp @@ -32,7 +32,7 @@ namespace Saga { -R_CVAR *CVHashTbl[R_CVAR_HASHLEN]; +CVAR *CVHashTbl[CVAR_HASHLEN]; static const char *CVAR_ErrMsg[] = { "No Error", @@ -73,20 +73,20 @@ int CVAR_GetError(const char **err_str) { } // Frees the cvar hash table int CVAR_Shutdown() { - R_CVAR *walk_ptr; - R_CVAR *temp_ptr; + CVAR *walk_ptr; + CVAR *temp_ptr; int i; debug(0, "CVAR_Shutdown(): Deleting cvar hash table."); - for (i = 0; i < R_CVAR_HASHLEN; i++) { + for (i = 0; i < CVAR_HASHLEN; i++) { for (walk_ptr = CVHashTbl[i]; walk_ptr; walk_ptr = temp_ptr) { temp_ptr = walk_ptr->next; free(walk_ptr); } } - return R_SUCCESS; + return SUCCESS; } // Returns hash index for string 'str'. @@ -98,23 +98,23 @@ unsigned int CVAR_HashString(const char *str) { index = *str + 31 * index; } - return index % R_CVAR_HASHLEN; + return index % CVAR_HASHLEN; } // Adds a copy of the given cvar into the hash table. -// Returns R_SUCCESS if cvar was added, R_MEM if allocation failed. -int CVAR_Add(int index, R_CVAR *cvar) { - R_CVAR *new_cvar; - R_CVAR *temp_ptr; +// Returns SUCCESS if cvar was added, MEM if allocation failed. +int CVAR_Add(int index, CVAR *cvar) { + CVAR *new_cvar; + CVAR *temp_ptr; - new_cvar = (R_CVAR *)malloc(sizeof(R_CVAR)); + new_cvar = (CVAR *)malloc(sizeof(CVAR)); if (new_cvar == NULL) { CVAR_ErrorState = CVERR_MEM; - return R_MEM; + return MEM; } - memcpy(new_cvar, cvar, sizeof(R_CVAR)); + memcpy(new_cvar, cvar, sizeof(CVAR)); if (CVHashTbl[index] == NULL) { CVHashTbl[index] = new_cvar; @@ -126,29 +126,29 @@ int CVAR_Add(int index, R_CVAR *cvar) { } CVAR_ErrorState = CVERR_NONE; - return R_SUCCESS; + return SUCCESS; } // Attempts to execute the specified console function with the given argument // string. -// Returns R_FAILURE if cvar_func is not a valid console function -int CVAR_Exec(R_CVAR_P cvar_func, char *r_value) { +// Returns FAILURE if cvar_func is not a valid console function +int CVAR_Exec(CVAR_P cvar_func, char *value) { int cf_argc = 0; char **cf_argv = NULL; int max_args; - if (cvar_func->type != R_CVAR_FUNC) { + if (cvar_func->type != CVAR_FUNC) { CVAR_ErrorState = CVERR_NOTFUNC; - return R_FAILURE; + return FAILURE; } - cf_argc = EXPR_GetArgs(r_value, &cf_argv); + cf_argc = EXPR_GetArgs(value, &cf_argv); if (cf_argc < cvar_func->t.func.min_args) { _vm->_console->print("Too few arguments to function."); if (cf_argv) free(cf_argv); - return R_FAILURE; + return FAILURE; } max_args = cvar_func->t.func.max_args; @@ -156,7 +156,7 @@ int CVAR_Exec(R_CVAR_P cvar_func, char *r_value) { _vm->_console->print("Too many arguments to function."); if (cf_argv) free(cf_argv); - return R_FAILURE; + return FAILURE; } // Call function @@ -165,53 +165,53 @@ int CVAR_Exec(R_CVAR_P cvar_func, char *r_value) { if (cf_argv) free(cf_argv); - return R_SUCCESS; + return SUCCESS; } -// Attempts to assign the value contained in the string 'r_value' to cvar. -// Returns R_FAILURE if there was an error parsing 'r_value' -int CVAR_SetValue(R_CVAR_P cvar, char *r_value) { +// Attempts to assign the value contained in the string 'value' to cvar. +// Returns FAILURE if there was an error parsing 'value' +int CVAR_SetValue(CVAR_P cvar, char *value) { long int int_param; unsigned long uint16_param; char *end_p; ptrdiff_t scan_len; - int r_value_len; + int value_len; - r_value_len = strlen(r_value); + value_len = strlen(value); - if (cvar->flags & R_CVAR_READONLY) { + if (cvar->flags & CVAR_READONLY) { CVAR_ErrorState = CVERR_READONLY; - return R_FAILURE; + return FAILURE; } switch (cvar->type) { - case R_CVAR_INT: - int_param = strtol(r_value, &end_p, 10); + case CVAR_INT: + int_param = strtol(value, &end_p, 10); if ((int_param == LONG_MIN) || (int_param == LONG_MAX)) { CVAR_ErrorState = CVERR_PARSEOVERFLOW; - return R_FAILURE; + return FAILURE; } - scan_len = end_p - r_value; + scan_len = end_p - value; if (int_param == 0) { - if (!scan_len || r_value[scan_len - 1] != '0') { + if (!scan_len || value[scan_len - 1] != '0') { // strtol() returned 0, but string isn't "0". Invalid. CVAR_ErrorState = CVERR_INVALID; - return R_FAILURE; + return FAILURE; } } - if (scan_len != r_value_len) { + if (scan_len != value_len) { // Entire string wasn't converted...Invalid CVAR_ErrorState = CVERR_INVALID; - return R_FAILURE; + return FAILURE; } if ((int_param < CV_INTMIN) || (int_param > CV_INTMAX)) { // Overflows destination type CVAR_ErrorState = CVERR_DESTOVERFLOW; - return R_FAILURE; + return FAILURE; } // Ignore bounds if equal @@ -219,48 +219,48 @@ int CVAR_SetValue(R_CVAR_P cvar, char *r_value) { if ((int_param < cvar->t.i.lbound) || (int_param > cvar->t.i.ubound)) { // Value is outside of cvar bounds CVAR_ErrorState = CVERR_BOUND; - return R_FAILURE; + return FAILURE; } } *(cvar->t.i.var_p) = (cv_int_t) int_param; -#ifdef R_CVAR_TRACE +#ifdef CVAR_TRACE printf("Set cvar to value %ld.\n", int_param); #endif break; - case R_CVAR_UINT: - if (*r_value == '-') { + case CVAR_UINT: + if (*value == '-') { CVAR_ErrorState = CVERR_SIGN; - return R_FAILURE; + return FAILURE; } - uint16_param = strtoul(r_value, &end_p, 10); + uint16_param = strtoul(value, &end_p, 10); if (uint16_param == ULONG_MAX) { CVAR_ErrorState = CVERR_PARSEOVERFLOW; - return R_FAILURE; + return FAILURE; } - scan_len = end_p - r_value; + scan_len = end_p - value; if (uint16_param == 0) { - if (!scan_len || r_value[scan_len - 1] != '0') { + if (!scan_len || value[scan_len - 1] != '0') { // strtol() returned 0, but string isn't "0". Invalid. CVAR_ErrorState = CVERR_INVALID; - return R_FAILURE; + return FAILURE; } } - if (scan_len != r_value_len) { + if (scan_len != value_len) { // Entire string wasn't converted...Invalid CVAR_ErrorState = CVERR_INVALID; - return R_FAILURE; + return FAILURE; } if (uint16_param > CV_UINTMAX) { // Overflows destination type CVAR_ErrorState = CVERR_DESTOVERFLOW; - return R_FAILURE; + return FAILURE; } // Ignore bounds if equal @@ -268,49 +268,49 @@ int CVAR_SetValue(R_CVAR_P cvar, char *r_value) { if ((uint16_param < cvar->t.ui.lbound) || (uint16_param > cvar->t.ui.ubound)) { // Value is outside cvar bounds CVAR_ErrorState = CVERR_BOUND; - return R_FAILURE; + return FAILURE; } } *(cvar->t.ui.var_p) = (cv_uint16_t) uint16_param; -#ifdef R_CVAR_TRACE +#ifdef CVAR_TRACE printf("Set cvar to value %lu.\n", uint16_param); #endif break; - case R_CVAR_FLOAT: + case CVAR_FLOAT: CVAR_ErrorState = CVERR_NOTIMPL; - return R_FAILURE; + return FAILURE; break; - case R_CVAR_STRING: - if (strrchr(r_value, '\"') != NULL) { + case CVAR_STRING: + if (strrchr(value, '\"') != NULL) { CVAR_ErrorState = CVERR_STRING; - return R_FAILURE; + return FAILURE; } - strncpy(cvar->t.s.var_str, r_value, cvar->t.s.ubound); - if (cvar->t.s.ubound < r_value_len) { + strncpy(cvar->t.s.var_str, value, cvar->t.s.ubound); + if (cvar->t.s.ubound < value_len) { cvar->t.s.var_str[cvar->t.s.ubound] = 0; } -#ifdef R_CVAR_TRACE +#ifdef CVAR_TRACE printf("Set cvar to value \"%s\".\n", cvar->t.s.var_str); #endif break; default: CVAR_ErrorState = CVERR_TYPE; - return R_FAILURE; + return FAILURE; break; } CVAR_ErrorState = CVERR_NONE; - return R_SUCCESS; + return SUCCESS; } // Given a cvar name this function returns a pointer to the appropriate // cvar structure or NULL if no match was found. -R_CVAR_P CVAR_Find(const char *var_str) { - R_CVAR *walk_ptr; +CVAR_P CVAR_Find(const char *var_str) { + CVAR *walk_ptr; int hash; hash = CVAR_HashString(var_str); -#ifdef R_CVAR_TRACE +#ifdef CVAR_TRACE printf("Performing lookup on hash bucket %d.\n", hash); #endif walk_ptr = CVHashTbl[hash]; @@ -324,8 +324,8 @@ R_CVAR_P CVAR_Find(const char *var_str) { return NULL; } -int CVAR_IsFunc(R_CVAR_P cvar_func) { - if (cvar_func->type == R_CVAR_FUNC) +int CVAR_IsFunc(CVAR_P cvar_func) { + if (cvar_func->type == CVAR_FUNC) return 1; else return 0; @@ -335,11 +335,11 @@ int CVAR_IsFunc(R_CVAR_P cvar_func) { // (could think of a better place to put these...?) int CVAR_RegisterFunc(cv_func_t func, const char *func_name, const char *func_argstr, uint16 flags, int min_args, int max_args, void *refCon) { - R_CVAR new_cvar; + CVAR new_cvar; int hash; new_cvar.name = func_name; - new_cvar.type = R_CVAR_FUNC; + new_cvar.type = CVAR_FUNC; new_cvar.section = NULL; new_cvar.refCon = refCon; new_cvar.flags = flags; @@ -349,7 +349,7 @@ int CVAR_RegisterFunc(cv_func_t func, const char *func_name, new_cvar.t.func.max_args = max_args; hash = CVAR_HashString(func_name); -#ifdef R_CVAR_TRACE +#ifdef CVAR_TRACE printf("Added FUNC cvar to hash bucket %d.\n", hash); #endif @@ -360,11 +360,11 @@ int CVAR_RegisterFunc(cv_func_t func, const char *func_name, int CVAR_Register_I(cv_int_t * var_p, const char *var_name, const char *section, uint16 flags, cv_int_t lbound, cv_int_t ubound) { - R_CVAR new_cvar; + CVAR new_cvar; int hash; new_cvar.name = var_name; - new_cvar.type = R_CVAR_INT; + new_cvar.type = CVAR_INT; new_cvar.section = section; new_cvar.flags = flags; new_cvar.t.i.var_p = var_p; @@ -372,7 +372,7 @@ int CVAR_Register_I(cv_int_t * var_p, const char *var_name, new_cvar.t.i.ubound = ubound; hash = CVAR_HashString(var_name); -#ifdef R_CVAR_TRACE +#ifdef CVAR_TRACE printf("Added INT cvar to hash bucket %d.\n", hash); #endif @@ -382,11 +382,11 @@ int CVAR_Register_I(cv_int_t * var_p, const char *var_name, // Registers an unsigned integer type cvar. int CVAR_Register_UI(cv_uint16_t * var_p, const char *var_name, const char *section, uint16 flags, cv_uint16_t lbound, cv_uint16_t ubound) { - R_CVAR new_cvar; + CVAR new_cvar; int hash; new_cvar.name = var_name; - new_cvar.type = R_CVAR_UINT; + new_cvar.type = CVAR_UINT; new_cvar.section = section; new_cvar.flags = flags; new_cvar.t.ui.var_p = var_p; @@ -394,7 +394,7 @@ int CVAR_Register_UI(cv_uint16_t * var_p, const char *var_name, new_cvar.t.ui.ubound = ubound; hash = CVAR_HashString(var_name); -#ifdef R_CVAR_TRACE +#ifdef CVAR_TRACE printf("Added UNSIGNED INT ccvar to hash bucket %d.\n", hash); #endif @@ -404,11 +404,11 @@ int CVAR_Register_UI(cv_uint16_t * var_p, const char *var_name, // Registers a floating point type cvar. int CVAR_Register_F(cv_float_t * var_p, const char *var_name, const char *section, uint16 flags, cv_float_t lbound, cv_float_t ubound) { - R_CVAR new_cvar; + CVAR new_cvar; int hash; new_cvar.name = var_name; - new_cvar.type = R_CVAR_FLOAT; + new_cvar.type = CVAR_FLOAT; new_cvar.section = section; new_cvar.flags = flags; new_cvar.t.f.var_p = var_p; @@ -416,7 +416,7 @@ int CVAR_Register_F(cv_float_t * var_p, const char *var_name, new_cvar.t.f.ubound = ubound; hash = CVAR_HashString(var_name); -#ifdef R_CVAR_TRACE +#ifdef CVAR_TRACE printf("Added FLOAT cvar to hash bucket %d.\n", hash); #endif @@ -426,18 +426,18 @@ int CVAR_Register_F(cv_float_t * var_p, const char *var_name, // Registers a string type cvar. Storage must be provided in var_p for 'ubound' // characters plus 1 for NUL char. int CVAR_Register_S(cv_char_t * var_str, const char *var_name, const char *section, uint16 flags, int ubound) { - R_CVAR new_cvar; + CVAR new_cvar; int hash; new_cvar.name = var_name; - new_cvar.type = R_CVAR_STRING; + new_cvar.type = CVAR_STRING; new_cvar.section = section; new_cvar.flags = flags; new_cvar.t.s.var_str = var_str; new_cvar.t.s.ubound = ubound; hash = CVAR_HashString(var_name); -#ifdef R_CVAR_TRACE +#ifdef CVAR_TRACE printf("Added UNSIGNED INT var to hash bucket %d.\n", hash); #endif @@ -445,26 +445,26 @@ int CVAR_Register_S(cv_char_t * var_str, const char *var_name, const char *secti } // Displays the value and type of the given cvar to the console. -int CVAR_Print(R_CVAR_P con_cvar) { +int CVAR_Print(CVAR_P con_cvar) { switch (con_cvar->type) { - case R_CVAR_INT: + case CVAR_INT: _vm->_console->print("\"%s\"(i) = %d", con_cvar->name, *(con_cvar->t.i.var_p)); break; - case R_CVAR_UINT: + case CVAR_UINT: _vm->_console->print("\"%s\"(ui) = %u", con_cvar->name, *(con_cvar->t.ui.var_p)); break; - case R_CVAR_FLOAT: + case CVAR_FLOAT: _vm->_console->print("\"%s\"(ui) = %f", con_cvar->name, *(con_cvar->t.f.var_p)); break; - case R_CVAR_STRING: + case CVAR_STRING: _vm->_console->print("\"%s\"(s) = \"%s\"", con_cvar->name, con_cvar->t.s.var_str); break; - case R_CVAR_FUNC: + case CVAR_FUNC: if (con_cvar->t.func.func_argstr) { _vm->_console->print("\"%s\"(func) Args: %s", con_cvar->name, con_cvar->t.func.func_argstr); } else { @@ -477,7 +477,7 @@ int CVAR_Print(R_CVAR_P con_cvar) { break; } - return R_SUCCESS; + return SUCCESS; } } // End of namespace Saga diff --git a/saga/cvar.h b/saga/cvar.h index f030eac989..3f0fe48300 100644 --- a/saga/cvar.h +++ b/saga/cvar.h @@ -28,40 +28,40 @@ namespace Saga { -#define R_CVAR_HASHLEN 32 +#define CVAR_HASHLEN 32 -struct R_SUBCVAR_INT { +struct SUBCVAR_INT { cv_int_t *var_p; cv_int_t ubound; cv_int_t lbound; }; -struct R_SUBCVAR_UINT { +struct SUBCVAR_UINT { cv_uint16_t *var_p; cv_uint16_t ubound; cv_uint16_t lbound; }; -struct R_SUBCVAR_FLOAT { +struct SUBCVAR_FLOAT { cv_float_t *var_p; cv_float_t ubound; cv_float_t lbound; }; -struct R_SUBCVAR_STRING { +struct SUBCVAR_STRING { cv_char_t *var_str; int ubound; }; -struct R_SUBCVAR_FUNC { +struct SUBCVAR_FUNC { cv_func_t func_p; const char *func_argstr; int min_args; int max_args; }; -struct R_CVAR { +struct CVAR { int type; const char *name; const char *section; @@ -69,14 +69,14 @@ struct R_CVAR { void *refCon; union { - R_SUBCVAR_INT i; - R_SUBCVAR_UINT ui; - R_SUBCVAR_FLOAT f; - R_SUBCVAR_STRING s; - R_SUBCVAR_FUNC func; + SUBCVAR_INT i; + SUBCVAR_UINT ui; + SUBCVAR_FLOAT f; + SUBCVAR_STRING s; + SUBCVAR_FUNC func; } t; - R_CVAR *next; + CVAR *next; }; diff --git a/saga/cvar_mod.h b/saga/cvar_mod.h index 2a343ceedf..b428a9c0b2 100644 --- a/saga/cvar_mod.h +++ b/saga/cvar_mod.h @@ -40,35 +40,35 @@ typedef char cv_char_t; typedef void (*cv_func_t) (int cv_argc, char *cv_argv[], void *refCon); /******************************************/ -typedef struct R_CVAR *R_CVAR_P; // opaque typedef +typedef struct CVAR *CVAR_P; // opaque typedef -enum R_CVAR_TYPES { - R_CVAR_INVALID, - R_CVAR_INT, - R_CVAR_UINT, - R_CVAR_FLOAT, - R_CVAR_STRING, - R_CVAR_FUNC +enum CVAR_TYPES { + CVAR_INVALID, + CVAR_INT, + CVAR_UINT, + CVAR_FLOAT, + CVAR_STRING, + CVAR_FUNC }; -enum R_CVAR_FLAGS { - R_CVAR_NONE, - R_CVAR_READONLY, - R_CVAR_LBOUND, - R_CVAR_UBOUND, - R_CVAR_CFG, - R_CVAR_SECTION +enum CVAR_FLAGS { + CVAR_NONE, + CVAR_READONLY, + CVAR_LBOUND, + CVAR_UBOUND, + CVAR_CFG, + CVAR_SECTION }; -#define R_CVAR_BOUNDED ( R_CVAR_LBOUND | R_CVAR_UBOUND ) +#define CVAR_BOUNDED ( CVAR_LBOUND | CVAR_UBOUND ) int CVAR_Shutdown(); -R_CVAR_P CVAR_Find(const char *var_str); -int CVAR_SetValue(R_CVAR_P cvar, char *r_value); -int CVAR_Print(R_CVAR_P con_cvar); +CVAR_P CVAR_Find(const char *var_str); +int CVAR_SetValue(CVAR_P cvar, char *r_value); +int CVAR_Print(CVAR_P con_cvar); int CVAR_GetError(const char **err_str); -int CVAR_IsFunc(R_CVAR_P cvar_func); -int CVAR_Exec(R_CVAR_P cvar_func, char *r_value); +int CVAR_IsFunc(CVAR_P cvar_func); +int CVAR_Exec(CVAR_P cvar_func, char *r_value); int CVAR_RegisterFunc(cv_func_t func, const char *func_name, const char *func_argstr, uint16 flags, int min_args, int max_args, void *refCon); int CVAR_Register_I(cv_int_t * var_p, const char *var_name, @@ -78,7 +78,7 @@ int CVAR_Register_UI(cv_uint16_t * var_p, const char *var_name, int CVAR_Register_F(cv_float_t * var_p, const char *var_name, const char *section, uint16 flags, cv_float_t lbound, cv_float_t ubound); int CVAR_Register_S(cv_char_t * var_str, const char *var_name, const char *section, uint16 flags, int ubound); -int EXPR_Parse(const char **exp_pp, int *len, R_CVAR_P * expr_cvar, char **rvalue); +int EXPR_Parse(const char **exp_pp, int *len, CVAR_P * expr_cvar, char **rvalue); char *EXPR_ReadString(const char **string_p, int *len, int term_char); int EXPR_GetError(const char **err_str); int EXPR_GetArgs(char *cmd_str, char ***expr_argv); diff --git a/saga/events.cpp b/saga/events.cpp index 99cd2e5f9f..9d28c8ea72 100644 --- a/saga/events.cpp +++ b/saga/events.cpp @@ -64,7 +64,7 @@ int Events::handleEvents(long msec) { YS_DL_NODE *walk_node; YS_DL_NODE *next_node; - R_EVENT *event_p; + EVENT *event_p; long delta_time; int result; @@ -74,7 +74,7 @@ int Events::handleEvents(long msec) { // Process each event in list for (walk_node = ys_dll_head(_eventList); walk_node != NULL; walk_node = next_node) { - event_p = (R_EVENT *)ys_dll_get_data(walk_node); + event_p = (EVENT *)ys_dll_get_data(walk_node); // Save next event in case current event is handled and removed next_node = ys_dll_next(walk_node); @@ -82,31 +82,31 @@ int Events::handleEvents(long msec) { // Call the appropriate event handler for the specific event type switch (event_p->type) { - case R_ONESHOT_EVENT: + case ONESHOT_EVENT: result = handleOneShot(event_p); break; - case R_CONTINUOUS_EVENT: + case CONTINUOUS_EVENT: result = handleContinuous(event_p); break; - case R_INTERVAL_EVENT: + case INTERVAL_EVENT: result = handleInterval(event_p); break; - case R_IMMEDIATE_EVENT: + case IMMEDIATE_EVENT: result = handleImmediate(event_p); break; default: - result = R_EVENT_INVALIDCODE; + result = EVENT_INVALIDCODE; warning("Invalid event code encountered"); break; } // Process the event appropriately based on result code from // handler - if ((result == R_EVENT_DELETE) || (result == R_EVENT_INVALIDCODE)) { + if ((result == EVENT_DELETE) || (result == EVENT_INVALIDCODE)) { // If there is no event chain, delete the base event. if (event_p->chain == NULL) { ys_dll_delete(walk_node); @@ -118,26 +118,26 @@ int Events::handleEvents(long msec) { ys_dll_replace(walk_node, event_p->chain, sizeof *event_p); - event_p = (R_EVENT *)ys_dll_get_data(walk_node); + event_p = (EVENT *)ys_dll_get_data(walk_node); event_p->time += delta_time; next_node = walk_node; } - } else if (result == R_EVENT_BREAK) { + } else if (result == EVENT_BREAK) { break; } } - return R_SUCCESS; + return SUCCESS; } -int Events::handleContinuous(R_EVENT *event) { +int Events::handleContinuous(EVENT *event) { double event_pc = 0.0; // Event completion percentage int event_done = 0; - R_BUFFER_INFO buf_info; + BUFFER_INFO buf_info; SCENE_BGINFO bg_info; - R_SURFACE *back_buf; + SURFACE *back_buf; event_pc = ((double)event->duration - event->time) / event->duration; @@ -149,15 +149,15 @@ int Events::handleContinuous(R_EVENT *event) { if (event_pc < 0.0) { // Event not signaled, skip it - return R_EVENT_CONTINUE; - } else if (!(event->code & R_SIGNALED)) { + return EVENT_CONTINUE; + } else if (!(event->code & SIGNALED)) { // Signal event - event->code |= R_SIGNALED; + event->code |= SIGNALED; event_pc = 0.0; } - switch (event->code & R_EVENT_MASK) { - case R_PAL_EVENT: + switch (event->code & EVENT_MASK) { + case PAL_EVENT: switch (event->op) { case EVENT_BLACKTOPAL: back_buf = _vm->_gfx->getBackBuffer(); @@ -172,13 +172,13 @@ int Events::handleContinuous(R_EVENT *event) { break; } break; - case R_TRANSITION_EVENT: + case TRANSITION_EVENT: switch (event->op) { case EVENT_DISSOLVE: _vm->_render->getBufferInfo(&buf_info); _vm->_scene->getBGInfo(&bg_info); - _vm->transitionDissolve(buf_info.r_bg_buf, buf_info.r_bg_buf_w, - buf_info.r_bg_buf_h, buf_info.r_bg_buf_w, bg_info.bg_buf, bg_info.bg_w, + _vm->transitionDissolve(buf_info.bg_buf, buf_info.bg_buf_w, + buf_info.bg_buf_h, buf_info.bg_buf_w, bg_info.bg_buf, bg_info.bg_w, bg_info.bg_h, bg_info.bg_p, 0, 0, 0, event_pc); break; case EVENT_DISSOLVE_BGMASK: @@ -190,15 +190,15 @@ int Events::handleContinuous(R_EVENT *event) { _vm->_render->getBufferInfo(&buf_info); _vm->_scene->getBGMaskInfo(&w, &h, &mask_buf, &len); - _vm->transitionDissolve(buf_info.r_bg_buf, buf_info.r_bg_buf_w, - buf_info.r_bg_buf_h, buf_info.r_bg_buf_w, mask_buf, w, h, 0, 1, + _vm->transitionDissolve(buf_info.bg_buf, buf_info.bg_buf_w, + buf_info.bg_buf_h, buf_info.bg_buf_w, mask_buf, w, h, 0, 1, (320 - w) / 2, (200 - h) / 2, event_pc); break; default: break; } break; - case R_CONSOLE_EVENT: + case CONSOLE_EVENT: switch (event->op) { case EVENT_ACTIVATE: _vm->_console->dropConsole(event_pc); @@ -216,17 +216,17 @@ int Events::handleContinuous(R_EVENT *event) { } if (event_done) { - return R_EVENT_DELETE; + return EVENT_DELETE; } - return R_EVENT_CONTINUE; + return EVENT_CONTINUE; } -int Events::handleImmediate(R_EVENT *event) { +int Events::handleImmediate(EVENT *event) { double event_pc = 0.0; // Event completion percentage bool event_done = false; - R_SURFACE *back_buf; + SURFACE *back_buf; event_pc = ((double)event->duration - event->time) / event->duration; @@ -238,15 +238,15 @@ int Events::handleImmediate(R_EVENT *event) { if (event_pc < 0.0) { // Event not signaled, skip it - return R_EVENT_BREAK; - } else if (!(event->code & R_SIGNALED)) { + return EVENT_BREAK; + } else if (!(event->code & SIGNALED)) { // Signal event - event->code |= R_SIGNALED; + event->code |= SIGNALED; event_pc = 0.0; } - switch (event->code & R_EVENT_MASK) { - case R_PAL_EVENT: + switch (event->code & EVENT_MASK) { + case PAL_EVENT: switch (event->op) { case EVENT_BLACKTOPAL: back_buf = _vm->_gfx->getBackBuffer(); @@ -261,9 +261,9 @@ int Events::handleImmediate(R_EVENT *event) { break; } break; - case R_SCRIPT_EVENT: - case R_BG_EVENT: - case R_INTERFACE_EVENT: + case SCRIPT_EVENT: + case BG_EVENT: + case INTERFACE_EVENT: handleOneShot(event); event_done = true; break; @@ -273,35 +273,35 @@ int Events::handleImmediate(R_EVENT *event) { } if (event_done) { - return R_EVENT_DELETE; + return EVENT_DELETE; } - return R_EVENT_BREAK; + return EVENT_BREAK; } -int Events::handleOneShot(R_EVENT *event) { - R_SURFACE *back_buf; - R_SCRIPT_THREAD *sthread; +int Events::handleOneShot(EVENT *event) { + SURFACE *back_buf; + SCRIPT_THREAD *sthread; static SCENE_BGINFO bginfo; if (event->time > 0) { - return R_EVENT_CONTINUE; + return EVENT_CONTINUE; } // Event has been signaled - switch (event->code & R_EVENT_MASK) { - case R_TEXT_EVENT: + switch (event->code & EVENT_MASK) { + case TEXT_EVENT: switch (event->op) { case EVENT_DISPLAY: - _vm->textSetDisplay((R_TEXTLIST_ENTRY *)event->data, 1); + _vm->textSetDisplay((TEXTLIST_ENTRY *)event->data, 1); break; case EVENT_REMOVE: { - R_SCENE_INFO scene_info; + SCENE_INFO scene_info; _vm->_scene->getInfo(&scene_info); - _vm->textDeleteEntry(scene_info.text_list, (R_TEXTLIST_ENTRY *)event->data); + _vm->textDeleteEntry(scene_info.text_list, (TEXTLIST_ENTRY *)event->data); } break; default: @@ -309,20 +309,20 @@ int Events::handleOneShot(R_EVENT *event) { } break; - case R_VOICE_EVENT: + case VOICE_EVENT: _vm->_sndRes->playVoice(event->param); break; - case R_MUSIC_EVENT: + case MUSIC_EVENT: _vm->_music->stop(); if (event->op == EVENT_PLAY) _vm->_music->play(event->param, event->param2); break; - case R_BG_EVENT: + case BG_EVENT: { - R_BUFFER_INFO rbuf_info; + BUFFER_INFO rbuf_info; Point bg_pt; - if (_vm->_scene->getMode() == R_SCENE_MODE_NORMAL) { + if (_vm->_scene->getMode() == SCENE_MODE_NORMAL) { back_buf = _vm->_gfx->getBackBuffer(); @@ -332,7 +332,7 @@ int Events::handleOneShot(R_EVENT *event) { bg_pt.x = bginfo.bg_x; bg_pt.y = bginfo.bg_y; - _vm->_gfx->bufToBuffer(rbuf_info.r_bg_buf, rbuf_info.r_bg_buf_w, rbuf_info.r_bg_buf_h, + _vm->_gfx->bufToBuffer(rbuf_info.bg_buf, rbuf_info.bg_buf_w, rbuf_info.bg_buf_h, bginfo.bg_buf, bginfo.bg_w, bginfo.bg_h, NULL, &bg_pt); if (event->param == SET_PALETTE) { PALENTRY *pal_p; @@ -342,7 +342,7 @@ int Events::handleOneShot(R_EVENT *event) { } } break; - case R_ANIM_EVENT: + case ANIM_EVENT: switch (event->op) { case EVENT_FRAME: _vm->_anim->play(event->param, event->time); @@ -357,17 +357,17 @@ int Events::handleOneShot(R_EVENT *event) { break; } break; - case R_SCENE_EVENT: + case SCENE_EVENT: switch (event->op) { case EVENT_END: _vm->_scene->nextScene(); - return R_EVENT_BREAK; + return EVENT_BREAK; break; default: break; } break; - case R_PALANIM_EVENT: + case PALANIM_EVENT: switch (event->op) { case EVENT_CYCLESTART: _vm->_palanim->cycleStart(); @@ -379,7 +379,7 @@ int Events::handleOneShot(R_EVENT *event) { break; } break; - case R_INTERFACE_EVENT: + case INTERFACE_EVENT: switch (event->op) { case EVENT_ACTIVATE: _vm->_interface->activate(); @@ -388,7 +388,7 @@ int Events::handleOneShot(R_EVENT *event) { break; } break; - case R_SCRIPT_EVENT: + case SCRIPT_EVENT: debug(0, "Starting start script #%d", event->param); sthread = _vm->_script->SThreadCreate(); @@ -412,18 +412,18 @@ int Events::handleOneShot(R_EVENT *event) { break; } - return R_EVENT_DELETE; + return EVENT_DELETE; } -int Events::handleInterval(R_EVENT *event) { - return R_EVENT_DELETE; +int Events::handleInterval(EVENT *event) { + return EVENT_DELETE; } // Schedules an event in the event list; returns a pointer to the scheduled // event suitable for chaining if desired. -R_EVENT *Events::queue(R_EVENT *event) { +EVENT *Events::queue(EVENT *event) { YS_DL_NODE *new_node; - R_EVENT *queued_event; + EVENT *queued_event; event->chain = NULL; new_node = ys_dll_add_tail(_eventList, event, sizeof *event); @@ -432,7 +432,7 @@ R_EVENT *Events::queue(R_EVENT *event) { return NULL; } - queued_event = (R_EVENT *)ys_dll_get_data(new_node); + queued_event = (EVENT *)ys_dll_get_data(new_node); initializeEvent(queued_event); @@ -441,12 +441,12 @@ R_EVENT *Events::queue(R_EVENT *event) { // Places a 'add_event' on the end of an event chain given by 'head_event' // (head_event may be in any position in the event chain) -R_EVENT *Events::chain(R_EVENT *head_event, R_EVENT *add_event) { - R_EVENT *walk_event; - R_EVENT *new_event; +EVENT *Events::chain(EVENT *head_event, EVENT *add_event) { + EVENT *walk_event; + EVENT *new_event; // Allocate space for new event - new_event = (R_EVENT *)malloc(sizeof *new_event); + new_event = (EVENT *)malloc(sizeof *new_event); if (new_event == NULL) { return NULL; } @@ -467,38 +467,38 @@ R_EVENT *Events::chain(R_EVENT *head_event, R_EVENT *add_event) { return new_event; } -int Events::initializeEvent(R_EVENT *event) { +int Events::initializeEvent(EVENT *event) { switch (event->type) { - case R_ONESHOT_EVENT: + case ONESHOT_EVENT: break; - case R_CONTINUOUS_EVENT: - case R_IMMEDIATE_EVENT: + case CONTINUOUS_EVENT: + case IMMEDIATE_EVENT: event->time += event->duration; break; - case R_INTERVAL_EVENT: + case INTERVAL_EVENT: break; default: - return R_FAILURE; + return FAILURE; break; } - return R_SUCCESS; + return SUCCESS; } int Events::clearList() { YS_DL_NODE *walk_node; YS_DL_NODE *next_node; - R_EVENT *chain_walk; - R_EVENT *next_chain; - R_EVENT *event_p; + EVENT *chain_walk; + EVENT *next_chain; + EVENT *event_p; // Walk down event list for (walk_node = ys_dll_head(_eventList); walk_node != NULL; walk_node = next_node) { next_node = ys_dll_next(walk_node); - event_p = (R_EVENT *)ys_dll_get_data(walk_node); + event_p = (EVENT *)ys_dll_get_data(walk_node); - // Only remove events not marked R_NODESTROY (engine events) - if (!(event_p->code & R_NODESTROY)) { + // Only remove events not marked NODESTROY (engine events) + if (!(event_p->code & NODESTROY)) { // Remove any events chained off this one */ for (chain_walk = event_p->chain; chain_walk != NULL; chain_walk = next_chain) { next_chain = chain_walk->chain; @@ -508,20 +508,20 @@ int Events::clearList() { } } - return R_SUCCESS; + return SUCCESS; } -// Removes all events from the list (even R_NODESTROY) +// Removes all events from the list (even NODESTROY) int Events::freeList() { YS_DL_NODE *walk_node; YS_DL_NODE *next_node; - R_EVENT *chain_walk; - R_EVENT *next_chain; - R_EVENT *event_p; + EVENT *chain_walk; + EVENT *next_chain; + EVENT *event_p; // Walk down event list for (walk_node = ys_dll_head(_eventList); walk_node != NULL; walk_node = next_node) { - event_p = (R_EVENT *)ys_dll_get_data(walk_node); + event_p = (EVENT *)ys_dll_get_data(walk_node); // Remove any events chained off current node for (chain_walk = event_p->chain; chain_walk != NULL; chain_walk = next_chain) { next_chain = chain_walk->chain; @@ -533,29 +533,29 @@ int Events::freeList() { ys_dll_delete(walk_node); } - return R_SUCCESS; + return SUCCESS; } // Walks down the event list, updating event times by 'msec'. int Events::processEventTime(long msec) { YS_DL_NODE *walk_node; - R_EVENT *event_p; + EVENT *event_p; uint16 event_count = 0; for (walk_node = ys_dll_head(_eventList); walk_node != NULL; walk_node = ys_dll_next(walk_node)) { - event_p = (R_EVENT *)ys_dll_get_data(walk_node); + event_p = (EVENT *)ys_dll_get_data(walk_node); event_p->time -= msec; event_count++; - if (event_p->type == R_IMMEDIATE_EVENT) + if (event_p->type == IMMEDIATE_EVENT) break; - if (event_count > R_EVENT_WARNINGCOUNT) { - warning("Event list exceeds %u", R_EVENT_WARNINGCOUNT); + if (event_count > EVENT_WARNINGCOUNT) { + warning("Event list exceeds %u", EVENT_WARNINGCOUNT); } } - return R_SUCCESS; + return SUCCESS; } } // End of namespace Saga diff --git a/saga/events.h b/saga/events.h index 85d46329f9..aaf72e6f85 100644 --- a/saga/events.h +++ b/saga/events.h @@ -27,36 +27,36 @@ #define SAGA_EVENT_H namespace Saga { -enum R_EVENT_TYPES { - R_ONESHOT_EVENT, - R_CONTINUOUS_EVENT, - R_INTERVAL_EVENT, - R_IMMEDIATE_EVENT +enum EVENT_TYPES { + ONESHOT_EVENT, + CONTINUOUS_EVENT, + INTERVAL_EVENT, + IMMEDIATE_EVENT }; -enum R_EVENT_FLAGS { - R_SIGNALED = 0x8000, - R_NODESTROY = 0x4000 +enum EVENT_FLAGS { + SIGNALED = 0x8000, + NODESTROY = 0x4000 }; -enum R_EVENT_CODES { - R_BG_EVENT = 1, - R_ANIM_EVENT, - R_MUSIC_EVENT, - R_VOICE_EVENT, - R_SOUND_EVENT, - R_SCENE_EVENT, - R_TEXT_EVENT, - R_PAL_EVENT, - R_PALANIM_EVENT, - R_TRANSITION_EVENT, - R_INTERFACE_EVENT, - R_CONSOLE_EVENT, - R_ACTOR_EVENT, - R_SCRIPT_EVENT +enum EVENT_CODES { + BG_EVENT = 1, + ANIM_EVENT, + MUSIC_EVENT, + VOICE_EVENT, + SOUND_EVENT, + SCENE_EVENT, + TEXT_EVENT, + PAL_EVENT, + PALANIM_EVENT, + TRANSITION_EVENT, + INTERFACE_EVENT, + CONSOLE_EVENT, + ACTOEVENT, + SCRIPT_EVENT }; -enum R_EVENT_OPS { +enum EVENT_OPS { // INSTANTANEOUS events // BG events EVENT_DISPLAY = 1, @@ -93,12 +93,12 @@ enum R_EVENT_OPS { EVENT_DISSOLVE_BGMASK = 2 }; -enum R_EVENT_PARAMS { +enum EVENT_PARAMS { NO_SET_PALETTE, SET_PALETTE }; -struct R_EVENT { +struct EVENT { unsigned int type; unsigned int code; // Event operation category & flags int op; // Event operation @@ -112,18 +112,18 @@ struct R_EVENT { long duration; // Duration of event long d_reserved; - R_EVENT *chain; // Event chain (For consecutive events) - R_EVENT() { memset(this, 0, sizeof(*this)); } + EVENT *chain; // Event chain (For consecutive events) + EVENT() { memset(this, 0, sizeof(*this)); } }; -#define R_EVENT_WARNINGCOUNT 1000 -#define R_EVENT_MASK 0x00FF +#define EVENT_WARNINGCOUNT 1000 +#define EVENT_MASK 0x00FF -enum R_EVENT_STATUSCODE { - R_EVENT_INVALIDCODE = 0, - R_EVENT_DELETE, - R_EVENT_CONTINUE, - R_EVENT_BREAK +enum EVENT_STATUSCODE { + EVENT_INVALIDCODE = 0, + EVENT_DELETE, + EVENT_CONTINUE, + EVENT_BREAK }; class Events { @@ -133,16 +133,16 @@ class Events { int handleEvents(long msec); int clearList(); int freeList(); - R_EVENT *queue(R_EVENT *event); - R_EVENT *chain(R_EVENT *eead_event, R_EVENT *add_event); + EVENT *queue(EVENT *event); + EVENT *chain(EVENT *eead_event, EVENT *add_event); private: - int handleContinuous(R_EVENT * event); - int handleOneShot(R_EVENT * event); - int handleInterval(R_EVENT * event); - int handleImmediate(R_EVENT *event); + int handleContinuous(EVENT * event); + int handleOneShot(EVENT * event); + int handleInterval(EVENT * event); + int handleImmediate(EVENT *event); int processEventTime(long msec); - int initializeEvent(R_EVENT * event); + int initializeEvent(EVENT * event); private: SagaEngine *_vm; diff --git a/saga/expr.cpp b/saga/expr.cpp index 9de0681906..ea744a1c4f 100644 --- a/saga/expr.cpp +++ b/saga/expr.cpp @@ -72,13 +72,13 @@ int EXPR_GetError(const char **err_str) { } // Parses an interactive expression. -// Sets 'expr_cvar' to the cvar/cfunction identifier input by the user, and +// Sets 'expCVAR' to the cvar/cfunction identifier input by the user, and // 'rvalue' to the corresponding rvalue ( in an expression ) or argument string // ( in a function call ). // // Memory pointed to by rvalue after return must be explicitly freed by the // caller. -int EXPR_Parse(const char **exp_pp, int *len, R_CVAR_P *expr_cvar, char **rvalue) { +int EXPR_Parse(const char **exp_pp, int *len, CVAR_P *expCVAR, char **rvalue) { int i; int in_char; int equ_offset = 0; @@ -96,7 +96,7 @@ int EXPR_Parse(const char **exp_pp, int *len, R_CVAR_P *expr_cvar, char **rvalue int test_char = '\0'; int have_func = 0; - R_CVAR_P lvalue_cvar; + CVAR_P lvalue_cvar; expr_p = *exp_pp; expr_len = strlen(*exp_pp); @@ -113,14 +113,14 @@ int EXPR_Parse(const char **exp_pp, int *len, R_CVAR_P *expr_cvar, char **rvalue if ((i == 0) && isdigit(in_char)) { // First character of a valid identifier cannot be a digit EXPR_ErrorState = EXERR_ILLEGAL; - return R_FAILURE; + return FAILURE; } // If we reach a character that isn't valid in an identifier... if ((!isalnum(in_char)) && ((in_char != '_'))) { // then eat remaining whitespace, if any - equ_offset = strspn(scan_p, R_EXPR_WHITESPACE); + equ_offset = strspn(scan_p, EXPR_WHITESPACE); test_char = scan_p[equ_offset]; // and test for the only valid characters after an identifier if ((test_char != '=') && (test_char != '\0') && (test_char != '(')) { @@ -129,7 +129,7 @@ int EXPR_Parse(const char **exp_pp, int *len, R_CVAR_P *expr_cvar, char **rvalue } else { EXPR_ErrorState = EXERR_EXPR; } - return R_FAILURE; + return FAILURE; } break; } @@ -140,7 +140,7 @@ int EXPR_Parse(const char **exp_pp, int *len, R_CVAR_P *expr_cvar, char **rvalue if (lvalue_str == NULL) { EXPR_ErrorState = EXERR_MEM; - return R_FAILURE; + return FAILURE; } strncpy(lvalue_str, expr_p, lvalue_len); @@ -150,7 +150,7 @@ int EXPR_Parse(const char **exp_pp, int *len, R_CVAR_P *expr_cvar, char **rvalue lvalue_cvar = CVAR_Find(lvalue_str); if (lvalue_cvar == NULL) { EXPR_ErrorState = EXERR_NOTFOUND; - return R_FAILURE; + return FAILURE; } if (lvalue_str) { free(lvalue_str); @@ -170,7 +170,7 @@ int EXPR_Parse(const char **exp_pp, int *len, R_CVAR_P *expr_cvar, char **rvalue if (rvalue_str != NULL) { // Successfully read string //CON_Print("Read function parameters \"%s\".", rvalue_str); - *expr_cvar = lvalue_cvar; + *expCVAR = lvalue_cvar; *rvalue = rvalue_str; scan_len = (scan_p - expr_p); @@ -179,26 +179,26 @@ int EXPR_Parse(const char **exp_pp, int *len, R_CVAR_P *expr_cvar, char **rvalue *len -= scan_len; EXPR_ErrorState = EXERR_NONE; - return R_SUCCESS; + return SUCCESS; } else { EXPR_ErrorState = EXERR_PAREN; - return R_FAILURE; + return FAILURE; } } else { EXPR_ErrorState = EXERR_NOTFUNC; - return R_FAILURE; + return FAILURE; } } // Eat more whitespace - rvalue_offset = strspn(scan_p, R_EXPR_WHITESPACE); + rvalue_offset = strspn(scan_p, EXPR_WHITESPACE); if (rvalue_offset + i == expr_len) { // Only found single lvalue - *expr_cvar = lvalue_cvar; + *expCVAR = lvalue_cvar; *exp_pp = scan_p; *len -= scan_len; - return R_SUCCESS; + return SUCCESS; } scan_p += rvalue_offset; @@ -217,7 +217,7 @@ int EXPR_Parse(const char **exp_pp, int *len, R_CVAR_P *expr_cvar, char **rvalue break; } else { EXPR_ErrorState = EXERR_LITERAL; - return R_FAILURE; + return FAILURE; } break; @@ -238,16 +238,16 @@ int EXPR_Parse(const char **exp_pp, int *len, R_CVAR_P *expr_cvar, char **rvalue break; } else { EXPR_ErrorState = EXERR_STRING; - return R_FAILURE; + return FAILURE; } } else { EXPR_ErrorState = EXERR_NUMBER; - return R_FAILURE; + return FAILURE; } break; } - *expr_cvar = lvalue_cvar; + *expCVAR = lvalue_cvar; *rvalue = rvalue_str; scan_len = (scan_p - expr_p); @@ -256,7 +256,7 @@ int EXPR_Parse(const char **exp_pp, int *len, R_CVAR_P *expr_cvar, char **rvalue *len -= scan_len; EXPR_ErrorState = EXERR_NONE; - return R_SUCCESS; + return SUCCESS; } @@ -331,7 +331,7 @@ int EXPR_GetArgs(char *cmd_str, char ***expr_argv) { *expr_argv = (char **)malloc((expr_argc + 1) * sizeof(**expr_argv)); if (expr_argv == NULL) { - return R_FAILURE; + return FAILURE; } EXPR_ParseArgs(cmd_str, *expr_argv); diff --git a/saga/expr.h b/saga/expr.h index c89795efef..f003ff04a6 100644 --- a/saga/expr.h +++ b/saga/expr.h @@ -28,7 +28,7 @@ namespace Saga { -#define R_EXPR_WHITESPACE "\t\n " +#define EXPR_WHITESPACE " \n " int EXPR_ParseArgs(char *cmd_str, char **argv); diff --git a/saga/font.cpp b/saga/font.cpp index 0de00a92f1..f581a293fe 100644 --- a/saga/font.cpp +++ b/saga/font.cpp @@ -33,12 +33,12 @@ namespace Saga { Font::Font(SagaEngine *vm) : _vm(vm), _initialized(false) { - R_GAME_FONTDESC *gamefonts; + GAME_FONTDESC *gamefonts; int i; // Load font module resource context if (GAME_GetFileContext(&_fontContext, - R_GAME_RESOURCEFILE, 0) != R_SUCCESS) { + GAME_RESOURCEFILE, 0) != SUCCESS) { error("Font::Font(): Couldn't get resource context."); } @@ -47,7 +47,7 @@ Font::Font(SagaEngine *vm) : _vm(vm), _initialized(false) { assert(_nFonts > 0); - _fonts = (R_FONT **)malloc(_nFonts * sizeof *_fonts); + _fonts = (FONT **)malloc(_nFonts * sizeof *_fonts); if (_fonts == NULL) { error("Font::Font(): Memory allocation failure."); } @@ -64,7 +64,7 @@ Font::~Font(void) { debug(0, "Font::~Font(): Freeing fonts."); /* - for ( i = 0 ; i < R_FONT_COUNT ; i ++ ) { + for ( i = 0 ; i < FONT_COUNT ; i ++ ) { if ( _fonts[i] != NULL ) { if ( _fonts[i]->normal_loaded ) { free( _fonts[i]->normal->font_free_p ); @@ -83,35 +83,35 @@ Font::~Font(void) { } int Font::loadFont(uint32 font_rn, int font_id) { - R_FONT_HEADER fh; - R_FONT *font; - R_FONT_STYLE *normal_font; + FONT_HEADER fh; + FONT *font; + FONT_STYLE *normal_font; byte *fontres_p; size_t fontres_len; int nbits; int c; if ((font_id < 0) || (font_id >= _nFonts)) { - return R_FAILURE; + return FAILURE; } // Load font resource - if (RSC_LoadResource(_fontContext, font_rn, &fontres_p, &fontres_len) != R_SUCCESS) { + if (RSC_LoadResource(_fontContext, font_rn, &fontres_p, &fontres_len) != SUCCESS) { error("Font::loadFont(): Couldn't load font resource."); - return R_FAILURE; + return FAILURE; } - if (fontres_len < R_FONT_DESCSIZE) { + if (fontres_len < FONT_DESCSIZE) { error("Font::loadFont(): Invalid font length."); } MemoryReadStream readS(fontres_p, fontres_len); // Create new font structure - font = (R_FONT *)malloc(sizeof *font); + font = (FONT *)malloc(sizeof *font); if (font == NULL) { error("Font:loadFont(): Memory allocation error."); - return R_MEM; + return MEM; } // Read font header @@ -121,16 +121,16 @@ int Font::loadFont(uint32 font_rn, int font_id) { debug(1, "Font::loadFont(): Reading font resource..."); - debug(2, "Character width:\t%d", fh.c_width); - debug(2, "Character height:\t%d", fh.c_height); - debug(2, "Row padding:\t%d", fh.row_length); + debug(2, "Character width: %d", fh.c_width); + debug(2, "Character height: %d", fh.c_height); + debug(2, "Row padding: %d", fh.row_length); // Create normal font style - normal_font = (R_FONT_STYLE *)malloc(sizeof *normal_font); + normal_font = (FONT_STYLE *)malloc(sizeof *normal_font); if (normal_font == NULL) { error("Font::loadFont(): Memory allocation error."); free(font); - return R_MEM; + return MEM; } normal_font->font_free_p = fontres_p; @@ -138,29 +138,29 @@ int Font::loadFont(uint32 font_rn, int font_id) { normal_font->hdr.c_width = fh.c_width; normal_font->hdr.row_length = fh.row_length; - for (c = 0; c < R_FONT_CHARCOUNT; c++) { + for (c = 0; c < FONT_CHARCOUNT; c++) { normal_font->fce[c].index = readS.readUint16LE(); } - for (c = 0; c < R_FONT_CHARCOUNT; c++) { + for (c = 0; c < FONT_CHARCOUNT; c++) { nbits = normal_font->fce[c].width = readS.readByte(); normal_font->fce[c].byte_width = getByteLen(nbits); } - for (c = 0; c < R_FONT_CHARCOUNT; c++) { + for (c = 0; c < FONT_CHARCOUNT; c++) { normal_font->fce[c].flag = readS.readByte(); } - for (c = 0; c < R_FONT_CHARCOUNT; c++) { + for (c = 0; c < FONT_CHARCOUNT; c++) { normal_font->fce[c].tracking = readS.readByte(); } - if (readS.pos() != R_FONT_DESCSIZE) { + if (readS.pos() != FONT_DESCSIZE) { warning("Invalid font resource size."); - return R_FAILURE; + return FAILURE; } - normal_font->font_p = fontres_p + R_FONT_DESCSIZE; + normal_font->font_p = fontres_p + FONT_DESCSIZE; font->normal = normal_font; font->normal_loaded = 1; @@ -172,19 +172,19 @@ int Font::loadFont(uint32 font_rn, int font_id) { // Set font data _fonts[font_id] = font; - return R_SUCCESS; + return SUCCESS; } int Font::getHeight(int font_id) { - R_FONT *font; + FONT *font; if (!_initialized) { - return R_FAILURE; + return FAILURE; } if ((font_id < 0) || (font_id >= _nFonts) || (_fonts[font_id] == NULL)) { error("Font::getHeight(): Invalid font id."); - return R_FAILURE; + return FAILURE; } font = _fonts[font_id]; @@ -192,8 +192,8 @@ int Font::getHeight(int font_id) { return font->normal->hdr.c_height; } -R_FONT_STYLE *Font::createOutline(R_FONT_STYLE *src_font) { - R_FONT_STYLE *new_font; +FONT_STYLE *Font::createOutline(FONT_STYLE *src_font) { + FONT_STYLE *new_font; unsigned char *new_font_data; size_t new_font_data_len; int s_width = src_font->hdr.c_width; @@ -214,7 +214,7 @@ R_FONT_STYLE *Font::createOutline(R_FONT_STYLE *src_font) { unsigned char c_rep; // Create new font style structure - new_font = (R_FONT_STYLE *)malloc(sizeof *new_font); + new_font = (FONT_STYLE *)malloc(sizeof *new_font); if (new_font == NULL) { error("Font::createOutline(): Memory allocation error."); @@ -224,11 +224,11 @@ R_FONT_STYLE *Font::createOutline(R_FONT_STYLE *src_font) { memset(new_font, 0, sizeof *new_font); // Populate new font style character data - for (i = 0; i < R_FONT_CHARCOUNT; i++) { + for (i = 0; i < FONT_CHARCOUNT; i++) { new_byte_width = 0; old_byte_width = 0; index = src_font->fce[i].index; - if ((index > 0) || (i == R_FONT_FIRSTCHAR)) { + if ((index > 0) || (i == FONT_FIRSTCHAR)) { index += index_offset; } @@ -271,7 +271,7 @@ R_FONT_STYLE *Font::createOutline(R_FONT_STYLE *src_font) { new_font->font_p = new_font_data; // Generate outline font representation - for (i = 0; i < R_FONT_CHARCOUNT; i++) { + for (i = 0; i < FONT_CHARCOUNT; i++) { for (row = 0; row < s_height; row++) { for (current_byte = 0; current_byte < new_font->fce[i].byte_width; current_byte++) { base_ptr = new_font->font_p + new_font->fce[i].index + current_byte; @@ -338,19 +338,19 @@ int Font::getByteLen(int num_bits) { // into account any formatting options specified by 'flags'. // If 'test_str_ct' is 0, all characters of 'test_str' are counted. int Font::getStringWidth(int font_id, const char *test_str, size_t test_str_ct, int flags) { - R_FONT *font; + FONT *font; size_t ct; int width = 0; int ch; const byte *txt_p; if (!_initialized) { - return R_FAILURE; + return FAILURE; } if ((font_id < 0) || (font_id >= _nFonts) || (_fonts[font_id] == NULL)) { error("Font::getStringWidth(): Invalid font id."); - return R_FAILURE; + return FAILURE; } font = _fonts[font_id]; @@ -362,7 +362,7 @@ int Font::getStringWidth(int font_id, const char *test_str, size_t test_str_ct, ch = *txt_p & 0xFFU; // Translate character ch = _charMap[ch]; - assert(ch < R_FONT_CHARCOUNT); + assert(ch < FONT_CHARCOUNT); width += font->normal->fce[ch].tracking; } @@ -373,19 +373,19 @@ int Font::getStringWidth(int font_id, const char *test_str, size_t test_str_ct, return width; } -int Font::draw(int font_id, R_SURFACE *ds, const char *draw_str, size_t draw_str_ct, +int Font::draw(int font_id, SURFACE *ds, const char *draw_str, size_t draw_str_ct, int text_x, int text_y, int color, int effect_color, int flags) { - R_FONT *font; + FONT *font; if (!_initialized) { error("Font::draw(): Font Module not initialized."); - return R_FAILURE; + return FAILURE; } if ((font_id < 0) || (font_id >= _nFonts) || (_fonts[font_id] == NULL)) { error("Font::draw(): Invalid font id."); - return R_FAILURE; + return FAILURE; } font = _fonts[font_id]; @@ -400,10 +400,10 @@ int Font::draw(int font_id, R_SURFACE *ds, const char *draw_str, size_t draw_str outFont(font->normal, ds, draw_str, draw_str_ct, text_x, text_y, color); } - return R_SUCCESS; + return SUCCESS; } -int Font::outFont(R_FONT_STYLE * draw_font, R_SURFACE * ds, const char *draw_str, size_t draw_str_ct, +int Font::outFont(FONT_STYLE * draw_font, SURFACE * ds, const char *draw_str, size_t draw_str_ct, int text_x, int text_y, int color) { const byte *draw_str_p; byte *c_data_ptr; @@ -424,7 +424,7 @@ int Font::outFont(R_FONT_STYLE * draw_font, R_SURFACE * ds, const char *draw_str if ((text_x > ds->buf_w) || (text_y > ds->buf_h)) { // Output string can't be visible - return R_SUCCESS; + return SUCCESS; } draw_str_p = (const byte *) draw_str; @@ -437,16 +437,16 @@ int Font::outFont(R_FONT_STYLE * draw_font, R_SURFACE * ds, const char *draw_str // Translate character c_code = _charMap[c_code]; - assert(c_code < R_FONT_CHARCOUNT); + assert(c_code < FONT_CHARCOUNT); // Check if character is defined - if ((draw_font->fce[c_code].index == 0) && (c_code != R_FONT_FIRSTCHAR)) { -#if R_FONT_SHOWUNDEFINED - if (c_code == R_FONT_CH_SPACE) { + if ((draw_font->fce[c_code].index == 0) && (c_code != FONT_FIRSTCHAR)) { +#if FONT_SHOWUNDEFINED + if (c_code == FONT_CH_SPACE) { text_x += draw_font->fce[c_code].tracking; continue; } - c_code = R_FONT_CH_QMARK; + c_code = FONT_CH_QMARK; #else // Character code is not defined, but advance tracking // ( Not defined if offset is 0, except for 33 ('!') which @@ -493,7 +493,7 @@ int Font::outFont(R_FONT_STYLE * draw_font, R_SURFACE * ds, const char *draw_str text_x += draw_font->fce[c_code].tracking; } // end per-character processing - return R_SUCCESS; + return SUCCESS; } } // End of namespace Saga diff --git a/saga/font.h b/saga/font.h index 49063174df..0db43920fa 100644 --- a/saga/font.h +++ b/saga/font.h @@ -30,21 +30,21 @@ namespace Saga { -#define R_FONT_SHOWUNDEFINED 1 // Define to draw undefined characters * as ?'s +#define FONT_SHOWUNDEFINED 1 // Define to draw undefined characters * as ?'s // The first defined character (!) is the only one that may // have a valid offset of '0' -#define R_FONT_FIRSTCHAR 33 +#define FONT_FIRSTCHAR 33 -#define R_FONT_CH_SPACE 32 -#define R_FONT_CH_QMARK 63 +#define FONT_CH_SPACE 32 +#define FONT_CH_QMARK 63 // Minimum font header size without font data // (6 + 512 + 256 + 256 + 256 ) -#define R_FONT_DESCSIZE 1286 +#define FONT_DESCSIZE 1286 -#define R_FONT_CHARCOUNT 256 -#define R_FONT_CHARMASK 0xFFU +#define FONT_CHARCOUNT 256 +#define FONT_CHARMASK 0xFFU #define SAGA_FONT_HEADER_LEN 6 @@ -62,7 +62,7 @@ enum FONT_EFFECT_FLAGS { FONT_CENTERED = 0x08 }; -struct R_FONT_HEADER { +struct FONT_HEADER { int c_height; int c_width; int row_length; @@ -76,21 +76,21 @@ struct FONT_CHAR_ENTRY { int tracking; }; -struct R_FONT_STYLE { - R_FONT_HEADER hdr; +struct FONT_STYLE { + FONT_HEADER hdr; FONT_CHAR_ENTRY fce[256]; byte *font_free_p; byte *font_p; }; -struct R_FONT { +struct FONT { uint32 font_rn; int font_id; int normal_loaded; - R_FONT_STYLE *normal; + FONT_STYLE *normal; int outline_loaded; - R_FONT_STYLE *outline; + FONT_STYLE *outline; byte *res_data; size_t res_len; @@ -100,7 +100,7 @@ class Font { public: Font(SagaEngine *vm); ~Font(void); - int draw(int font_id, R_SURFACE *ds, const char *draw_str, size_t draw_str_len, + int draw(int font_id, SURFACE *ds, const char *draw_str, size_t draw_str_len, int text_x, int text_y, int color, int effect_color, int flags); int getStringWidth(int font_id, const char *test_str, size_t test_str_ct, int flags); int getHeight(int font_id); @@ -108,8 +108,8 @@ class Font { private: int loadFont(uint32 font_rn, int font_id); - R_FONT_STYLE *createOutline(R_FONT_STYLE * src_font); - int outFont(R_FONT_STYLE *font, R_SURFACE * ds, const char *draw_str, size_t draw_str_ct, + FONT_STYLE *createOutline(FONT_STYLE * src_font); + int outFont(FONT_STYLE *font, SURFACE * ds, const char *draw_str, size_t draw_str_ct, int text_x, int text_y, int color); int getByteLen(int num_bits); @@ -117,10 +117,10 @@ class Font { SagaEngine *_vm; bool _initialized; - R_RSCFILE_CONTEXT *_fontContext; + RSCFILE_CONTEXT *_fontContext; int _nFonts; - R_FONT **_fonts; + FONT **_fonts; }; } // End of namespace Saga diff --git a/saga/game.cpp b/saga/game.cpp index f680f172f7..acc87f8f59 100644 --- a/saga/game.cpp +++ b/saga/game.cpp @@ -41,126 +41,126 @@ namespace Saga { // Inherit the Earth - DOS Demo version -R_GAME_FILEDESC ITEDEMO_GameFiles[] = { - {"ITE.RSC", R_GAME_RESOURCEFILE}, - {"ITE.DMO", R_GAME_DEMOFILE}, - {"SCRIPTS.RSC", R_GAME_SCRIPTFILE}, - {"VOICES.RSC", R_GAME_SOUNDFILE | R_GAME_VOICEFILE} +GAME_FILEDESC ITEDEMO_GameFiles[] = { + {"ITE.RSC", GAME_RESOURCEFILE}, + {"ITE.DMO", GAME_DEMOFILE}, + {"SCRIPTS.RSC", GAME_SCRIPTFILE}, + {"VOICES.RSC", GAME_SOUNDFILE | GAME_VOICEFILE} }; -R_GAME_FONTDESC ITEDEMO_GameFonts[] = { - {R_GAME_FONT_SMALL, 0}, - {R_GAME_FONT_MEDIUM, 1} +GAME_FONTDESC ITEDEMO_GameFonts[] = { + {GAME_FONT_SMALL, 0}, + {GAME_FONT_MEDIUM, 1} }; -R_GAME_SOUNDINFO ITEDEMO_GameSound = { - R_GAME_SOUND_VOC, 0, 0, 0 +GAME_SOUNDINFO ITEDEMO_GameSound = { + GAME_SOUND_VOC, 0, 0, 0 }; // Inherit the Earth - win32 Wyrmkeep Demo version -R_GAME_FILEDESC ITEWINDEMO_GameFiles[] = { - {"ITED.RSC", R_GAME_RESOURCEFILE}, - {"SCRIPTSD.RSC", R_GAME_SCRIPTFILE}, - {"SOUNDSD.RSC", R_GAME_SOUNDFILE}, - {"VOICESD.RSC", R_GAME_VOICEFILE} +GAME_FILEDESC ITEWINDEMO_GameFiles[] = { + {"ITED.RSC", GAME_RESOURCEFILE}, + {"SCRIPTSD.RSC", GAME_SCRIPTFILE}, + {"SOUNDSD.RSC", GAME_SOUNDFILE}, + {"VOICESD.RSC", GAME_VOICEFILE} }; // Inherit the Earth - Diskette version -R_GAME_FILEDESC ITEDISK_GameFiles[] = { - {"ITE.RSC", R_GAME_RESOURCEFILE} , - {"SCRIPTS.RSC", R_GAME_SCRIPTFILE} , - {"VOICES.RSC", R_GAME_SOUNDFILE | R_GAME_VOICEFILE} +GAME_FILEDESC ITEDISK_GameFiles[] = { + {"ITE.RSC", GAME_RESOURCEFILE} , + {"SCRIPTS.RSC", GAME_SCRIPTFILE} , + {"VOICES.RSC", GAME_SOUNDFILE | GAME_VOICEFILE} }; -R_GAME_FONTDESC ITEDISK_GameFonts[] = { - {R_GAME_FONT_MEDIUM, 0} , - {R_GAME_FONT_LARGE, 1} , - {R_GAME_FONT_SMALL, 2} +GAME_FONTDESC ITEDISK_GameFonts[] = { + {GAME_FONT_MEDIUM, 0} , + {GAME_FONT_LARGE, 1} , + {GAME_FONT_SMALL, 2} }; -R_GAME_RESOURCEDESC ITE_Resources = { +GAME_RESOURCEDESC ITE_Resources = { ITE_SCENE_LUT, // Scene lookup table RN ITE_SCRIPT_LUT, // Script lookup table RN ITE_COMMAND_PANEL, ITE_DIALOGUE_PANEL }; -R_GAME_SOUNDINFO ITE_GameSound = { - R_GAME_SOUND_VOC, 0, 0, 0 +GAME_SOUNDINFO ITE_GameSound = { + GAME_SOUND_VOC, 0, 0, 0 }; // Inherit the Earth - CD Enhanced version -R_GAME_FILEDESC ITECD_GameFiles[] = { - {"ITE.RSC", R_GAME_RESOURCEFILE}, - {"SCRIPTS.RSC", R_GAME_SCRIPTFILE}, - {"SOUNDS.RSC", R_GAME_SOUNDFILE}, - {"VOICES.RSC", R_GAME_VOICEFILE} +GAME_FILEDESC ITECD_GameFiles[] = { + {"ITE.RSC", GAME_RESOURCEFILE}, + {"SCRIPTS.RSC", GAME_SCRIPTFILE}, + {"SOUNDS.RSC", GAME_SOUNDFILE}, + {"VOICES.RSC", GAME_VOICEFILE} }; -R_GAME_FONTDESC ITECD_GameFonts[] = { - {R_GAME_FONT_MEDIUM, 0}, - {R_GAME_FONT_LARGE, 1}, - {R_GAME_FONT_SMALL, 2} +GAME_FONTDESC ITECD_GameFonts[] = { + {GAME_FONT_MEDIUM, 0}, + {GAME_FONT_LARGE, 1}, + {GAME_FONT_SMALL, 2} }; -R_GAME_SOUNDINFO ITECD_GameSound = { - R_GAME_SOUND_PCM, +GAME_SOUNDINFO ITECD_GameSound = { + GAME_SOUND_PCM, 22050, 16, 0 }; // I Have No Mouth and I Must Scream - Demo version -R_GAME_FILEDESC IHNMDEMO_GameFiles[] = { - {"SCREAM.RES", R_GAME_RESOURCEFILE}, - {"SCRIPTS.RES", R_GAME_SCRIPTFILE}, - {"SFX.RES", R_GAME_SOUNDFILE}, - {"VOICESD.RES", R_GAME_VOICEFILE} +GAME_FILEDESC IHNMDEMO_GameFiles[] = { + {"SCREAM.RES", GAME_RESOURCEFILE}, + {"SCRIPTS.RES", GAME_SCRIPTFILE}, + {"SFX.RES", GAME_SOUNDFILE}, + {"VOICESD.RES", GAME_VOICEFILE} }; // I Have No Mouth and I Must Scream - Retail CD version -R_GAME_FILEDESC IHNMCD_GameFiles[] = { - {"MUSICFM.RES", R_GAME_MUSICFILE}, - {"MUSICGM.RES", R_GAME_MUSICFILE}, - {"SCREAM.RES", R_GAME_RESOURCEFILE}, - {"SCRIPTS.RES", R_GAME_SCRIPTFILE}, - {"SFX.RES", R_GAME_SOUNDFILE}, - {"VOICES1.RES", R_GAME_VOICEFILE}, - {"VOICES2.RES", R_GAME_VOICEFILE}, - {"VOICES3.RES", R_GAME_VOICEFILE}, - {"VOICES4.RES", R_GAME_VOICEFILE}, - {"VOICES5.RES", R_GAME_VOICEFILE}, - {"VOICES6.RES", R_GAME_VOICEFILE}, - {"VOICESS.RES", R_GAME_VOICEFILE} +GAME_FILEDESC IHNMCD_GameFiles[] = { + {"MUSICFM.RES", GAME_MUSICFILE}, + {"MUSICGM.RES", GAME_MUSICFILE}, + {"SCREAM.RES", GAME_RESOURCEFILE}, + {"SCRIPTS.RES", GAME_SCRIPTFILE}, + {"SFX.RES", GAME_SOUNDFILE}, + {"VOICES1.RES", GAME_VOICEFILE}, + {"VOICES2.RES", GAME_VOICEFILE}, + {"VOICES3.RES", GAME_VOICEFILE}, + {"VOICES4.RES", GAME_VOICEFILE}, + {"VOICES5.RES", GAME_VOICEFILE}, + {"VOICES6.RES", GAME_VOICEFILE}, + {"VOICESS.RES", GAME_VOICEFILE} }; -R_GAME_FONTDESC IHNMCD_GameFonts[] = { - {R_GAME_FONT_MEDIUM, 2}, - {R_GAME_FONT_LARGE, 3}, - {R_GAME_FONT_SMALL, 4}, - {R_GAME_FONT_SMALL2, 5}, - {R_GAME_FONT_MEDIUM2, 6}, - {R_GAME_FONT_LARGE2, 7}, - {R_GAME_FONT_LARGE3, 8} +GAME_FONTDESC IHNMCD_GameFonts[] = { + {GAME_FONT_MEDIUM, 2}, + {GAME_FONT_LARGE, 3}, + {GAME_FONT_SMALL, 4}, + {GAME_FONT_SMALL2, 5}, + {GAME_FONT_MEDIUM2, 6}, + {GAME_FONT_LARGE2, 7}, + {GAME_FONT_LARGE3, 8} }; -R_GAME_RESOURCEDESC IHNM_Resources = { +GAME_RESOURCEDESC IHNM_Resources = { IHNM_SCENE_LUT, // Scene lookup table RN IHNM_SCRIPT_LUT, // Script lookup table RN IHNM_COMMAND_PANEL, IHNM_DIALOGUE_PANEL }; -R_GAME_SOUNDINFO IHNM_GameSound = { - R_GAME_SOUND_WAV, 0, 0, 0 +GAME_SOUNDINFO IHNM_GameSound = { + GAME_SOUND_WAV, 0, 0, 0 }; -R_GAMEDESC GameDescs[] = { +GAMEDESC GameDescs[] = { // Inherit the earth - DOS Demo version { "ite-demo", GID_ITE, - R_GAME_ITE_DEMO, // Game id + GAME_ITE_DEMO, // Game id "Inherit the Earth (DOS Demo)", // Game title 320, 200, // Logical resolution 137, // Scene viewport height @@ -178,7 +178,7 @@ R_GAMEDESC GameDescs[] = { { "ite-demo-win", GID_ITE, - R_GAME_ITE_WINDEMO, + GAME_ITE_WINDEMO, "Inherit the Earth (Win32 Demo)", 320, 200, 137, @@ -197,7 +197,7 @@ R_GAMEDESC GameDescs[] = { { "itecd", GID_ITE, - R_GAME_ITE_CD, + GAME_ITE_CD, "Inherit the Earth (DOS CD Version)", 320, 200, 137, @@ -215,7 +215,7 @@ R_GAMEDESC GameDescs[] = { { "ite", GID_ITE, - R_GAME_ITE_DISK, + GAME_ITE_DISK, "Inherit the Earth (DOS)", 320, 200, 137, @@ -233,7 +233,7 @@ R_GAMEDESC GameDescs[] = { { "ihnm-demo", GID_IHNM, - R_GAME_IHNM_DEMO, + GAME_IHNM_DEMO, "I Have No Mouth and I Must Scream (DOS Demo)", 640, 480, 304, @@ -251,7 +251,7 @@ R_GAMEDESC GameDescs[] = { { "ihnm", GID_IHNM, - R_GAME_IHNM_CD, + GAME_IHNM_CD, "I Have No Mouth and I Must Scream (DOS)", 640, 480, 304, @@ -266,48 +266,48 @@ R_GAMEDESC GameDescs[] = { } }; -static R_GAMEMODULE GameModule; +static GAMEMODULE GameModule; int GAME_Register() { - return R_SUCCESS; + return SUCCESS; // Register "g_language" cfg cvar - strncpy(GameModule.game_language, "us", R_MAXPATH); + strncpy(GameModule.game_language, "us", MAXPATH); if (CVAR_Register_S(GameModule.game_language, "g_language", - NULL, R_CVAR_CFG, R_GAME_LANGSTR_LIMIT) != R_SUCCESS) { - return R_FAILURE; + NULL, CVAR_CFG, GAME_LANGSTR_LIMIT) != SUCCESS) { + return FAILURE; } // Register "g_skipintro" cfg cvar - if (CVAR_Register_I(&GameModule.g_skipintro, "g_skipintro", NULL, R_CVAR_CFG, 0, 1) != R_SUCCESS) { - return R_FAILURE; + if (CVAR_Register_I(&GameModule.g_skipintro, "g_skipintro", NULL, CVAR_CFG, 0, 1) != SUCCESS) { + return FAILURE; } - return R_SUCCESS; + return SUCCESS; } int GAME_Init() { uint16 game_n; - if (DetectGame(&game_n) != R_SUCCESS) { + if (DetectGame(&game_n) != SUCCESS) { warning("No valid games were found in the specified directory."); - return R_FAILURE; + return FAILURE; } - if (LoadGame(game_n) != R_SUCCESS) { + if (LoadGame(game_n) != SUCCESS) { warning("Error loading game resource files."); - return R_FAILURE; + return FAILURE; } // Load dialogue file LoadLanguage(); - return R_SUCCESS; + return SUCCESS; } int LoadLanguage() { - char lang_file[R_MAXPATH]; + char lang_file[MAXPATH]; uint16 game_n; File test_file; @@ -315,22 +315,22 @@ int LoadLanguage() { game_n = GameModule.game_number; if (GameDescs[game_n].gd_game_type == GID_ITE) { - snprintf(lang_file, R_MAXPATH, "%s%s.%s", R_GAME_ITE_LANG_PREFIX, GameModule.game_language, R_GAME_LANG_EXT); + snprintf(lang_file, MAXPATH, "%s%s.%s", GAME_ITE_LANG_PREFIX, GameModule.game_language, GAME_LANG_EXT); if (!test_file.open(lang_file)) { debug(0, "Couldn't open language file %s. Using default (US English)", lang_file); - return R_SUCCESS; + return SUCCESS; } test_file.close(); - if (_vm->_interface->registerLang() != R_SUCCESS) { + if (_vm->_interface->registerLang() != SUCCESS) { warning("Error registering interface language cvars"); - return R_FAILURE; + return FAILURE; } - if (_vm->_scene->ITEIntroRegisterLang() != R_SUCCESS) { + if (_vm->_scene->ITEIntroRegisterLang() != SUCCESS) { warning("Error registering intro sequence language cvars"); - return R_FAILURE; + return FAILURE; } debug(0, "Using language file %s.", lang_file); @@ -340,19 +340,19 @@ int LoadLanguage() { debug(0, "Language support for this game not implemented."); } - return R_SUCCESS; + return SUCCESS; } -int GAME_GetFileContext(R_RSCFILE_CONTEXT ** ctxt_p, uint16 r_type, int param) { - R_RSCFILE_CONTEXT *found_ctxt = NULL; +int GAME_GetFileContext(RSCFILE_CONTEXT ** ctxt_p, uint16 type, int param) { + RSCFILE_CONTEXT *found_ctxt = NULL; uint16 i; if (ctxt_p == NULL) { - return R_FAILURE; + return FAILURE; } for (i = 0; i < GameModule.gfile_n; i++) { - if (GameModule.gfile_data[i].file_types & r_type) { + if (GameModule.gfile_data[i].file_types & type) { found_ctxt = GameModule.gfile_data[i].file_ctxt; } } @@ -363,7 +363,7 @@ int GAME_GetFileContext(R_RSCFILE_CONTEXT ** ctxt_p, uint16 r_type, int param) { *ctxt_p = NULL; } - return R_SUCCESS; + return SUCCESS; } DetectedGameList GAME_ProbeGame(const FSList &fslist) { @@ -424,7 +424,7 @@ int DetectGame(uint16 *game_n_p) { int file_missing = 0; if (game_n_p == NULL) { - return R_FAILURE; + return FAILURE; } for (game_n = 0; game_n < game_count; game_n++) { @@ -448,28 +448,28 @@ int DetectGame(uint16 *game_n_p) { debug(0, "Found game: %s", GameDescs[game_n].gd_title); *game_n_p = game_n; - return R_SUCCESS; + return SUCCESS; } - return R_FAILURE; + return FAILURE; } int LoadGame(uint16 game_n) { - R_RSCFILE_CONTEXT *load_ctxt; + RSCFILE_CONTEXT *load_ctxt; uint16 game_count = ARRAYSIZE(GameDescs); const char *game_fname; uint16 game_filect; uint16 i; if (game_n >= game_count) { - return R_FAILURE; + return FAILURE; } game_filect = GameDescs[game_n].gd_filect; - GameModule.gfile_data = (R_GAME_FILEDATA *)malloc(game_filect * sizeof *GameModule.gfile_data); + GameModule.gfile_data = (GAME_FILEDATA *)malloc(game_filect * sizeof *GameModule.gfile_data); if (GameModule.gfile_data == NULL) { - return R_MEM; + return MEM; } GameModule.gfile_n = game_filect; @@ -478,8 +478,8 @@ int LoadGame(uint16 game_n) { for (i = 0; i < game_filect; i++) { load_ctxt = RSC_CreateContext(); game_fname = GameDescs[game_n].gd_filedescs[i].gf_fname; - if (RSC_OpenContext(load_ctxt, game_fname) != R_SUCCESS) { - return R_FAILURE; + if (RSC_OpenContext(load_ctxt, game_fname) != SUCCESS) { + return FAILURE; } debug(0, "Opened resource file: %s", game_fname); @@ -497,32 +497,32 @@ int LoadGame(uint16 game_n) { GameModule.gamedesc = &GameDescs[game_n]; GameModule.game_init = 1; - return R_SUCCESS; + return SUCCESS; } -int GAME_GetResourceInfo(R_GAME_RESOURCEDESC *rsc_desc) { +int GAME_GetResourceInfo(GAME_RESOURCEDESC *rsc_desc) { assert(rsc_desc != NULL); *rsc_desc = *GameModule.gamedesc->gd_resource_desc; - return R_SUCCESS; + return SUCCESS; } -int GAME_GetSoundInfo(R_GAME_SOUNDINFO *snd_info) { +int GAME_GetSoundInfo(GAME_SOUNDINFO *snd_info) { assert(snd_info != NULL); *snd_info = *GameModule.gamedesc->gd_soundinfo; - return R_SUCCESS; + return SUCCESS; } -int GAME_GetDisplayInfo(R_GAME_DISPLAYINFO *disp_info) { +int GAME_GetDisplayInfo(GAME_DISPLAYINFO *disp_info) { int game_n; assert(disp_info != NULL); if (!GameModule.game_init) { - return R_FAILURE; + return FAILURE; } game_n = GameModule.game_number; @@ -531,25 +531,25 @@ int GAME_GetDisplayInfo(R_GAME_DISPLAYINFO *disp_info) { disp_info->logical_h = GameDescs[game_n].gd_logical_h; disp_info->scene_h = GameDescs[game_n].gd_scene_h; - return R_SUCCESS; + return SUCCESS; } -int GAME_GetFontInfo(R_GAME_FONTDESC **gf_desc, int *font_n) { +int GAME_GetFontInfo(GAME_FONTDESC **gf_desc, int *font_n) { assert((gf_desc != NULL) && (font_n != NULL)); *gf_desc = GameModule.gd_fontdescs; *font_n = GameModule.gd_fontct; - return R_SUCCESS; + return SUCCESS; } -int GAME_GetSceneInfo(R_GAME_SCENEDESC *gs_desc) { +int GAME_GetSceneInfo(GAME_SCENEDESC *gs_desc) { assert(gs_desc != NULL); gs_desc->first_scene = GameModule.gamedesc->gd_startscene; gs_desc->scene_lut_rn = GameModule.gamedesc->gd_resource_desc->scene_lut_rn; - return R_SUCCESS; + return SUCCESS; } int GAME_GetGame() { diff --git a/saga/game.h b/saga/game.h index 19b55e5885..d92a15dcc2 100644 --- a/saga/game.h +++ b/saga/game.h @@ -30,22 +30,22 @@ namespace Saga { -#define R_GAME_LANGSTR_LIMIT 3 -#define R_GAME_PATH_LIMIT 512 +#define GAME_LANGSTR_LIMIT 3 +#define GAME_PATH_LIMIT 512 -#define R_GAME_ITE_LANG_PREFIX "ite_" -#define R_GAME_LANG_EXT "lng" +#define GAME_ITE_LANG_PREFIX "ite_" +#define GAME_LANG_EXT "lng" // Script lookup table entry sizes for game verification -#define R_SCR_LUT_ENTRYLEN_ITECD 22 -#define R_SCR_LUT_ENTRYLEN_ITEDISK 16 +#define SCR_LUT_ENTRYLEN_ITECD 22 +#define SCR_LUT_ENTRYLEN_ITEDISK 16 -struct R_GAME_FILEDESC { +struct GAME_FILEDESC { const char *gf_fname; uint16 gf_type; }; -struct R_GAMEDESC { +struct GAMEDESC { const char *name; int gd_game_type; uint32 gd_game_id; @@ -54,12 +54,12 @@ struct R_GAMEDESC { int gd_logical_h; int gd_scene_h; int gd_startscene; - R_GAME_RESOURCEDESC *gd_resource_desc; + GAME_RESOURCEDESC *gd_resource_desc; int gd_filect; - R_GAME_FILEDESC *gd_filedescs; + GAME_FILEDESC *gd_filedescs; int gd_fontct; - R_GAME_FONTDESC *gd_fontdescs; - R_GAME_SOUNDINFO *gd_soundinfo; + GAME_FONTDESC *gd_fontdescs; + GAME_SOUNDINFO *gd_soundinfo; uint32 features; GameSettings toGameSettings() const { @@ -68,22 +68,22 @@ struct R_GAMEDESC { } }; -struct R_GAME_FILEDATA { - R_RSCFILE_CONTEXT *file_ctxt; +struct GAME_FILEDATA { + RSCFILE_CONTEXT *file_ctxt; uint16 file_types; uint16 file_flags; }; -struct R_GAMEMODULE { +struct GAMEMODULE { int game_init; int game_number; - R_GAMEDESC *gamedesc; + GAMEDESC *gamedesc; int g_skipintro; - char game_language[R_GAME_LANGSTR_LIMIT]; + char game_language[GAME_LANGSTR_LIMIT]; uint16 gfile_n; - R_GAME_FILEDATA *gfile_data; + GAME_FILEDATA *gfile_data; uint16 gd_fontct; - R_GAME_FONTDESC *gd_fontdescs; + GAME_FONTDESC *gd_fontdescs; int err_n; const char *err_str; }; diff --git a/saga/game_mod.h b/saga/game_mod.h index d427cc9f4f..6e2254fcc8 100644 --- a/saga/game_mod.h +++ b/saga/game_mod.h @@ -30,64 +30,64 @@ namespace Saga { -enum R_GAME_IDS { - R_GAME_ITE_DEMO = 0, - R_GAME_ITE_DISK = 1, - R_GAME_ITE_CD = 2, - R_GAME_IHNM_DEMO = 3, - R_GAME_IHNM_CD = 4, - R_GAME_ITE_WINDEMO = 5 +enum GAME_IDS { + GAME_ITE_DEMO = 0, + GAME_ITE_DISK = 1, + GAME_ITE_CD = 2, + GAME_IHNM_DEMO = 3, + GAME_IHNM_CD = 4, + GAME_ITE_WINDEMO = 5 }; -enum R_GAME_FILETYPES { - R_GAME_RESOURCEFILE = 0x01, - R_GAME_SCRIPTFILE = 0x02, - R_GAME_SOUNDFILE = 0x04, - R_GAME_VOICEFILE = 0x08, - R_GAME_DEMOFILE = 0x10, - R_GAME_MUSICFILE = 0x20 +enum GAME_FILETYPES { + GAME_RESOURCEFILE = 0x01, + GAME_SCRIPTFILE = 0x02, + GAME_SOUNDFILE = 0x04, + GAME_VOICEFILE = 0x08, + GAME_DEMOFILE = 0x10, + GAME_MUSICFILE = 0x20 }; -enum R_GAME_SOUNDINFO_TYPES { - R_GAME_SOUND_PCM = 0, - R_GAME_SOUND_VOC, - R_GAME_SOUND_WAV +enum GAME_SOUNDINFO_TYPES { + GAME_SOUND_PCM = 0, + GAME_SOUND_VOC, + GAME_SOUND_WAV }; -enum R_GAME_FONT_IDS { - R_GAME_FONT_SMALL = 0, - R_GAME_FONT_MEDIUM, - R_GAME_FONT_LARGE, - R_GAME_FONT_SMALL2, - R_GAME_FONT_MEDIUM2, - R_GAME_FONT_LARGE2, - R_GAME_FONT_LARGE3 +enum GAME_FONT_IDS { + GAME_FONT_SMALL = 0, + GAME_FONT_MEDIUM, + GAME_FONT_LARGE, + GAME_FONT_SMALL2, + GAME_FONT_MEDIUM2, + GAME_FONT_LARGE2, + GAME_FONT_LARGE3 }; -struct R_GAME_DISPLAYINFO { +struct GAME_DISPLAYINFO { int logical_w; int logical_h; int scene_h; }; -struct R_GAME_SOUNDINFO { +struct GAME_SOUNDINFO { int res_type; long freq; int sample_size; int stereo; }; -struct R_GAME_FONTDESC { +struct GAME_FONTDESC { uint16 font_id; uint32 font_rn; }; -struct R_GAME_SCENEDESC { +struct GAME_SCENEDESC { uint32 scene_lut_rn; uint32 first_scene; }; -struct R_GAME_RESOURCEDESC { +struct GAME_RESOURCEDESC { uint32 scene_lut_rn; uint32 script_lut_rn; uint32 command_panel_rn; @@ -96,12 +96,12 @@ struct R_GAME_RESOURCEDESC { int GAME_Register(); int GAME_Init(); -int GAME_GetFileContext(R_RSCFILE_CONTEXT **ctxt_p, uint16 r_type, int param); -int GAME_GetFontInfo(R_GAME_FONTDESC **, int *); -int GAME_GetResourceInfo(R_GAME_RESOURCEDESC *); -int GAME_GetSoundInfo(R_GAME_SOUNDINFO *); -int GAME_GetDisplayInfo(R_GAME_DISPLAYINFO *); -int GAME_GetSceneInfo(R_GAME_SCENEDESC *); +int GAME_GetFileContext(RSCFILE_CONTEXT **ctxt_p, uint16 type, int param); +int GAME_GetFontInfo(GAME_FONTDESC **, int *); +int GAME_GetResourceInfo(GAME_RESOURCEDESC *); +int GAME_GetSoundInfo(GAME_SOUNDINFO *); +int GAME_GetDisplayInfo(GAME_DISPLAYINFO *); +int GAME_GetSceneInfo(GAME_SCENEDESC *); int GAME_GetGame(); int GAME_GetGameType(); GameList GAME_GameList(); diff --git a/saga/gfx.cpp b/saga/gfx.cpp index 3c82d9068b..433de8c44f 100644 --- a/saga/gfx.cpp +++ b/saga/gfx.cpp @@ -36,25 +36,25 @@ namespace Saga { Gfx::Gfx(OSystem *system, int width, int height) { - R_SURFACE r_back_buf; + SURFACE back_buf; _system = system; _system->initSize(width, height); debug(0, "Init screen %dx%d", width, height); // Convert surface data to R surface data - r_back_buf.buf = (byte *)calloc(1, width * height); - r_back_buf.buf_w = width; - r_back_buf.buf_h = height; - r_back_buf.buf_pitch = width; + back_buf.buf = (byte *)calloc(1, width * height); + back_buf.buf_w = width; + back_buf.buf_h = height; + back_buf.buf_pitch = width; - r_back_buf.clip_rect.left = 0; - r_back_buf.clip_rect.top = 0; - r_back_buf.clip_rect.right = width; - r_back_buf.clip_rect.bottom = height; + back_buf.clip_rect.left = 0; + back_buf.clip_rect.top = 0; + back_buf.clip_rect.right = width; + back_buf.clip_rect.bottom = height; // Set module data - _back_buf = r_back_buf; + _back_buf = back_buf; _init = 1; _white_index = -1; _black_index = -1; @@ -70,7 +70,7 @@ Gfx::Gfx(OSystem *system, int width, int height) { } */ -int Gfx::drawPalette(R_SURFACE *dst_s) { +int Gfx::drawPalette(SURFACE *dst_s) { int x; int y; int color = 0; @@ -93,7 +93,7 @@ int Gfx::drawPalette(R_SURFACE *dst_s) { return 0; } -int Gfx::simpleBlit(R_SURFACE *dst_s, R_SURFACE *src_s) { +int Gfx::simpleBlit(SURFACE *dst_s, SURFACE *src_s) { byte *src_p; byte *dst_p; int y, w, p; @@ -115,7 +115,7 @@ int Gfx::simpleBlit(R_SURFACE *dst_s, R_SURFACE *src_s) { src_p += p; } - return R_SUCCESS; + return SUCCESS; } // TODO: I've fixed at least one clipping bug here, but I have a feeling there @@ -129,8 +129,8 @@ int Gfx::simpleBlit(R_SURFACE *dst_s, R_SURFACE *src_s) { // origin. // - If src_rect is NULL, the entire buffer is copied./ // - The surface must match the logical dimensions of the buffer exactly. -// - Returns R_FAILURE on error -int Gfx::bufToSurface(R_SURFACE *ds, const byte *src, int src_w, int src_h, +// - Returns FAILURE on error +int Gfx::bufToSurface(SURFACE *ds, const byte *src, int src_w, int src_h, Rect *src_rect, Point *dst_pt) { const byte *read_p; byte *write_p; @@ -160,7 +160,7 @@ int Gfx::bufToSurface(R_SURFACE *ds, const byte *src, int src_w, int src_h, if (s.width() <= 0 || s.height() <= 0) { // Empty or negative region - return R_FAILURE; + return FAILURE; } // Get destination origin and clip rectangle @@ -197,7 +197,7 @@ int Gfx::bufToSurface(R_SURFACE *ds, const byte *src, int src_w, int src_h, if (d_x < clip.left) { if (d_x <= (-src_draw_w)) { // dst rect completely off left edge - return R_SUCCESS; + return SUCCESS; } src_off_x += (clip.left - d_x); @@ -211,7 +211,7 @@ int Gfx::bufToSurface(R_SURFACE *ds, const byte *src, int src_w, int src_h, if (d_y < clip.top) { if (d_y >= (-src_draw_h)) { // dst rect completely off top edge - return R_SUCCESS; + return SUCCESS; } src_off_y += (clip.top - d_y); @@ -224,7 +224,7 @@ int Gfx::bufToSurface(R_SURFACE *ds, const byte *src, int src_w, int src_h, if (d_x >= clip.right) { // dst rect completely off right edge - return R_SUCCESS; + return SUCCESS; } if ((d_x + src_draw_w) > clip.right) { @@ -235,7 +235,7 @@ int Gfx::bufToSurface(R_SURFACE *ds, const byte *src, int src_w, int src_h, if (d_y > clip.bottom) { // dst rect completely off bottom edge - return R_SUCCESS; + return SUCCESS; } if ((d_y + src_draw_h) > clip.bottom) { @@ -253,7 +253,7 @@ int Gfx::bufToSurface(R_SURFACE *ds, const byte *src, int src_w, int src_h, read_p += src_w; } - return R_SUCCESS; + return SUCCESS; } int Gfx::bufToBuffer(byte *dst_buf, int dst_w, int dst_h, const byte *src, @@ -287,7 +287,7 @@ int Gfx::bufToBuffer(byte *dst_buf, int dst_w, int dst_h, const byte *src, if (s.width() <= 0 || s.height() <= 0) { // Empty or negative region - return R_FAILURE; + return FAILURE; } // Get destination origin and clip rectangle @@ -317,7 +317,7 @@ int Gfx::bufToBuffer(byte *dst_buf, int dst_w, int dst_h, const byte *src, if (d_x < clip.left) { if (d_x <= (-src_draw_w)) { // dst rect completely off left edge - return R_SUCCESS; + return SUCCESS; } src_off_x += (clip.left - d_x); @@ -331,7 +331,7 @@ int Gfx::bufToBuffer(byte *dst_buf, int dst_w, int dst_h, const byte *src, if (d_y < clip.top) { if (d_y >= (-src_draw_h)) { // dst rect completely off top edge - return R_SUCCESS; + return SUCCESS; } src_off_y += (clip.top - d_y); @@ -344,7 +344,7 @@ int Gfx::bufToBuffer(byte *dst_buf, int dst_w, int dst_h, const byte *src, if (d_x >= clip.right) { // dst rect completely off right edge - return R_SUCCESS; + return SUCCESS; } if ((d_x + src_draw_w) > clip.right) { @@ -355,7 +355,7 @@ int Gfx::bufToBuffer(byte *dst_buf, int dst_w, int dst_h, const byte *src, if (d_y >= clip.bottom) { // dst rect completely off bottom edge - return R_SUCCESS; + return SUCCESS; } if ((d_y + src_draw_h) > clip.bottom) { @@ -373,12 +373,12 @@ int Gfx::bufToBuffer(byte *dst_buf, int dst_w, int dst_h, const byte *src, read_p += src_w; } - return R_SUCCESS; + return SUCCESS; } // Fills a rectangle in the surface ds from point 'p1' to point 'p2' using // the specified color. -int Gfx::drawRect(R_SURFACE *ds, Rect *dst_rect, int color) { +int Gfx::drawRect(SURFACE *ds, Rect *dst_rect, int color) { byte *write_p; int w; @@ -396,7 +396,7 @@ int Gfx::drawRect(R_SURFACE *ds, Rect *dst_rect, int color) { if ((left >= right) || (top >= bottom)) { // Empty or negative region - return R_FAILURE; + return FAILURE; } } else { left = 0; @@ -415,10 +415,10 @@ int Gfx::drawRect(R_SURFACE *ds, Rect *dst_rect, int color) { write_p += ds->buf_pitch; } - return R_SUCCESS; + return SUCCESS; } -int Gfx::drawFrame(R_SURFACE *ds, const Point *p1, const Point *p2, int color) { +int Gfx::drawFrame(SURFACE *ds, const Point *p1, const Point *p2, int color) { int left, top, right, bottom; int min_x; @@ -457,10 +457,10 @@ int Gfx::drawFrame(R_SURFACE *ds, const Point *p1, const Point *p2, int color) { drawLine(ds, &n_p3, &n_p4, color); drawLine(ds, &n_p4, &n_p1, color); - return R_SUCCESS; + return SUCCESS; } -int Gfx::drawPolyLine(R_SURFACE *ds, const Point *pts, int pt_ct, int draw_color) { +int Gfx::drawPolyLine(SURFACE *ds, const Point *pts, int pt_ct, int draw_color) { const Point *first_pt = pts; int last_i = 1; int i; @@ -468,7 +468,7 @@ int Gfx::drawPolyLine(R_SURFACE *ds, const Point *pts, int pt_ct, int draw_color assert((ds != NULL) & (pts != NULL)); if (pt_ct < 3) { - return R_FAILURE; + return FAILURE; } for (i = 1; i < pt_ct; i++) { @@ -478,17 +478,17 @@ int Gfx::drawPolyLine(R_SURFACE *ds, const Point *pts, int pt_ct, int draw_color drawLine(ds, &pts[last_i], first_pt, draw_color); - return R_SUCCESS; + return SUCCESS; } -int Gfx::getClipInfo(R_CLIPINFO *clipinfo) { +int Gfx::getClipInfo(CLIPINFO *clipinfo) { Common::Rect s; int d_x, d_y; Common::Rect clip; if (clipinfo == NULL) { - return R_FAILURE; + return FAILURE; } if (clipinfo->dst_pt != NULL) { @@ -518,7 +518,7 @@ int Gfx::getClipInfo(R_CLIPINFO *clipinfo) { if (d_x <= -(clipinfo->draw_w)) { // dst rect completely off left edge clipinfo->nodraw = 1; - return R_SUCCESS; + return SUCCESS; } clipinfo->src_draw_x += (clip.left - d_x); @@ -531,7 +531,7 @@ int Gfx::getClipInfo(R_CLIPINFO *clipinfo) { if (d_y <= -(clipinfo->draw_h)) { // dst rect completely off top edge clipinfo->nodraw = 1; - return R_SUCCESS; + return SUCCESS; } clipinfo->src_draw_y += (clip.top - d_y); @@ -544,7 +544,7 @@ int Gfx::getClipInfo(R_CLIPINFO *clipinfo) { if (d_x >= clip.right) { // dst rect completely off right edge clipinfo->nodraw = 1; - return R_SUCCESS; + return SUCCESS; } if ((d_x + clipinfo->draw_w) > clip.right) { @@ -555,17 +555,17 @@ int Gfx::getClipInfo(R_CLIPINFO *clipinfo) { if (d_y >= clip.bottom) { // dst rect completely off bottom edge clipinfo->nodraw = 1; - return R_SUCCESS; + return SUCCESS; } if ((d_y + clipinfo->draw_h) > clip.bottom) { clipinfo->draw_h = clip.bottom - d_y; } - return R_SUCCESS; + return SUCCESS; } -int Gfx::clipLine(R_SURFACE *ds, const Point *src_p1, const Point *src_p2, +int Gfx::clipLine(SURFACE *ds, const Point *src_p1, const Point *src_p2, Point *dst_p1, Point *dst_p2) { const Point *n_p1; const Point *n_p2; @@ -637,7 +637,7 @@ int Gfx::clipLine(R_SURFACE *ds, const Point *src_p1, const Point *src_p2, // Coriolis Group Books, 1997 // // Performs no clipping -void Gfx::drawLine(R_SURFACE *ds, const Point *p1, const Point *p2, int color) { +void Gfx::drawLine(SURFACE *ds, const Point *p1, const Point *p2, int color) { byte *write_p; int clip_result; int temp; @@ -812,7 +812,7 @@ void Gfx::drawLine(R_SURFACE *ds, const Point *p1, const Point *p2, int color) { return; } -R_SURFACE *Gfx::getBackBuffer() { +SURFACE *Gfx::getBackBuffer() { return &_back_buf; } @@ -837,7 +837,7 @@ int Gfx::matchColor(unsigned long colormask) { int best_index = 0; byte *ppal; - for (i = 0, ppal = _cur_pal; i < R_PAL_ENTRIES; i++, ppal += 4) { + for (i = 0, ppal = _cur_pal; i < PAL_ENTRIES; i++, ppal += 4) { dr = ppal[0] - red; dr = ABS(dr); dg = ppal[1] - green; @@ -846,7 +846,7 @@ int Gfx::matchColor(unsigned long colormask) { db = ABS(db); ppal[3] = 0; - color_delta = (long)(dr * R_RED_WEIGHT + dg * R_GREEN_WEIGHT + db * R_BLUE_WEIGHT); + color_delta = (long)(dr * RED_WEIGHT + dg * GREEN_WEIGHT + db * BLUE_WEIGHT); if (color_delta == 0) { return i; @@ -861,7 +861,7 @@ int Gfx::matchColor(unsigned long colormask) { return best_index; } -int Gfx::setPalette(R_SURFACE *surface, PALENTRY *pal) { +int Gfx::setPalette(SURFACE *surface, PALENTRY *pal) { byte red; byte green; byte blue; @@ -873,7 +873,7 @@ int Gfx::setPalette(R_SURFACE *surface, PALENTRY *pal) { int i; byte *ppal; - for (i = 0, ppal = _cur_pal; i < R_PAL_ENTRIES; i++, ppal += 4) { + for (i = 0, ppal = _cur_pal; i < PAL_ENTRIES; i++, ppal += 4) { red = pal[i].red; ppal[0] = red; color_delta = red; @@ -907,25 +907,25 @@ int Gfx::setPalette(R_SURFACE *surface, PALENTRY *pal) { _white_index = best_windex; _black_index = best_bindex; - _system->setPalette(_cur_pal, 0, R_PAL_ENTRIES); + _system->setPalette(_cur_pal, 0, PAL_ENTRIES); - return R_SUCCESS; + return SUCCESS; } int Gfx::getCurrentPal(PALENTRY *src_pal) { int i; byte *ppal; - for (i = 0, ppal = _cur_pal; i < R_PAL_ENTRIES; i++, ppal += 4) { + for (i = 0, ppal = _cur_pal; i < PAL_ENTRIES; i++, ppal += 4) { src_pal[i].red = ppal[0]; src_pal[i].green = ppal[1]; src_pal[i].blue = ppal[2]; } - return R_SUCCESS; + return SUCCESS; } -int Gfx::palToBlack(R_SURFACE *surface, PALENTRY *src_pal, double percent) { +int Gfx::palToBlack(SURFACE *surface, PALENTRY *src_pal, double percent) { int i; //int fade_max = 255; int new_entry; @@ -943,7 +943,7 @@ int Gfx::palToBlack(R_SURFACE *surface, PALENTRY *src_pal, double percent) { fpercent = 1.0 - fpercent; // Use the correct percentage change per frame for each palette entry - for (i = 0, ppal = _cur_pal; i < R_PAL_ENTRIES; i++, ppal += 4) { + for (i = 0, ppal = _cur_pal; i < PAL_ENTRIES; i++, ppal += 4) { new_entry = (int)(src_pal[i].red * fpercent); if (new_entry < 0) { @@ -970,12 +970,12 @@ int Gfx::palToBlack(R_SURFACE *surface, PALENTRY *src_pal, double percent) { ppal[3] = 0; } - _system->setPalette(_cur_pal, 0, R_PAL_ENTRIES); + _system->setPalette(_cur_pal, 0, PAL_ENTRIES); - return R_SUCCESS; + return SUCCESS; } -int Gfx::blackToPal(R_SURFACE *surface, PALENTRY *src_pal, double percent) { +int Gfx::blackToPal(SURFACE *surface, PALENTRY *src_pal, double percent) { int new_entry; double fpercent; int color_delta; @@ -996,7 +996,7 @@ int Gfx::blackToPal(R_SURFACE *surface, PALENTRY *src_pal, double percent) { fpercent = 1.0 - fpercent; // Use the correct percentage change per frame for each palette entry - for (i = 0, ppal = _cur_pal; i < R_PAL_ENTRIES; i++, ppal += 4) { + for (i = 0, ppal = _cur_pal; i < PAL_ENTRIES; i++, ppal += 4) { new_entry = (int)(src_pal[i].red - src_pal[i].red * fpercent); if (new_entry < 0) { @@ -1025,7 +1025,7 @@ int Gfx::blackToPal(R_SURFACE *surface, PALENTRY *src_pal, double percent) { // Find the best white and black color indices again if (percent >= 1.0) { - for (i = 0, ppal = _cur_pal; i < R_PAL_ENTRIES; i++, ppal += 4) { + for (i = 0, ppal = _cur_pal; i < PAL_ENTRIES; i++, ppal += 4) { color_delta = ppal[0]; color_delta += ppal[1]; color_delta += ppal[2]; @@ -1049,9 +1049,9 @@ int Gfx::blackToPal(R_SURFACE *surface, PALENTRY *src_pal, double percent) { setCursor(best_windex); } - _system->setPalette(_cur_pal, 0, R_PAL_ENTRIES); + _system->setPalette(_cur_pal, 0, PAL_ENTRIES); - return R_SUCCESS; + return SUCCESS; } void Gfx::setCursor(int best_white) { @@ -1059,7 +1059,7 @@ void Gfx::setCursor(int best_white) { byte keycolor = (best_white == 0) ? 1 : 0; // Set up the mouse cursor - byte cursor_img[R_CURSOR_W * R_CURSOR_H] = { + byte cursor_img[CURSOR_W * CURSOR_H] = { 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -1069,14 +1069,14 @@ void Gfx::setCursor(int best_white) { 0, 0, 0, 255, 0, 0, 0, }; - for (i = 0; i < R_CURSOR_W * R_CURSOR_H; i++) { + for (i = 0; i < CURSOR_W * CURSOR_H; i++) { if (cursor_img[i] != 0) cursor_img[i] = best_white; else cursor_img[i] = keycolor; } - _system->setMouseCursor(cursor_img, R_CURSOR_W, R_CURSOR_H, 4, 4, keycolor); + _system->setMouseCursor(cursor_img, CURSOR_W, CURSOR_H, 4, 4, keycolor); } bool Gfx::hitTestPoly(const Point *points, unsigned int npoints, const Point& test_point) { diff --git a/saga/gfx.h b/saga/gfx.h index 18412f1169..b281f21f0a 100644 --- a/saga/gfx.h +++ b/saga/gfx.h @@ -31,7 +31,7 @@ namespace Saga { using Common::Point; using Common::Rect; -struct R_CLIPINFO { +struct CLIPINFO { // input members const Rect *src_rect; const Rect *dst_rect; @@ -53,14 +53,14 @@ struct PALENTRY { byte blue; }; -struct R_COLOR { +struct COLOR { int red; int green; int blue; int alpha; }; -struct R_SURFACE { +struct SURFACE { byte *buf; int buf_w; int buf_h; @@ -68,54 +68,54 @@ struct R_SURFACE { Rect clip_rect; }; -#define R_PAL_ENTRIES 256 +#define PAL_ENTRIES 256 -#define R_RGB_RED 0x00FF0000UL -#define R_RGB_GREEN 0x0000FF00UL -#define R_RGB_BLUE 0x000000FFUL +#define RGB_RED 0x00FF0000UL +#define RGB_GREEN 0x0000FF00UL +#define RGB_BLUE 0x000000FFUL -#define R_CURSOR_W 7 -#define R_CURSOR_H 7 +#define CURSOR_W 7 +#define CURSOR_H 7 -#define R_CURSOR_ORIGIN_X 4 -#define R_CURSOR_ORIGIN_Y 4 +#define CURSOR_ORIGIN_X 4 +#define CURSOR_ORIGIN_Y 4 -#define R_RED_WEIGHT 0.299 -#define R_GREEN_WEIGHT 0.587 -#define R_BLUE_WEIGHT 0.114 +#define RED_WEIGHT 0.299 +#define GREEN_WEIGHT 0.587 +#define BLUE_WEIGHT 0.114 class Gfx { public: - int simpleBlit(R_SURFACE *dst_s, R_SURFACE *src_s); - int drawPalette(R_SURFACE *dst_s); - int bufToSurface(R_SURFACE *ds, const byte *src, int src_w, int src_h, Rect *src_rect, Point *dst_pt); + int simpleBlit(SURFACE *dst_s, SURFACE *src_s); + int drawPalette(SURFACE *dst_s); + int bufToSurface(SURFACE *ds, const byte *src, int src_w, int src_h, Rect *src_rect, Point *dst_pt); int bufToBuffer(byte * dst_buf, int dst_w, int dst_h, const byte *src, int src_w, int src_h, Rect *src_rect, Point *dst_pt); - int drawRect(R_SURFACE *ds, Rect *dst_rect, int color); - int drawFrame(R_SURFACE *ds, const Point *p1, const Point *p2, int color); - int drawPolyLine(R_SURFACE *ds, const Point *pts, int pt_ct, int draw_color); - int getClipInfo(R_CLIPINFO *clipinfo); - int clipLine(R_SURFACE *ds, const Point *src_p1, const Point *src_p2, Point *dst_p1, Point *dst_p2); - void drawLine(R_SURFACE * ds, const Point *p1, const Point *p2, int color); + int drawRect(SURFACE *ds, Rect *dst_rect, int color); + int drawFrame(SURFACE *ds, const Point *p1, const Point *p2, int color); + int drawPolyLine(SURFACE *ds, const Point *pts, int pt_ct, int draw_color); + int getClipInfo(CLIPINFO *clipinfo); + int clipLine(SURFACE *ds, const Point *src_p1, const Point *src_p2, Point *dst_p1, Point *dst_p2); + void drawLine(SURFACE * ds, const Point *p1, const Point *p2, int color); Gfx(OSystem *system, int width, int height); - R_SURFACE *getBackBuffer(); + SURFACE *getBackBuffer(); int getWhite(); int getBlack(); int matchColor(unsigned long colormask); - int setPalette(R_SURFACE *surface, PALENTRY *pal); + int setPalette(SURFACE *surface, PALENTRY *pal); int getCurrentPal(PALENTRY *src_pal); - int palToBlack(R_SURFACE *surface, PALENTRY *src_pal, double percent); - int blackToPal(R_SURFACE *surface, PALENTRY *src_pal, double percent); + int palToBlack(SURFACE *surface, PALENTRY *src_pal, double percent); + int blackToPal(SURFACE *surface, PALENTRY *src_pal, double percent); bool hitTestPoly(const Point *points, unsigned int npoints, const Point& test_point); private: void setCursor(int best_white); int _init; - R_SURFACE _back_buf; + SURFACE _back_buf; int _white_index; int _black_index; - byte _cur_pal[R_PAL_ENTRIES * 4]; + byte _cur_pal[PAL_ENTRIES * 4]; OSystem *_system; }; diff --git a/saga/ihnm_introproc.cpp b/saga/ihnm_introproc.cpp index 345c3d3726..f2e7ca8a12 100644 --- a/saga/ihnm_introproc.cpp +++ b/saga/ihnm_introproc.cpp @@ -36,51 +36,51 @@ namespace Saga { -R_SCENE_RESLIST IHNM_IntroMovie1RL[] = { +SCENE_RESLIST IHNM_IntroMovie1RL[] = { {30, SAGA_BG_IMAGE, 0, 0} , {31, SAGA_ANIM_1, 0, 0} }; -R_SCENE_DESC IHNM_IntroMovie1Desc = { +SCENE_DESC IHNM_IntroMovie1Desc = { 0, 0, 0, 0, 0, 0, 0, 0, IHNM_IntroMovie1RL, ARRAYSIZE(IHNM_IntroMovie1RL) }; -R_SCENE_RESLIST IHNM_IntroMovie2RL[] = { +SCENE_RESLIST IHNM_IntroMovie2RL[] = { {32, SAGA_BG_IMAGE, 0, 0} , {33, SAGA_ANIM_1, 0, 0} }; -R_SCENE_DESC IHNM_IntroMovie2Desc = { +SCENE_DESC IHNM_IntroMovie2Desc = { 0, 0, 0, 0, 0, 0, 0, 0, IHNM_IntroMovie2RL, ARRAYSIZE(IHNM_IntroMovie2RL) }; -R_SCENE_RESLIST IHNM_IntroMovie3RL[] = { +SCENE_RESLIST IHNM_IntroMovie3RL[] = { {34, SAGA_BG_IMAGE, 0, 0}, {35, SAGA_ANIM_1, 0, 0} }; -R_SCENE_DESC IHNM_IntroMovie3Desc = { +SCENE_DESC IHNM_IntroMovie3Desc = { 0, 0, 0, 0, 0, 0, 0, 0, IHNM_IntroMovie3RL, ARRAYSIZE(IHNM_IntroMovie3RL) }; -R_SCENE_RESLIST IHNM_IntroMovie4RL[] = { +SCENE_RESLIST IHNM_IntroMovie4RL[] = { {1227, SAGA_BG_IMAGE, 0, 0}, {1226, SAGA_ANIM_1, 0, 0} }; -R_SCENE_DESC IHNM_IntroMovie4Desc = { +SCENE_DESC IHNM_IntroMovie4Desc = { 0, 0, 0, 0, 0, 0, 0, 0, IHNM_IntroMovie4RL, ARRAYSIZE(IHNM_IntroMovie4RL) }; -R_SCENE_QUEUE IHNM_IntroList[] = { +SCENE_QUEUE IHNM_IntroList[] = { {0, &IHNM_IntroMovie1Desc, BY_DESC, Scene::SC_IHNMIntroMovieProc1, 0, SCENE_NOFADE}, {0, &IHNM_IntroMovie2Desc, BY_DESC, Scene::SC_IHNMIntroMovieProc2, 0, SCENE_NOFADE}, {0, &IHNM_IntroMovie3Desc, BY_DESC, Scene::SC_IHNMIntroMovieProc3, 0, SCENE_NOFADE}, @@ -97,27 +97,27 @@ int Scene::IHNMStartProc() { _vm->_scene->queueScene(&IHNM_IntroList[i]); } - return R_SUCCESS; + return SUCCESS; } -int Scene::SC_IHNMIntroMovieProc1(int param, R_SCENE_INFO *scene_info, void *refCon) { +int Scene::SC_IHNMIntroMovieProc1(int param, SCENE_INFO *scene_info, void *refCon) { return ((Scene *)refCon)->IHNMIntroMovieProc1(param, scene_info); } -int Scene::IHNMIntroMovieProc1(int param, R_SCENE_INFO *scene_info) { - R_EVENT event; +int Scene::IHNMIntroMovieProc1(int param, SCENE_INFO *scene_info) { + EVENT event; switch (param) { case SCENE_BEGIN: // Background for intro scene is the first frame of the // intro animation; display it and set the palette - event.type = R_ONESHOT_EVENT; - event.code = R_BG_EVENT; + event.type = ONESHOT_EVENT; + event.code = BG_EVENT; event.op = EVENT_DISPLAY; event.param = SET_PALETTE; event.time = 0; _vm->_events->queue(&event); - _vm->_anim->setFrameTime(0, R_IHNM_INTRO_FRAMETIME); + _vm->_anim->setFrameTime(0, IHNM_INTRO_FRAMETIME); _vm->_anim->setFlag(0, ANIM_ENDSCENE); _vm->_anim->play(0, 0); break; @@ -128,35 +128,35 @@ int Scene::IHNMIntroMovieProc1(int param, R_SCENE_INFO *scene_info) { return 0; } -int Scene::SC_IHNMIntroMovieProc2(int param, R_SCENE_INFO *scene_info, void *refCon) { +int Scene::SC_IHNMIntroMovieProc2(int param, SCENE_INFO *scene_info, void *refCon) { return ((Scene *)refCon)->IHNMIntroMovieProc2(param, scene_info); } -int Scene::IHNMIntroMovieProc2(int param, R_SCENE_INFO *scene_info) { - R_EVENT event; - R_EVENT *q_event; +int Scene::IHNMIntroMovieProc2(int param, SCENE_INFO *scene_info) { + EVENT event; + EVENT *q_event; PALENTRY *pal; - static PALENTRY current_pal[R_PAL_ENTRIES]; + static PALENTRY current_pal[PAL_ENTRIES]; switch (param) { case SCENE_BEGIN: // Fade to black out of the intro CyberDreams logo anim _vm->_gfx->getCurrentPal(current_pal); - event.type = R_CONTINUOUS_EVENT; - event.code = R_PAL_EVENT; + event.type = CONTINUOUS_EVENT; + event.code = PAL_EVENT; event.op = EVENT_PALTOBLACK; event.time = 0; - event.duration = R_IHNM_PALFADE_TIME; + event.duration = IHNM_PALFADE_TIME; event.data = current_pal; q_event = _vm->_events->queue(&event); // Background for intro scene is the first frame of the // intro animation; display it but don't set palette - event.type = R_ONESHOT_EVENT; - event.code = R_BG_EVENT; + event.type = ONESHOT_EVENT; + event.code = BG_EVENT; event.op = EVENT_DISPLAY; event.param = NO_SET_PALETTE; event.time = 0; @@ -166,23 +166,23 @@ int Scene::IHNMIntroMovieProc2(int param, R_SCENE_INFO *scene_info) { // Fade in from black to the scene background palette _vm->_scene->getBGPal(&pal); - event.type = R_CONTINUOUS_EVENT; - event.code = R_PAL_EVENT; + event.type = CONTINUOUS_EVENT; + event.code = PAL_EVENT; event.op = EVENT_BLACKTOPAL; event.time = 0; - event.duration = R_IHNM_PALFADE_TIME; + event.duration = IHNM_PALFADE_TIME; event.data = pal; q_event = _vm->_events->chain(q_event, &event); _vm->_anim->setFlag(0, ANIM_LOOP); - _vm->_anim->play(0, R_IHNM_PALFADE_TIME * 2); + _vm->_anim->play(0, IHNM_PALFADE_TIME * 2); // Queue end of scene after looping animation for a while - event.type = R_ONESHOT_EVENT; - event.code = R_SCENE_EVENT; + event.type = ONESHOT_EVENT; + event.code = SCENE_EVENT; event.op = EVENT_END; - event.time = R_IHNM_DGLOGO_TIME; + event.time = IHNM_DGLOGO_TIME; q_event = _vm->_events->chain(q_event, &event); break; @@ -193,34 +193,34 @@ int Scene::IHNMIntroMovieProc2(int param, R_SCENE_INFO *scene_info) { return 0; } -int Scene::SC_IHNMIntroMovieProc3(int param, R_SCENE_INFO *scene_info, void *refCon) { +int Scene::SC_IHNMIntroMovieProc3(int param, SCENE_INFO *scene_info, void *refCon) { return ((Scene *)refCon)->IHNMIntroMovieProc3(param, scene_info); } -int Scene::IHNMIntroMovieProc3(int param, R_SCENE_INFO *scene_info) { - R_EVENT event; - R_EVENT *q_event; +int Scene::IHNMIntroMovieProc3(int param, SCENE_INFO *scene_info) { + EVENT event; + EVENT *q_event; PALENTRY *pal; - static PALENTRY current_pal[R_PAL_ENTRIES]; + static PALENTRY current_pal[PAL_ENTRIES]; switch (param) { case SCENE_BEGIN: // Fade to black out of the intro DG logo anim _vm->_gfx->getCurrentPal(current_pal); - event.type = R_CONTINUOUS_EVENT; - event.code = R_PAL_EVENT; + event.type = CONTINUOUS_EVENT; + event.code = PAL_EVENT; event.op = EVENT_PALTOBLACK; event.time = 0; - event.duration = R_IHNM_PALFADE_TIME; + event.duration = IHNM_PALFADE_TIME; event.data = current_pal; q_event = _vm->_events->queue(&event); // Background for intro scene is the first frame of the // intro animation; display it but don't set palette - event.type = R_ONESHOT_EVENT; - event.code = R_BG_EVENT; + event.type = ONESHOT_EVENT; + event.code = BG_EVENT; event.op = EVENT_DISPLAY; event.param = NO_SET_PALETTE; event.time = 0; @@ -230,11 +230,11 @@ int Scene::IHNMIntroMovieProc3(int param, R_SCENE_INFO *scene_info) { // Fade in from black to the scene background palette _vm->_scene->getBGPal(&pal); - event.type = R_CONTINUOUS_EVENT; - event.code = R_PAL_EVENT; + event.type = CONTINUOUS_EVENT; + event.code = PAL_EVENT; event.op = EVENT_BLACKTOPAL; event.time = 0; - event.duration = R_IHNM_PALFADE_TIME; + event.duration = IHNM_PALFADE_TIME; event.data = pal; q_event = _vm->_events->chain(q_event, &event); @@ -242,10 +242,10 @@ int Scene::IHNMIntroMovieProc3(int param, R_SCENE_INFO *scene_info) { _vm->_anim->play(0, 0); // Queue end of scene after a while - event.type = R_ONESHOT_EVENT; - event.code = R_SCENE_EVENT; + event.type = ONESHOT_EVENT; + event.code = SCENE_EVENT; event.op = EVENT_END; - event.time = R_IHNM_TITLE_TIME; + event.time = IHNM_TITLE_TIME; q_event = _vm->_events->chain(q_event, &event); break; @@ -256,20 +256,20 @@ int Scene::IHNMIntroMovieProc3(int param, R_SCENE_INFO *scene_info) { return 0; } -int Scene::SC_IHNMHateProc(int param, R_SCENE_INFO *scene_info, void *refCon) { +int Scene::SC_IHNMHateProc(int param, SCENE_INFO *scene_info, void *refCon) { return ((Scene *)refCon)->IHNMHateProc(param, scene_info); } -int Scene::IHNMHateProc(int param, R_SCENE_INFO *scene_info) { - R_EVENT event; - R_EVENT *q_event; +int Scene::IHNMHateProc(int param, SCENE_INFO *scene_info) { + EVENT event; + EVENT *q_event; switch (param) { case SCENE_BEGIN: // Background for intro scene is the first frame of the // intro animation; display it and set the palette - event.type = R_ONESHOT_EVENT; - event.code = R_BG_EVENT; + event.type = ONESHOT_EVENT; + event.code = BG_EVENT; event.op = EVENT_DISPLAY; event.param = SET_PALETTE; event.time = 0; diff --git a/saga/image.cpp b/saga/image.cpp index 80a732317d..c2f19282b9 100644 --- a/saga/image.cpp +++ b/saga/image.cpp @@ -50,7 +50,7 @@ static int granulate(int value, int granularity) { int SagaEngine::decodeBGImage(const byte *image_data, size_t image_size, byte **output_buf, size_t *output_buf_len, int *w, int *h) { - R_IMAGE_HEADER hdr; + IMAGE_HEADER hdr; int modex_height; const byte *RLE_data_ptr; size_t RLE_data_len; @@ -61,7 +61,7 @@ int SagaEngine::decodeBGImage(const byte *image_data, size_t image_size, if (image_size <= SAGA_IMAGE_DATA_OFFSET) { /* Image size is way too small */ - return R_FAILURE; + return FAILURE; } MemoryReadStream readS(image_data, image_size); @@ -83,10 +83,10 @@ int SagaEngine::decodeBGImage(const byte *image_data, size_t image_size, out_buf = (byte *)malloc(out_buf_len); if (decodeBGImageRLE(RLE_data_ptr, - RLE_data_len, decode_buf, decode_buf_len) != R_SUCCESS) { + RLE_data_len, decode_buf, decode_buf_len) != SUCCESS) { free(decode_buf); free(out_buf); - return R_FAILURE; + return FAILURE; } unbankBGImage(out_buf, decode_buf, hdr.width, hdr.height); @@ -104,7 +104,7 @@ int SagaEngine::decodeBGImage(const byte *image_data, size_t image_size, *w = hdr.width; *h = hdr.height; - return R_SUCCESS; + return SUCCESS; } int SagaEngine::decodeBGImageRLE(const byte *inbuf, size_t inbuf_len, byte *outbuf, size_t outbuf_len) { @@ -146,7 +146,7 @@ int SagaEngine::decodeBGImageRLE(const byte *inbuf, size_t inbuf_len, byte *outb while ((inbuf_remain > 1) && (outbuf_remain > 0) && !decode_err) { if ((inbuf_ptr > inbuf_end) || (outbuf_ptr > outbuf_end)) { - return R_FAILURE; + return FAILURE; } mark_byte = *inbuf_ptr++; @@ -159,7 +159,7 @@ int SagaEngine::decodeBGImageRLE(const byte *inbuf, size_t inbuf_len, byte *outb // Uncompressed run follows: Max runlength 63 runcount = mark_byte & 0x3f; if ((inbuf_remain < runcount) || (outbuf_remain < runcount)) { - return R_FAILURE; + return FAILURE; } for (c = 0; c < runcount; c++) { @@ -174,7 +174,7 @@ int SagaEngine::decodeBGImageRLE(const byte *inbuf, size_t inbuf_len, byte *outb // Compressed run follows: Max runlength 63 runcount = (mark_byte & 0x3f) + 3; if (!inbuf_remain || (outbuf_remain < runcount)) { - return R_FAILURE; + return FAILURE; } for (c = 0; c < runcount; c++) { @@ -196,7 +196,7 @@ int SagaEngine::decodeBGImageRLE(const byte *inbuf, size_t inbuf_len, byte *outb backtrack_amount = *inbuf_ptr; if (!inbuf_remain || (backtrack_amount > (outbuf_ptr - outbuf)) || (runcount > outbuf_remain)) { - return R_FAILURE; + return FAILURE; } inbuf_ptr++; @@ -225,7 +225,7 @@ int SagaEngine::decodeBGImageRLE(const byte *inbuf, size_t inbuf_len, byte *outb runcount = (mark_byte & 0x0F) + 1; if ((inbuf_remain < (runcount + 2)) || (outbuf_remain < (runcount * 8))) { - return R_FAILURE; + return FAILURE; } bitfield_byte1 = *inbuf_ptr++; @@ -253,7 +253,7 @@ int SagaEngine::decodeBGImageRLE(const byte *inbuf, size_t inbuf_len, byte *outb // Uncompressed run follows runcount = ((mark_byte & 0x0F) << 8) + *inbuf_ptr; if ((inbuf_remain < (runcount + 1)) || (outbuf_remain < runcount)) { - return R_FAILURE; + return FAILURE; } inbuf_ptr++; @@ -272,14 +272,14 @@ int SagaEngine::decodeBGImageRLE(const byte *inbuf, size_t inbuf_len, byte *outb // Repeat decoded sequence from output stream backtrack_amount = ((mark_byte & 0x0F) << 8) + *inbuf_ptr; if (inbuf_remain < 2) { - return R_FAILURE; + return FAILURE; } inbuf_ptr++; runcount = *inbuf_ptr++; if ((backtrack_amount > (outbuf_ptr - outbuf)) || (outbuf_remain < runcount)) { - return R_FAILURE; + return FAILURE; } backtrack_ptr = outbuf_ptr - backtrack_amount; @@ -293,12 +293,12 @@ int SagaEngine::decodeBGImageRLE(const byte *inbuf, size_t inbuf_len, byte *outb continue; break; default: - return R_FAILURE; + return FAILURE; break; } } - return R_SUCCESS; + return SUCCESS; } int SagaEngine::flipImage(byte *img_buf, int columns, int scanlines) { @@ -312,7 +312,7 @@ int SagaEngine::flipImage(byte *img_buf, int columns, int scanlines) { tmp_scan = (byte *)malloc(columns); if (tmp_scan == NULL) { - return R_FAILURE; + return FAILURE; } flip_p1 = img_buf; @@ -328,7 +328,7 @@ int SagaEngine::flipImage(byte *img_buf, int columns, int scanlines) { free(tmp_scan); - return R_SUCCESS; + return SUCCESS; } int SagaEngine::unbankBGImage(byte *dst_buf, const byte *src_buf, int columns, int scanlines) { @@ -426,7 +426,7 @@ int SagaEngine::unbankBGImage(byte *dst_buf, const byte *src_buf, int columns, i default: break; } - return R_SUCCESS; + return SUCCESS; } const byte *SagaEngine::getImagePal(const byte *image_data, size_t image_size) { diff --git a/saga/image.h b/saga/image.h index 6f0813d5dd..11d9861dcd 100644 --- a/saga/image.h +++ b/saga/image.h @@ -28,13 +28,13 @@ namespace Saga { -#define R_MIN_IMG_RLECODE 3 +#define MIN_IMG_RLECODE 3 #define MODEX_SCANLINE_LIMIT 200 #define SAGA_IMAGE_DATA_OFFSET 776 #define SAGA_IMAGE_HEADER_LEN 8 -struct R_IMAGE_HEADER { +struct IMAGE_HEADER { int width; int height; int unknown4; diff --git a/saga/input.cpp b/saga/input.cpp index 4bab4b5a54..37f764eee4 100644 --- a/saga/input.cpp +++ b/saga/input.cpp @@ -132,7 +132,7 @@ int SagaEngine::processInput() { } } - return R_SUCCESS; + return SUCCESS; } Point SagaEngine::getMousePos() { diff --git a/saga/interface.cpp b/saga/interface.cpp index 6d76ce36e1..420ec11986 100644 --- a/saga/interface.cpp +++ b/saga/interface.cpp @@ -41,7 +41,7 @@ namespace Saga { -static R_VERB_DATA I_VerbData[] = { +static VERB_DATA I_VerbData[] = { {I_VERB_WALKTO, "verb_walkto", "Walk to", S_VERB_WALKTO}, {I_VERB_LOOKAT, "verb_lookat", "Look at", S_VERB_LOOKAT}, {I_VERB_PICKUP, "verb_pickup", "Pick up", S_VERB_PICKUP}, @@ -52,7 +52,7 @@ static R_VERB_DATA I_VerbData[] = { {I_VERB_GIVE, "verb_give", "Give", S_VERB_GIVE} }; -static R_INTERFACE_DESC ITE_interface = { +static INTERFACE_DESC ITE_interface = { ITE_STATUS_Y, ITE_STATUS_W, ITE_STATUS_H, @@ -72,7 +72,7 @@ static R_INTERFACE_DESC ITE_interface = { ITE_RPORTRAIT_Y }; -static R_INTERFACE_BUTTON ITE_c_buttons[] = { +static INTERFACE_BUTTON ITE_c_buttons[] = { {5, 4, 46, 47, "Portrait", 0, 0, BUTTON_NONE, 0}, // "Walk To" and "Talk To" share button sprites {52, 4, 109, 14, "Walk To", 1, 2, BUTTON_VERB, I_VERB_WALKTO}, @@ -96,7 +96,7 @@ static R_INTERFACE_BUTTON ITE_c_buttons[] = { {306, 41, 314, 45, "InvDown", 0, 0, BUTTON_NONE, 0} }; -static R_INTERFACE_DESC IHNM_interface = { +static INTERFACE_DESC IHNM_interface = { IHNM_STATUS_Y, IHNM_STATUS_W, IHNM_STATUS_H, @@ -116,7 +116,7 @@ static R_INTERFACE_DESC IHNM_interface = { IHNM_RPORTRAIT_Y }; -static R_INTERFACE_BUTTON IHNM_c_buttons[] = { +static INTERFACE_BUTTON IHNM_c_buttons[] = { {5, 4, 46, 47, "Portrait", 0, 0, 0, 0} }; @@ -126,19 +126,19 @@ int Interface::registerLang(void) { for (i = 0; i < ARRAYSIZE(I_VerbData); i++) { if (CVAR_Register_S(I_VerbData[i].verb_str, I_VerbData[i].verb_cvar, - NULL, R_CVAR_CFG, R_VERB_STRLIMIT) != R_SUCCESS) { + NULL, CVAR_CFG, VERB_STRLIMIT) != SUCCESS) { - return R_FAILURE; + return FAILURE; } assert(CVAR_Find(I_VerbData[i].verb_cvar) != NULL); } - return R_SUCCESS; + return SUCCESS; } Interface::Interface(SagaEngine *vm) : _vm(vm), _initialized(false) { - R_GAME_RESOURCEDESC g_resdesc; + GAME_RESOURCEDESC g_resdesc; int game_type; int result; @@ -154,8 +154,8 @@ Interface::Interface(SagaEngine *vm) : _vm(vm), _initialized(false) { } // Load interface module resource file context - result = GAME_GetFileContext(&_interfaceContext, R_GAME_RESOURCEFILE, 0); - if (result != R_SUCCESS) { + result = GAME_GetFileContext(&_interfaceContext, GAME_RESOURCEFILE, 0); + if (result != SUCCESS) { return; } @@ -182,14 +182,14 @@ Interface::Interface(SagaEngine *vm) : _vm(vm), _initialized(false) { // Load command panel resource result = RSC_LoadResource(_interfaceContext, g_resdesc.command_panel_rn, &_cPanel.res, &_cPanel.res_len); - if (result != R_SUCCESS) { + if (result != SUCCESS) { return; } // Load dialogue panel resource result = RSC_LoadResource(_interfaceContext, g_resdesc.dialogue_panel_rn, &_dPanel.res, &_dPanel.res_len); - if (result != R_SUCCESS) { + if (result != SUCCESS) { return; } @@ -232,13 +232,13 @@ int Interface::activate() { _active = 1; draw(); - return R_SUCCESS; + return SUCCESS; } int Interface::deactivate() { _active = 0; - return R_SUCCESS; + return SUCCESS; } int Interface::setMode(int mode) { @@ -247,15 +247,15 @@ int Interface::setMode(int mode) { _panelMode = mode; draw(); - return R_SUCCESS; + return SUCCESS; } int Interface::setStatusText(const char *new_txt) { assert(new_txt != NULL); - strncpy(_statusText, new_txt, R_STATUS_TEXT_LEN); + strncpy(_statusText, new_txt, STATUS_TEXT_LEN); - return R_SUCCESS; + return SUCCESS; } int Interface::loadScenePortraits(int res) { @@ -269,19 +269,19 @@ int Interface::setLeftPortrait(int portrait) { _leftPortrait = portrait; draw(); - return R_SUCCESS; + return SUCCESS; } int Interface::setRightPortrait(int portrait) { _rightPortrait = portrait; draw(); - return R_SUCCESS; + return SUCCESS; } int Interface::draw() { - R_GAME_DISPLAYINFO g_di; - R_SURFACE *back_buf; + GAME_DISPLAYINFO g_di; + SURFACE *back_buf; int xbase; int ybase; @@ -296,7 +296,7 @@ int Interface::draw() { back_buf = _vm->_gfx->getBackBuffer(); if (!_active) { - return R_SUCCESS; + return SUCCESS; } // Get game display info @@ -344,18 +344,18 @@ int Interface::draw() { _vm->_sprite->draw(back_buf, _scenePortraits, _rightPortrait, rportrait_x, rportrait_y); } - return R_SUCCESS; + return SUCCESS; } int Interface::update(const Point& imousePt, int update_flag) { - R_GAME_DISPLAYINFO g_di; + GAME_DISPLAYINFO g_di; - R_SURFACE *back_buf; + SURFACE *back_buf; int imouse_x, imouse_y; if (!_active) { - return R_SUCCESS; + return SUCCESS; } imouse_x = imousePt.x; @@ -387,11 +387,11 @@ int Interface::update(const Point& imousePt, int update_flag) { drawStatusBar(back_buf); - return R_SUCCESS; + return SUCCESS; } -int Interface::drawStatusBar(R_SURFACE *ds) { - R_GAME_DISPLAYINFO g_di; +int Interface::drawStatusBar(SURFACE *ds) { + GAME_DISPLAYINFO g_di; Rect rect; int string_w; @@ -412,10 +412,10 @@ int Interface::drawStatusBar(R_SURFACE *ds) { _vm->_font->draw(SMALL_FONT_ID, ds, _statusText, 0, (_iDesc.status_w / 2) - (string_w / 2), _iDesc.status_y + _iDesc.status_txt_y, _iDesc.status_txt_col, 0, 0); - return R_SUCCESS; + return SUCCESS; } -int Interface::handleCommandClick(R_SURFACE *ds, const Point& imousePt) { +int Interface::handleCommandClick(SURFACE *ds, const Point& imousePt) { int hit_button; int ibutton_num; @@ -429,9 +429,9 @@ int Interface::handleCommandClick(R_SURFACE *ds, const Point& imousePt) { int set_button; hit_button = hitTest(imousePt, &ibutton_num); - if (hit_button != R_SUCCESS) { + if (hit_button != SUCCESS) { // Clicking somewhere other than a button doesn't do anything - return R_SUCCESS; + return SUCCESS; } x_base = _cPanel.x; @@ -463,10 +463,10 @@ int Interface::handleCommandClick(R_SURFACE *ds, const Point& imousePt) { } } - return R_SUCCESS; + return SUCCESS; } -int Interface::handleCommandUpdate(R_SURFACE *ds, const Point& imousePt) { +int Interface::handleCommandUpdate(SURFACE *ds, const Point& imousePt) { int hit_button; int ibutton_num; @@ -482,7 +482,7 @@ int Interface::handleCommandUpdate(R_SURFACE *ds, const Point& imousePt) { hit_button = hitTest(imousePt, &ibutton_num); - if (hit_button == R_SUCCESS) { + if (hit_button == SUCCESS) { // Hovering over a command panel button setStatusText(I_VerbData[_activeVerb].verb_str); } @@ -517,10 +517,10 @@ int Interface::handleCommandUpdate(R_SURFACE *ds, const Point& imousePt) { } } - return R_SUCCESS; + return SUCCESS; } -int Interface::handlePlayfieldClick(R_SURFACE *ds, const Point& imousePt) { +int Interface::handlePlayfieldClick(SURFACE *ds, const Point& imousePt) { int objectNum; uint16 object_flags = 0; @@ -533,7 +533,7 @@ int Interface::handlePlayfieldClick(R_SURFACE *ds, const Point& imousePt) { // Player clicked on empty spot - walk here regardless of verb _vm->_actor->StoA(&iactor_pt, imousePt); _vm->_actor->walkTo(0, &iactor_pt, 0, NULL); - return R_SUCCESS; + return SUCCESS; } object_flags = _vm->_scene->_objectMap->getFlags(objectNum); @@ -554,15 +554,15 @@ int Interface::handlePlayfieldClick(R_SURFACE *ds, const Point& imousePt) { _vm->_actor->walkTo(0, &iactor_pt, 0, NULL); } - return R_SUCCESS; + return SUCCESS; } -int Interface::handlePlayfieldUpdate(R_SURFACE *ds, const Point& imousePt) { +int Interface::handlePlayfieldUpdate(SURFACE *ds, const Point& imousePt) { const char *object_name; int objectNum; uint16 object_flags = 0; - char new_status[R_STATUS_TEXT_LEN]; + char new_status[STATUS_TEXT_LEN]; new_status[0] = 0; @@ -571,7 +571,7 @@ int Interface::handlePlayfieldUpdate(R_SURFACE *ds, const Point& imousePt) { if (objectNum == -1) { // Cursor over nothing - just display current verb setStatusText(I_VerbData[_activeVerb].verb_str); - return R_SUCCESS; + return SUCCESS; } object_flags = _vm->_scene->_objectMap->getFlags(objectNum); @@ -580,20 +580,20 @@ int Interface::handlePlayfieldUpdate(R_SURFACE *ds, const Point& imousePt) { if (object_flags & OBJECT_EXIT) { // FIXME. This is wrong // Normal scene object - display as subject of verb - snprintf(new_status, R_STATUS_TEXT_LEN, "%s %s", I_VerbData[_activeVerb].verb_str, object_name); + snprintf(new_status, STATUS_TEXT_LEN, "%s %s", I_VerbData[_activeVerb].verb_str, object_name); } else { // Not normal scene object - override verb as we can only // walk to this object - snprintf(new_status, R_STATUS_TEXT_LEN, "%s %s", I_VerbData[I_VERB_WALKTO].verb_str, object_name); + snprintf(new_status, STATUS_TEXT_LEN, "%s %s", I_VerbData[I_VERB_WALKTO].verb_str, object_name); } setStatusText(new_status); - return R_SUCCESS; + return SUCCESS; } int Interface::hitTest(const Point& imousePt, int *ibutton) { - R_INTERFACE_BUTTON *buttons; + INTERFACE_BUTTON *buttons; int nbuttons; int xbase; @@ -611,12 +611,12 @@ int Interface::hitTest(const Point& imousePt, int *ibutton) { if ((imousePt.x >= (xbase + buttons[i].x1)) && (imousePt.x < (xbase + buttons[i].x2)) && (imousePt.y >= (ybase + buttons[i].y1)) && (imousePt.y < (ybase + buttons[i].y2))) { *ibutton = i; - return R_SUCCESS; + return SUCCESS; } } *ibutton = -1; - return R_FAILURE; + return FAILURE; } } // End of namespace Saga diff --git a/saga/interface.h b/saga/interface.h index 003f2c123d..fc820de12d 100644 --- a/saga/interface.h +++ b/saga/interface.h @@ -36,9 +36,9 @@ enum INTERFACE_UPDATE_FLAGS { UPDATE_MOUSECLICK }; -#define R_VERB_STRLIMIT 32 +#define VERB_STRLIMIT 32 -#define R_STATUS_TEXT_LEN 128 +#define STATUS_TEXT_LEN 128 #define COMMAND_DEFAULT_BUTTON 1 @@ -76,13 +76,13 @@ enum INTERFACE_UPDATE_FLAGS { #define IHNM_RPORTRAIT_X -1 #define IHNM_RPORTRAIT_Y -1 -enum R_PANEL_MODES { +enum PANEL_MODES { kPanelNone, kPanelCommand, kPanelDialogue }; -enum R_BUTTON_FLAGS { +enum BUTTON_FLAGS { BUTTON_NONE = 0x0, BUTTON_LABEL = 0x01, BUTTON_BITMAP = 0x02, @@ -92,7 +92,7 @@ enum R_BUTTON_FLAGS { #define BUTTON_VERB ( BUTTON_LABEL | BUTTON_BITMAP | BUTTON_SET ) -struct R_INTERFACE_BUTTON { +struct INTERFACE_BUTTON { int x1; int y1; int x2; @@ -104,7 +104,7 @@ struct R_INTERFACE_BUTTON { int data; }; -struct R_INTERFACE_PANEL { +struct INTERFACE_PANEL { byte *res; size_t res_len; int x; @@ -115,11 +115,11 @@ struct R_INTERFACE_PANEL { int img_h; int set_button; int nbuttons; - R_INTERFACE_BUTTON *buttons; - R_SPRITELIST *sprites; + INTERFACE_BUTTON *buttons; + SPRITELIST *sprites; }; -struct R_INTERFACE_DESC { +struct INTERFACE_DESC { int status_y; int status_w; int status_h; @@ -136,7 +136,7 @@ struct R_INTERFACE_DESC { int rportrait_y; }; -struct R_INTERFACE_MODULE { +struct INTERFACE_MODULE { }; enum INTERFACE_VERBS { @@ -150,10 +150,10 @@ enum INTERFACE_VERBS { I_VERB_GIVE }; -struct R_VERB_DATA { +struct VERB_DATA { int i_verb; const char *verb_cvar; - char verb_str[R_VERB_STRLIMIT]; + char verb_str[VERB_STRLIMIT]; int s_verb; }; @@ -177,32 +177,32 @@ class Interface { private: int hitTest(const Point& imousePt, int *ibutton); - int drawStatusBar(R_SURFACE *ds); - int handleCommandUpdate(R_SURFACE *ds, const Point& imousePt); - int handleCommandClick(R_SURFACE *ds, const Point& imousePt); - int handlePlayfieldUpdate(R_SURFACE *ds, const Point& imousePt); - int handlePlayfieldClick(R_SURFACE *ds, const Point& imousePt); + int drawStatusBar(SURFACE *ds); + int handleCommandUpdate(SURFACE *ds, const Point& imousePt); + int handleCommandClick(SURFACE *ds, const Point& imousePt); + int handlePlayfieldUpdate(SURFACE *ds, const Point& imousePt); + int handlePlayfieldClick(SURFACE *ds, const Point& imousePt); private: SagaEngine *_vm; bool _initialized; int _active; - R_RSCFILE_CONTEXT *_interfaceContext; - R_INTERFACE_DESC _iDesc; + RSCFILE_CONTEXT *_interfaceContext; + INTERFACE_DESC _iDesc; int _panelMode; - R_INTERFACE_PANEL _cPanel; - R_INTERFACE_PANEL _dPanel; - char _statusText[R_STATUS_TEXT_LEN]; + INTERFACE_PANEL _cPanel; + INTERFACE_PANEL _dPanel; + char _statusText[STATUS_TEXT_LEN]; int _leftPortrait; int _rightPortrait; - R_SPRITELIST *_defPortraits; - R_SPRITELIST *_scenePortraits; + SPRITELIST *_defPortraits; + SPRITELIST *_scenePortraits; int _activeVerb; - R_SCRIPT_THREAD *_iThread; + SCRIPT_THREAD *_iThread; }; } // End of namespace Saga -#endif /* R_INTERFACE_H__ */ +#endif /* INTERFACE_H__ */ /* end "r_interface.h" */ diff --git a/saga/isomap.cpp b/saga/isomap.cpp index 5d004133b2..701f8cf690 100644 --- a/saga/isomap.cpp +++ b/saga/isomap.cpp @@ -38,8 +38,8 @@ IsoMap::IsoMap(Gfx *gfx) { } int IsoMap::loadTileset(const byte *tileres_p, size_t tileres_len) { - R_ISOTILE_ENTRY first_entry; - R_ISOTILE_ENTRY *tile_tbl; + ISOTILE_ENTRY first_entry; + ISOTILE_ENTRY *tile_tbl; uint16 i; @@ -55,9 +55,9 @@ int IsoMap::loadTileset(const byte *tileres_p, size_t tileres_len) { readS.seek(0); - tile_tbl = (R_ISOTILE_ENTRY *)malloc(_tile_ct * sizeof *tile_tbl); + tile_tbl = (ISOTILE_ENTRY *)malloc(_tile_ct * sizeof *tile_tbl); if (tile_tbl == NULL) { - return R_MEM; + return MEM; } for (i = 0; i < _tile_ct; i++) { @@ -73,11 +73,11 @@ int IsoMap::loadTileset(const byte *tileres_p, size_t tileres_len) { _tileres_p = tileres_p; _tileres_len = tileres_len; - return R_SUCCESS; + return SUCCESS; } int IsoMap::loadMetaTileset(const byte *mtileres_p, size_t mtileres_len) { - R_ISO_METATILE_ENTRY *mtile_tbl; + ISO_METATILE_ENTRY *mtile_tbl; uint16 mtile_ct; uint16 ct; int i; @@ -88,9 +88,9 @@ int IsoMap::loadMetaTileset(const byte *mtileres_p, size_t mtileres_len) { MemoryReadStream readS(mtileres_p, mtileres_len); mtile_ct = mtileres_len / SAGA_METATILE_ENTRY_LEN; - mtile_tbl = (R_ISO_METATILE_ENTRY *)malloc(mtile_ct * sizeof *mtile_tbl); + mtile_tbl = (ISO_METATILE_ENTRY *)malloc(mtile_ct * sizeof *mtile_tbl); if (mtile_tbl == NULL) { - return R_MEM; + return MEM; } for (ct = 0; ct < mtile_ct; ct++) { @@ -111,7 +111,7 @@ int IsoMap::loadMetaTileset(const byte *mtileres_p, size_t mtileres_len) { _mtiles_loaded = 1; - return R_SUCCESS; + return SUCCESS; } int IsoMap::loadMetamap(const byte *mm_res_p, size_t mm_res_len) { @@ -128,20 +128,20 @@ int IsoMap::loadMetamap(const byte *mm_res_p, size_t mm_res_len) { _mm_res_len = mm_res_len; _metamap_loaded = 1; - return R_SUCCESS; + return SUCCESS; } -int IsoMap::draw(R_SURFACE *dst_s) { - R_GAME_DISPLAYINFO disp_info; +int IsoMap::draw(SURFACE *dst_s) { + GAME_DISPLAYINFO disp_info; GAME_GetDisplayInfo(&disp_info); Rect iso_rect(disp_info.logical_w, disp_info.scene_h); _gfx->drawRect(dst_s, &iso_rect, 0); drawMetamap(dst_s, -1000, -500); - return R_SUCCESS; + return SUCCESS; } -int IsoMap::drawMetamap(R_SURFACE *dst_s, int map_x, int map_y) { +int IsoMap::drawMetamap(SURFACE *dst_s, int map_x, int map_y) { int meta_base_x = map_x; int meta_base_y = map_y; int meta_xi; @@ -164,10 +164,10 @@ int IsoMap::drawMetamap(R_SURFACE *dst_s, int map_x, int map_y) { meta_base_y += 64; } - return R_SUCCESS; + return SUCCESS; } -int IsoMap::drawMetaTile(R_SURFACE *dst_s, uint16 mtile_i, int mtile_x, int mtile_y) { +int IsoMap::drawMetaTile(SURFACE *dst_s, uint16 mtile_i, int mtile_x, int mtile_y) { int tile_xi; int tile_yi; int tile_x; @@ -175,11 +175,11 @@ int IsoMap::drawMetaTile(R_SURFACE *dst_s, uint16 mtile_i, int mtile_x, int mtil int tile_base_x; int tile_base_y; int tile_i; - R_ISO_METATILE_ENTRY *mtile_p; + ISO_METATILE_ENTRY *mtile_p; assert(_init && _mtiles_loaded); if (mtile_i >= _mtile_ct) { - return R_FAILURE; + return FAILURE; } mtile_p = &_mtile_tbl[mtile_i]; @@ -200,10 +200,10 @@ int IsoMap::drawMetaTile(R_SURFACE *dst_s, uint16 mtile_i, int mtile_x, int mtil tile_base_y += SAGA_ISOTILE_BASEHEIGHT / 2 + 1; } - return R_SUCCESS; + return SUCCESS; } -int IsoMap::drawTile(R_SURFACE *dst_s, uint16 tile_i, int tile_x, int tile_y) { +int IsoMap::drawTile(SURFACE *dst_s, uint16 tile_i, int tile_x, int tile_y) { const byte *tile_p; const byte *read_p; byte *draw_p; @@ -219,17 +219,17 @@ int IsoMap::drawTile(R_SURFACE *dst_s, uint16 tile_i, int tile_x, int tile_y) { assert(_init && _tiles_loaded); if (tile_i >= _tile_ct) { - return R_FAILURE; + return FAILURE; } /* temporary x clip */ if (tile_x < 0) { - return R_SUCCESS; + return SUCCESS; } /* temporary x clip */ if (tile_x >= 320 - 32) { - return R_SUCCESS; + return SUCCESS; } tile_p = _tileres_p + _tile_tbl[tile_i].tile_offset; @@ -247,7 +247,7 @@ int IsoMap::drawTile(R_SURFACE *dst_s, uint16 tile_i, int tile_x, int tile_y) { // temporary y clip if (draw_y < 0) { - return R_SUCCESS; + return SUCCESS; } for (row = 0; row < tile_h; row++) { @@ -256,7 +256,7 @@ int IsoMap::drawTile(R_SURFACE *dst_s, uint16 tile_i, int tile_x, int tile_y) { // temporary y clip if ((draw_y + row) >= 137) { - return R_SUCCESS; + return SUCCESS; } for (;;) { @@ -276,7 +276,7 @@ int IsoMap::drawTile(R_SURFACE *dst_s, uint16 tile_i, int tile_x, int tile_y) { } } - return R_SUCCESS; + return SUCCESS; } } // End of namespace Saga diff --git a/saga/isomap.h b/saga/isomap.h index 7ac95975d5..0699a96fb1 100644 --- a/saga/isomap.h +++ b/saga/isomap.h @@ -28,7 +28,7 @@ namespace Saga { -struct R_ISOTILE_ENTRY { +struct ISOTILE_ENTRY { int tile_h; int unknown01; size_t tile_offset; @@ -49,7 +49,7 @@ struct R_ISOTILE_ENTRY { #define SAGA_METAMAP_H 16 #define SAGA_METAMAP_SIZE 256 -struct R_ISO_METATILE_ENTRY { +struct ISO_METATILE_ENTRY { int mtile_n; int unknown02; int unknown04; @@ -67,23 +67,23 @@ public: int loadTileset(const byte *, size_t); int loadMetaTileset(const byte *, size_t); int loadMetamap(const byte *mm_res_p, size_t mm_res_len); - int draw(R_SURFACE *dst_s); + int draw(SURFACE *dst_s); private: - int drawTile(R_SURFACE *dst_s, uint16 tile_i, int tile_x, int tile_y); - int drawMetaTile(R_SURFACE *dst_s, uint16 mtile_i, int mtile_x, int mtile_y); - int drawMetamap(R_SURFACE *dst_s, int map_x, int map_y); + int drawTile(SURFACE *dst_s, uint16 tile_i, int tile_x, int tile_y); + int drawMetaTile(SURFACE *dst_s, uint16 mtile_i, int mtile_x, int mtile_y); + int drawMetamap(SURFACE *dst_s, int map_x, int map_y); int _init; int _tiles_loaded; const byte *_tileres_p; size_t _tileres_len; uint16 _tile_ct; - R_ISOTILE_ENTRY *_tile_tbl; + ISOTILE_ENTRY *_tile_tbl; int _mtiles_loaded; const byte *_mtileres_p; size_t _mtileres_len; uint16 _mtile_ct; - R_ISO_METATILE_ENTRY *_mtile_tbl; + ISO_METATILE_ENTRY *_mtile_tbl; int _metamap_loaded; int _metamap_n; diff --git a/saga/ite_introproc.cpp b/saga/ite_introproc.cpp index 99a8971c96..adb9df7446 100644 --- a/saga/ite_introproc.cpp +++ b/saga/ite_introproc.cpp @@ -43,7 +43,7 @@ namespace Saga { -static R_INTRO_DIALOGUE IntroDiag[] = { +static INTRO_DIALOGUE IntroDiag[] = { { CAVE_VOICE_0, "intro1a", "We see the sky, we see the land, we see the water, " @@ -111,7 +111,7 @@ static R_INTRO_DIALOGUE IntroDiag[] = { }, }; -R_SCENE_QUEUE ITE_IntroList[] = { +SCENE_QUEUE ITE_IntroList[] = { {ITE_INTRO_ANIM_SCENE, NULL, BY_RESOURCE, Scene::SC_ITEIntroAnimProc, 0, SCENE_NOFADE}, {ITE_CAVE_SCENE_1, NULL, BY_RESOURCE, Scene::SC_ITEIntroCave1Proc, 0, SCENE_FADE_NO_INTERFACE}, {ITE_CAVE_SCENE_2, NULL, BY_RESOURCE, Scene::SC_ITEIntroCave2Proc, 0, SCENE_NOFADE}, @@ -127,8 +127,8 @@ int Scene::ITEStartProc() { size_t n_introscenes; size_t i; - R_SCENE_QUEUE first_scene; - R_GAME_SCENEDESC gs_desc; + SCENE_QUEUE first_scene; + GAME_SCENEDESC gs_desc; n_introscenes = ARRAYSIZE(ITE_IntroList); @@ -146,7 +146,7 @@ int Scene::ITEStartProc() { _vm->_scene->queueScene(&first_scene); - return R_SUCCESS; + return SUCCESS; } int Scene::ITEIntroRegisterLang() { @@ -155,30 +155,30 @@ int Scene::ITEIntroRegisterLang() { for (i = 0; i < ARRAYSIZE(IntroDiag); i++) { if (CVAR_Register_S(IntroDiag[i].i_str, IntroDiag[i].i_cvar_name, - NULL, R_CVAR_CFG, R_INTRO_STRMAX) != R_SUCCESS) { + NULL, CVAR_CFG, INTRO_STRMAX) != SUCCESS) { warning("Error registering intro text cvars"); - return R_FAILURE; + return FAILURE; } } - return R_SUCCESS; + return SUCCESS; } -int Scene::SC_ITEIntroAnimProc(int param, R_SCENE_INFO *scene_info, void *refCon) { +int Scene::SC_ITEIntroAnimProc(int param, SCENE_INFO *scene_info, void *refCon) { return ((Scene *)refCon)->ITEIntroAnimProc(param, scene_info); } // Handles the introductory Dreamer's Guild / NWC logo animation scene. -int Scene::ITEIntroAnimProc(int param, R_SCENE_INFO *scene_info) { - R_EVENT event; +int Scene::ITEIntroAnimProc(int param, SCENE_INFO *scene_info) { + EVENT event; switch (param) { case SCENE_BEGIN: // Background for intro scene is the first frame of the // intro animation; display it and set the palette - event.type = R_ONESHOT_EVENT; - event.code = R_BG_EVENT; + event.type = ONESHOT_EVENT; + event.code = BG_EVENT; event.op = EVENT_DISPLAY; event.param = SET_PALETTE; event.time = 0; @@ -207,10 +207,10 @@ int Scene::ITEIntroAnimProc(int param, R_SCENE_INFO *scene_info) { _vm->_anim->play(0, 0); // Queue intro music playback - event.type = R_ONESHOT_EVENT; - event.code = R_MUSIC_EVENT; + event.type = ONESHOT_EVENT; + event.code = MUSIC_EVENT; event.param = MUSIC_1; - event.param2 = R_MUSIC_LOOP; + event.param2 = MUSIC_LOOP; event.op = EVENT_PLAY; event.time = 0; @@ -226,27 +226,27 @@ int Scene::ITEIntroAnimProc(int param, R_SCENE_INFO *scene_info) { return 0; } -int Scene::SC_ITEIntroCave1Proc(int param, R_SCENE_INFO *scene_info, void *refCon) { +int Scene::SC_ITEIntroCave1Proc(int param, SCENE_INFO *scene_info, void *refCon) { return ((Scene *)refCon)->ITEIntroCave1Proc(param, scene_info); } // Handles first introductory cave painting scene -int Scene::ITEIntroCave1Proc(int param, R_SCENE_INFO *scene_info) { - R_EVENT event; - R_EVENT *q_event; +int Scene::ITEIntroCave1Proc(int param, SCENE_INFO *scene_info) { + EVENT event; + EVENT *q_event; int event_time = 0; int voice_len; int voice_pad = 50; - R_TEXTLIST_ENTRY text_entry; - R_TEXTLIST_ENTRY *entry_p; + TEXTLIST_ENTRY text_entry; + TEXTLIST_ENTRY *entry_p; int i; int font_flags = FONT_OUTLINE | FONT_CENTERED; switch (param) { case SCENE_BEGIN: // Begin palette cycling animation for candles - event.type = R_ONESHOT_EVENT; - event.code = R_PALANIM_EVENT; + event.type = ONESHOT_EVENT; + event.code = PALANIM_EVENT; event.op = EVENT_CYCLESTART; event.time = 0; @@ -265,8 +265,8 @@ int Scene::ITEIntroCave1Proc(int param, R_SCENE_INFO *scene_info) { entry_p = _vm->textAddEntry(scene_info->text_list, &text_entry); // Display text - event.type = R_ONESHOT_EVENT; - event.code = R_TEXT_EVENT; + event.type = ONESHOT_EVENT; + event.code = TEXT_EVENT; event.op = EVENT_DISPLAY; event.data = entry_p; event.time = event_time; @@ -274,8 +274,8 @@ int Scene::ITEIntroCave1Proc(int param, R_SCENE_INFO *scene_info) { q_event = _vm->_events->chain(q_event, &event); // Play voice - event.type = R_ONESHOT_EVENT; - event.code = R_VOICE_EVENT; + event.type = ONESHOT_EVENT; + event.code = VOICE_EVENT; event.op = EVENT_PLAY; event.param = IntroDiag[i].i_voice_rn; event.time = event_time; @@ -288,8 +288,8 @@ int Scene::ITEIntroCave1Proc(int param, R_SCENE_INFO *scene_info) { } // Remove text - event.type = R_ONESHOT_EVENT; - event.code = R_TEXT_EVENT; + event.type = ONESHOT_EVENT; + event.code = TEXT_EVENT; event.op = EVENT_REMOVE; event.data = entry_p; event.time = voice_len; @@ -300,8 +300,8 @@ int Scene::ITEIntroCave1Proc(int param, R_SCENE_INFO *scene_info) { } // End scene after last dialogue over - event.type = R_ONESHOT_EVENT; - event.code = R_SCENE_EVENT; + event.type = ONESHOT_EVENT; + event.code = SCENE_EVENT; event.op = EVENT_END; event.time = 0; @@ -318,27 +318,27 @@ int Scene::ITEIntroCave1Proc(int param, R_SCENE_INFO *scene_info) { return 0; } -int Scene::SC_ITEIntroCave2Proc(int param, R_SCENE_INFO *scene_info, void *refCon) { +int Scene::SC_ITEIntroCave2Proc(int param, SCENE_INFO *scene_info, void *refCon) { return ((Scene *)refCon)->ITEIntroCave2Proc(param, scene_info); } // Handles second introductory cave painting scene -int Scene::ITEIntroCave2Proc(int param, R_SCENE_INFO *scene_info) { - R_EVENT event; - R_EVENT *q_event; +int Scene::ITEIntroCave2Proc(int param, SCENE_INFO *scene_info) { + EVENT event; + EVENT *q_event; int event_time = 0; int voice_len; int voice_pad = 50; - R_TEXTLIST_ENTRY text_entry; - R_TEXTLIST_ENTRY *entry_p; + TEXTLIST_ENTRY text_entry; + TEXTLIST_ENTRY *entry_p; int i; int font_flags = FONT_OUTLINE | FONT_CENTERED; switch (param) { case SCENE_BEGIN: // Start 'dissolve' transition to new scene background - event.type = R_CONTINUOUS_EVENT; - event.code = R_TRANSITION_EVENT; + event.type = CONTINUOUS_EVENT; + event.code = TRANSITION_EVENT; event.op = EVENT_DISSOLVE; event.time = 0; event.duration = DISSOLVE_DURATION; @@ -346,8 +346,8 @@ int Scene::ITEIntroCave2Proc(int param, R_SCENE_INFO *scene_info) { q_event = _vm->_events->queue(&event); // Begin palette cycling animation for candles - event.type = R_ONESHOT_EVENT; - event.code = R_PALANIM_EVENT; + event.type = ONESHOT_EVENT; + event.code = PALANIM_EVENT; event.op = EVENT_CYCLESTART; event.time = 0; @@ -366,8 +366,8 @@ int Scene::ITEIntroCave2Proc(int param, R_SCENE_INFO *scene_info) { entry_p = _vm->textAddEntry(scene_info->text_list, &text_entry); // Display text - event.type = R_ONESHOT_EVENT; - event.code = R_TEXT_EVENT; + event.type = ONESHOT_EVENT; + event.code = TEXT_EVENT; event.op = EVENT_DISPLAY; event.data = entry_p; event.time = event_time; @@ -375,8 +375,8 @@ int Scene::ITEIntroCave2Proc(int param, R_SCENE_INFO *scene_info) { q_event = _vm->_events->chain(q_event, &event); // Play voice - event.type = R_ONESHOT_EVENT; - event.code = R_VOICE_EVENT; + event.type = ONESHOT_EVENT; + event.code = VOICE_EVENT; event.op = EVENT_PLAY; event.param = IntroDiag[i].i_voice_rn; event.time = event_time; @@ -389,8 +389,8 @@ int Scene::ITEIntroCave2Proc(int param, R_SCENE_INFO *scene_info) { } // Remove text - event.type = R_ONESHOT_EVENT; - event.code = R_TEXT_EVENT; + event.type = ONESHOT_EVENT; + event.code = TEXT_EVENT; event.op = EVENT_REMOVE; event.data = entry_p; event.time = voice_len; @@ -401,8 +401,8 @@ int Scene::ITEIntroCave2Proc(int param, R_SCENE_INFO *scene_info) { } // End scene after last dialogue over - event.type = R_ONESHOT_EVENT; - event.code = R_SCENE_EVENT; + event.type = ONESHOT_EVENT; + event.code = SCENE_EVENT; event.op = EVENT_END; event.time = event_time; @@ -418,27 +418,27 @@ int Scene::ITEIntroCave2Proc(int param, R_SCENE_INFO *scene_info) { return 0; } -int Scene::SC_ITEIntroCave3Proc(int param, R_SCENE_INFO *scene_info, void *refCon) { +int Scene::SC_ITEIntroCave3Proc(int param, SCENE_INFO *scene_info, void *refCon) { return ((Scene *)refCon)->ITEIntroCave3Proc(param, scene_info); } // Handles third introductory cave painting scene -int Scene::ITEIntroCave3Proc(int param, R_SCENE_INFO *scene_info) { - R_EVENT event; - R_EVENT *q_event; +int Scene::ITEIntroCave3Proc(int param, SCENE_INFO *scene_info) { + EVENT event; + EVENT *q_event; int event_time = 0; int voice_len; int voice_pad = 50; - R_TEXTLIST_ENTRY text_entry; - R_TEXTLIST_ENTRY *entry_p; + TEXTLIST_ENTRY text_entry; + TEXTLIST_ENTRY *entry_p; int i; int font_flags = FONT_OUTLINE | FONT_CENTERED; switch (param) { case SCENE_BEGIN: // Start 'dissolve' transition to new scene background - event.type = R_CONTINUOUS_EVENT; - event.code = R_TRANSITION_EVENT; + event.type = CONTINUOUS_EVENT; + event.code = TRANSITION_EVENT; event.op = EVENT_DISSOLVE; event.time = 0; event.duration = DISSOLVE_DURATION; @@ -446,8 +446,8 @@ int Scene::ITEIntroCave3Proc(int param, R_SCENE_INFO *scene_info) { q_event = _vm->_events->queue(&event); // Begin palette cycling animation for candles - event.type = R_ONESHOT_EVENT; - event.code = R_PALANIM_EVENT; + event.type = ONESHOT_EVENT; + event.code = PALANIM_EVENT; event.op = EVENT_CYCLESTART; event.time = 0; @@ -466,8 +466,8 @@ int Scene::ITEIntroCave3Proc(int param, R_SCENE_INFO *scene_info) { entry_p = _vm->textAddEntry(scene_info->text_list, &text_entry); // Display text - event.type = R_ONESHOT_EVENT; - event.code = R_TEXT_EVENT; + event.type = ONESHOT_EVENT; + event.code = TEXT_EVENT; event.op = EVENT_DISPLAY; event.data = entry_p; event.time = event_time; @@ -475,8 +475,8 @@ int Scene::ITEIntroCave3Proc(int param, R_SCENE_INFO *scene_info) { q_event = _vm->_events->chain(q_event, &event); // Play voice - event.type = R_ONESHOT_EVENT; - event.code = R_VOICE_EVENT; + event.type = ONESHOT_EVENT; + event.code = VOICE_EVENT; event.op = EVENT_PLAY; event.param = IntroDiag[i].i_voice_rn; event.time = event_time; @@ -489,8 +489,8 @@ int Scene::ITEIntroCave3Proc(int param, R_SCENE_INFO *scene_info) { } // Remove text - event.type = R_ONESHOT_EVENT; - event.code = R_TEXT_EVENT; + event.type = ONESHOT_EVENT; + event.code = TEXT_EVENT; event.op = EVENT_REMOVE; event.data = entry_p; event.time = voice_len; @@ -501,8 +501,8 @@ int Scene::ITEIntroCave3Proc(int param, R_SCENE_INFO *scene_info) { } // End scene after last dialogue over - event.type = R_ONESHOT_EVENT; - event.code = R_SCENE_EVENT; + event.type = ONESHOT_EVENT; + event.code = SCENE_EVENT; event.op = EVENT_END; event.time = event_time; @@ -519,27 +519,27 @@ int Scene::ITEIntroCave3Proc(int param, R_SCENE_INFO *scene_info) { return 0; } -int Scene::SC_ITEIntroCave4Proc(int param, R_SCENE_INFO *scene_info, void *refCon) { +int Scene::SC_ITEIntroCave4Proc(int param, SCENE_INFO *scene_info, void *refCon) { return ((Scene *)refCon)->ITEIntroCave4Proc(param, scene_info); } // Handles fourth introductory cave painting scene -int Scene::ITEIntroCave4Proc(int param, R_SCENE_INFO *scene_info) { - R_EVENT event; - R_EVENT *q_event; +int Scene::ITEIntroCave4Proc(int param, SCENE_INFO *scene_info) { + EVENT event; + EVENT *q_event; int event_time = 0; int voice_len; int voice_pad = 50; - R_TEXTLIST_ENTRY text_entry; - R_TEXTLIST_ENTRY *entry_p; + TEXTLIST_ENTRY text_entry; + TEXTLIST_ENTRY *entry_p; int i; int font_flags = FONT_OUTLINE | FONT_CENTERED; switch (param) { case SCENE_BEGIN: // Start 'dissolve' transition to new scene background - event.type = R_CONTINUOUS_EVENT; - event.code = R_TRANSITION_EVENT; + event.type = CONTINUOUS_EVENT; + event.code = TRANSITION_EVENT; event.op = EVENT_DISSOLVE; event.time = 0; event.duration = DISSOLVE_DURATION; @@ -547,8 +547,8 @@ int Scene::ITEIntroCave4Proc(int param, R_SCENE_INFO *scene_info) { q_event = _vm->_events->queue(&event); // Begin palette cycling animation for candles - event.type = R_ONESHOT_EVENT; - event.code = R_PALANIM_EVENT; + event.type = ONESHOT_EVENT; + event.code = PALANIM_EVENT; event.op = EVENT_CYCLESTART; event.time = 0; @@ -567,8 +567,8 @@ int Scene::ITEIntroCave4Proc(int param, R_SCENE_INFO *scene_info) { entry_p = _vm->textAddEntry(scene_info->text_list, &text_entry); // Display text - event.type = R_ONESHOT_EVENT; - event.code = R_TEXT_EVENT; + event.type = ONESHOT_EVENT; + event.code = TEXT_EVENT; event.op = EVENT_DISPLAY; event.data = entry_p; event.time = event_time; @@ -576,8 +576,8 @@ int Scene::ITEIntroCave4Proc(int param, R_SCENE_INFO *scene_info) { q_event = _vm->_events->chain(q_event, &event); // Play voice - event.type = R_ONESHOT_EVENT; - event.code = R_VOICE_EVENT; + event.type = ONESHOT_EVENT; + event.code = VOICE_EVENT; event.op = EVENT_PLAY; event.param = IntroDiag[i].i_voice_rn; event.time = event_time; @@ -590,8 +590,8 @@ int Scene::ITEIntroCave4Proc(int param, R_SCENE_INFO *scene_info) { } // Remove text - event.type = R_ONESHOT_EVENT; - event.code = R_TEXT_EVENT; + event.type = ONESHOT_EVENT; + event.code = TEXT_EVENT; event.op = EVENT_REMOVE; event.data = entry_p; event.time = voice_len; @@ -602,8 +602,8 @@ int Scene::ITEIntroCave4Proc(int param, R_SCENE_INFO *scene_info) { } // End scene after last dialogue over - event.type = R_ONESHOT_EVENT; - event.code = R_SCENE_EVENT; + event.type = ONESHOT_EVENT; + event.code = SCENE_EVENT; event.op = EVENT_END; event.time = event_time; @@ -620,16 +620,16 @@ int Scene::ITEIntroCave4Proc(int param, R_SCENE_INFO *scene_info) { return 0; } -int Scene::SC_ITEIntroValleyProc(int param, R_SCENE_INFO *scene_info, void *refCon) { +int Scene::SC_ITEIntroValleyProc(int param, SCENE_INFO *scene_info, void *refCon) { return ((Scene *)refCon)->ITEIntroValleyProc(param, scene_info); } // Handles intro title scene (valley overlook) -int Scene::ITEIntroValleyProc(int param, R_SCENE_INFO *scene_info) { - R_TEXTLIST_ENTRY text_entry; - R_TEXTLIST_ENTRY *entry_p; - R_EVENT event; - R_EVENT *q_event; +int Scene::ITEIntroValleyProc(int param, SCENE_INFO *scene_info) { + TEXTLIST_ENTRY text_entry; + TEXTLIST_ENTRY *entry_p; + EVENT event; + EVENT *q_event; int i; const INTRO_CREDIT credits[] = { @@ -661,8 +661,8 @@ int Scene::ITEIntroValleyProc(int param, R_SCENE_INFO *scene_info) { // Begin ITE title theme music _vm->_music->stop(); - event.type = R_ONESHOT_EVENT; - event.code = R_MUSIC_EVENT; + event.type = ONESHOT_EVENT; + event.code = MUSIC_EVENT; event.param = MUSIC_2; event.param2 = 0; event.op = EVENT_PLAY; @@ -671,8 +671,8 @@ int Scene::ITEIntroValleyProc(int param, R_SCENE_INFO *scene_info) { q_event = _vm->_events->queue(&event); // Pause animation before logo - event.type = R_ONESHOT_EVENT; - event.code = R_ANIM_EVENT; + event.type = ONESHOT_EVENT; + event.code = ANIM_EVENT; event.op = EVENT_SETFLAG; event.param = 0; event.param2 = ANIM_PAUSE; @@ -681,8 +681,8 @@ int Scene::ITEIntroValleyProc(int param, R_SCENE_INFO *scene_info) { q_event = _vm->_events->chain(q_event, &event); // Display logo - event.type = R_CONTINUOUS_EVENT; - event.code = R_TRANSITION_EVENT; + event.type = CONTINUOUS_EVENT; + event.code = TRANSITION_EVENT; event.op = EVENT_DISSOLVE_BGMASK; event.time = 0; event.duration = LOGO_DISSOLVE_DURATION; @@ -690,8 +690,8 @@ int Scene::ITEIntroValleyProc(int param, R_SCENE_INFO *scene_info) { q_event = _vm->_events->chain(q_event, &event); // Remove logo - event.type = R_CONTINUOUS_EVENT; - event.code = R_TRANSITION_EVENT; + event.type = CONTINUOUS_EVENT; + event.code = TRANSITION_EVENT; event.op = EVENT_DISSOLVE; event.time = 1000; event.duration = LOGO_DISSOLVE_DURATION; @@ -699,8 +699,8 @@ int Scene::ITEIntroValleyProc(int param, R_SCENE_INFO *scene_info) { q_event = _vm->_events->chain(q_event, &event); // Unpause animation before logo - event.type = R_ONESHOT_EVENT; - event.code = R_ANIM_EVENT; + event.type = ONESHOT_EVENT; + event.code = ANIM_EVENT; event.op = EVENT_CLEARFLAG; event.param = 0; event.param2 = ANIM_PAUSE; @@ -708,8 +708,8 @@ int Scene::ITEIntroValleyProc(int param, R_SCENE_INFO *scene_info) { q_event = _vm->_events->chain(q_event, &event); - event.type = R_ONESHOT_EVENT; - event.code = R_ANIM_EVENT; + event.type = ONESHOT_EVENT; + event.code = ANIM_EVENT; event.op = EVENT_FRAME; event.param = 0; event.time = LOGO_DISSOLVE_DURATION; @@ -730,8 +730,8 @@ int Scene::ITEIntroValleyProc(int param, R_SCENE_INFO *scene_info) { entry_p = _vm->textAddEntry(scene_info->text_list, &text_entry); // Display text - event.type = R_ONESHOT_EVENT; - event.code = R_TEXT_EVENT; + event.type = ONESHOT_EVENT; + event.code = TEXT_EVENT; event.op = EVENT_DISPLAY; event.data = entry_p; event.time = event_delay += credits[i].delta_time; @@ -739,8 +739,8 @@ int Scene::ITEIntroValleyProc(int param, R_SCENE_INFO *scene_info) { q_event = _vm->_events->queue(&event); // Remove text - event.type = R_ONESHOT_EVENT; - event.code = R_TEXT_EVENT; + event.type = ONESHOT_EVENT; + event.code = TEXT_EVENT; event.op = EVENT_REMOVE; event.data = entry_p; event.time = credits[i].duration; @@ -749,8 +749,8 @@ int Scene::ITEIntroValleyProc(int param, R_SCENE_INFO *scene_info) { } // End scene after credit display - event.type = R_ONESHOT_EVENT; - event.code = R_SCENE_EVENT; + event.type = ONESHOT_EVENT; + event.code = SCENE_EVENT; event.op = EVENT_END; event.time = 1000; @@ -766,16 +766,16 @@ int Scene::ITEIntroValleyProc(int param, R_SCENE_INFO *scene_info) { return 0; } -int Scene::SC_ITEIntroTreeHouseProc(int param, R_SCENE_INFO *scene_info, void *refCon) { +int Scene::SC_ITEIntroTreeHouseProc(int param, SCENE_INFO *scene_info, void *refCon) { return ((Scene *)refCon)->ITEIntroTreeHouseProc(param, scene_info); } // Handles second intro credit screen (treehouse view) -int Scene::ITEIntroTreeHouseProc(int param, R_SCENE_INFO *scene_info) { - R_TEXTLIST_ENTRY text_entry; - R_TEXTLIST_ENTRY *entry_p; - R_EVENT event; - R_EVENT *q_event; +int Scene::ITEIntroTreeHouseProc(int param, SCENE_INFO *scene_info) { + TEXTLIST_ENTRY text_entry; + TEXTLIST_ENTRY *entry_p; + EVENT event; + EVENT *q_event; int i; @@ -812,8 +812,8 @@ int Scene::ITEIntroTreeHouseProc(int param, R_SCENE_INFO *scene_info) { switch (param) { case SCENE_BEGIN: // Start 'dissolve' transition to new scene background - event.type = R_CONTINUOUS_EVENT; - event.code = R_TRANSITION_EVENT; + event.type = CONTINUOUS_EVENT; + event.code = TRANSITION_EVENT; event.op = EVENT_DISSOLVE; event.time = 0; event.duration = DISSOLVE_DURATION; @@ -840,8 +840,8 @@ int Scene::ITEIntroTreeHouseProc(int param, R_SCENE_INFO *scene_info) { entry_p = _vm->textAddEntry(scene_info->text_list, &text_entry); // Display text - event.type = R_ONESHOT_EVENT; - event.code = R_TEXT_EVENT; + event.type = ONESHOT_EVENT; + event.code = TEXT_EVENT; event.op = EVENT_DISPLAY; event.data = entry_p; event.time = event_delay += credits[i].delta_time; @@ -849,8 +849,8 @@ int Scene::ITEIntroTreeHouseProc(int param, R_SCENE_INFO *scene_info) { q_event = _vm->_events->queue(&event); // Remove text - event.type = R_ONESHOT_EVENT; - event.code = R_TEXT_EVENT; + event.type = ONESHOT_EVENT; + event.code = TEXT_EVENT; event.op = EVENT_REMOVE; event.data = entry_p; event.time = credits[i].duration; @@ -859,8 +859,8 @@ int Scene::ITEIntroTreeHouseProc(int param, R_SCENE_INFO *scene_info) { } // End scene after credit display - event.type = R_ONESHOT_EVENT; - event.code = R_SCENE_EVENT; + event.type = ONESHOT_EVENT; + event.code = SCENE_EVENT; event.op = EVENT_END; event.time = 1000; @@ -876,16 +876,16 @@ int Scene::ITEIntroTreeHouseProc(int param, R_SCENE_INFO *scene_info) { return 0; } -int Scene::SC_ITEIntroFairePathProc(int param, R_SCENE_INFO *scene_info, void *refCon) { +int Scene::SC_ITEIntroFairePathProc(int param, SCENE_INFO *scene_info, void *refCon) { return ((Scene *)refCon)->ITEIntroFairePathProc(param, scene_info); } // Handles third intro credit screen (path to puzzle tent) -int Scene::ITEIntroFairePathProc(int param, R_SCENE_INFO *scene_info) { - R_TEXTLIST_ENTRY text_entry; - R_TEXTLIST_ENTRY *entry_p; - R_EVENT event; - R_EVENT *q_event; +int Scene::ITEIntroFairePathProc(int param, SCENE_INFO *scene_info) { + TEXTLIST_ENTRY text_entry; + TEXTLIST_ENTRY *entry_p; + EVENT event; + EVENT *q_event; long event_delay = 0; int i; @@ -925,8 +925,8 @@ int Scene::ITEIntroFairePathProc(int param, R_SCENE_INFO *scene_info) { case SCENE_BEGIN: // Start 'dissolve' transition to new scene background - event.type = R_CONTINUOUS_EVENT; - event.code = R_TRANSITION_EVENT; + event.type = CONTINUOUS_EVENT; + event.code = TRANSITION_EVENT; event.op = EVENT_DISSOLVE; event.time = 0; event.duration = DISSOLVE_DURATION; @@ -953,8 +953,8 @@ int Scene::ITEIntroFairePathProc(int param, R_SCENE_INFO *scene_info) { entry_p = _vm->textAddEntry(scene_info->text_list, &text_entry); // Display text - event.type = R_ONESHOT_EVENT; - event.code = R_TEXT_EVENT; + event.type = ONESHOT_EVENT; + event.code = TEXT_EVENT; event.op = EVENT_DISPLAY; event.data = entry_p; event.time = event_delay += credits[i].delta_time; @@ -962,8 +962,8 @@ int Scene::ITEIntroFairePathProc(int param, R_SCENE_INFO *scene_info) { q_event = _vm->_events->queue(&event); // Remove text - event.type = R_ONESHOT_EVENT; - event.code = R_TEXT_EVENT; + event.type = ONESHOT_EVENT; + event.code = TEXT_EVENT; event.op = EVENT_REMOVE; event.data = entry_p; event.time = credits[i].duration; @@ -972,8 +972,8 @@ int Scene::ITEIntroFairePathProc(int param, R_SCENE_INFO *scene_info) { } // End scene after credit display - event.type = R_ONESHOT_EVENT; - event.code = R_SCENE_EVENT; + event.type = ONESHOT_EVENT; + event.code = SCENE_EVENT; event.op = EVENT_END; event.time = 1000; @@ -989,22 +989,22 @@ int Scene::ITEIntroFairePathProc(int param, R_SCENE_INFO *scene_info) { return 0; } -int Scene::SC_ITEIntroFaireTentProc(int param, R_SCENE_INFO *scene_info, void *refCon) { +int Scene::SC_ITEIntroFaireTentProc(int param, SCENE_INFO *scene_info, void *refCon) { return ((Scene *)refCon)->ITEIntroFaireTentProc(param, scene_info); } // Handles fourth intro credit screen (treehouse view) -int Scene::ITEIntroFaireTentProc(int param, R_SCENE_INFO *scene_info) { - R_EVENT event; - R_EVENT *q_event; - R_EVENT *q_event_start; +int Scene::ITEIntroFaireTentProc(int param, SCENE_INFO *scene_info) { + EVENT event; + EVENT *q_event; + EVENT *q_event_start; switch (param) { case SCENE_BEGIN: // Start 'dissolve' transition to new scene background - event.type = R_CONTINUOUS_EVENT; - event.code = R_TRANSITION_EVENT; + event.type = CONTINUOUS_EVENT; + event.code = TRANSITION_EVENT; event.op = EVENT_DISSOLVE; event.time = 0; event.duration = DISSOLVE_DURATION; @@ -1012,8 +1012,8 @@ int Scene::ITEIntroFaireTentProc(int param, R_SCENE_INFO *scene_info) { q_event_start = _vm->_events->queue(&event); // End scene after momentary pause - event.type = R_ONESHOT_EVENT; - event.code = R_SCENE_EVENT; + event.type = ONESHOT_EVENT; + event.code = SCENE_EVENT; event.op = EVENT_END; event.time = 5000; q_event = _vm->_events->chain(q_event_start, &event); diff --git a/saga/music.cpp b/saga/music.cpp index 2ba0c170b0..60e9739f13 100644 --- a/saga/music.cpp +++ b/saga/music.cpp @@ -341,46 +341,46 @@ Music::~Music() { // reset.mid seems to be unused. const MUSIC_MIDITABLE Music::_midiTableITECD[26] = { - { "cave.mid", R_MUSIC_LOOP }, // 9 - { "intro.mid", R_MUSIC_LOOP }, // 10 - { "fvillage.mid", R_MUSIC_LOOP }, // 11 - { "elkhall.mid", R_MUSIC_LOOP }, // 12 + { "cave.mid", MUSIC_LOOP }, // 9 + { "intro.mid", MUSIC_LOOP }, // 10 + { "fvillage.mid", MUSIC_LOOP }, // 11 + { "elkhall.mid", MUSIC_LOOP }, // 12 { "mouse.mid", 0 }, // 13 - { "darkclaw.mid", R_MUSIC_LOOP }, // 14 - { "birdchrp.mid", R_MUSIC_LOOP }, // 15 - { "orbtempl.mid", R_MUSIC_LOOP }, // 16 - { "spooky.mid", R_MUSIC_LOOP }, // 17 - { "catfest.mid", R_MUSIC_LOOP }, // 18 + { "darkclaw.mid", MUSIC_LOOP }, // 14 + { "birdchrp.mid", MUSIC_LOOP }, // 15 + { "orbtempl.mid", MUSIC_LOOP }, // 16 + { "spooky.mid", MUSIC_LOOP }, // 17 + { "catfest.mid", MUSIC_LOOP }, // 18 { "elkfanfare.mid", 0 }, // 19 - { "bcexpl.mid", R_MUSIC_LOOP }, // 20 - { "boargtnt.mid", R_MUSIC_LOOP }, // 21 - { "boarking.mid", R_MUSIC_LOOP }, // 22 - { "explorea.mid", R_MUSIC_LOOP }, // 23 - { "exploreb.mid", R_MUSIC_LOOP }, // 24 - { "explorec.mid", R_MUSIC_LOOP }, // 25 - { "sunstatm.mid", R_MUSIC_LOOP }, // 26 - { "nitstrlm.mid", R_MUSIC_LOOP }, // 27 - { "humruinm.mid", R_MUSIC_LOOP }, // 28 - { "damexplm.mid", R_MUSIC_LOOP }, // 29 - { "tychom.mid", R_MUSIC_LOOP }, // 30 - { "kitten.mid", R_MUSIC_LOOP }, // 31 - { "sweet.mid", R_MUSIC_LOOP }, // 32 - { "brutalmt.mid", R_MUSIC_LOOP }, // 33 - { "shiala.mid", R_MUSIC_LOOP } // 34 + { "bcexpl.mid", MUSIC_LOOP }, // 20 + { "boargtnt.mid", MUSIC_LOOP }, // 21 + { "boarking.mid", MUSIC_LOOP }, // 22 + { "explorea.mid", MUSIC_LOOP }, // 23 + { "exploreb.mid", MUSIC_LOOP }, // 24 + { "explorec.mid", MUSIC_LOOP }, // 25 + { "sunstatm.mid", MUSIC_LOOP }, // 26 + { "nitstrlm.mid", MUSIC_LOOP }, // 27 + { "humruinm.mid", MUSIC_LOOP }, // 28 + { "damexplm.mid", MUSIC_LOOP }, // 29 + { "tychom.mid", MUSIC_LOOP }, // 30 + { "kitten.mid", MUSIC_LOOP }, // 31 + { "sweet.mid", MUSIC_LOOP }, // 32 + { "brutalmt.mid", MUSIC_LOOP }, // 33 + { "shiala.mid", MUSIC_LOOP } // 34 }; int Music::play(uint32 music_rn, uint16 flags) { - R_RSCFILE_CONTEXT *rsc_ctxt = NULL; + RSCFILE_CONTEXT *rsc_ctxt = NULL; byte *resource_data; size_t resource_size; if (!_musicInitialized) { - return R_FAILURE; + return FAILURE; } if (!_enabled) { - return R_SUCCESS; + return SUCCESS; } _player->stopMusic(); @@ -394,7 +394,7 @@ int Music::play(uint32 music_rn, uint16 flags) { if (GAME_GetGameType() == GID_ITE) { if (music_rn >= 9 && music_rn <= 34) { - if (flags == R_MUSIC_DEFAULT) { + if (flags == MUSIC_DEFAULT) { flags = _midiTableITECD[music_rn - 9].flags; } @@ -403,7 +403,7 @@ int Music::play(uint32 music_rn, uint16 flags) { uint32 length = _digiTableITECD[music_rn - 9].length; if (length > 0) { - audioStream = makeRAWStream("music.rsc", start, length, flags == R_MUSIC_LOOP); + audioStream = makeRAWStream("music.rsc", start, length, flags == MUSIC_LOOP); } } @@ -413,14 +413,14 @@ int Music::play(uint32 music_rn, uint16 flags) { } } - if (flags == R_MUSIC_DEFAULT) { + if (flags == MUSIC_DEFAULT) { flags = 0; } if (audioStream) { debug(0, "Playing digitized music"); _mixer->playInputStream(&_musicHandle, audioStream, true); - return R_SUCCESS; + return SUCCESS; } // FIXME: Is resource_data ever freed? @@ -437,12 +437,12 @@ int Music::play(uint32 music_rn, uint16 flags) { } else { // Load XMI resource data - GAME_GetFileContext(&rsc_ctxt, R_GAME_RESOURCEFILE, 0); + GAME_GetFileContext(&rsc_ctxt, GAME_RESOURCEFILE, 0); if (RSC_LoadResource(rsc_ctxt, music_rn, &resource_data, - &resource_size) != R_SUCCESS ) { + &resource_size) != SUCCESS ) { warning("Music::play(): Resource load failed: %u", music_rn); - return R_FAILURE; + return FAILURE; } _player->setGM(false); @@ -463,37 +463,37 @@ int Music::play(uint32 music_rn, uint16 flags) { _player->_parser = parser; _player->setVolume(ConfMan.getInt("music_volume") * ConfMan.getInt("master_volume") / 255); - if (flags & R_MUSIC_LOOP) + if (flags & MUSIC_LOOP) _player->setLoop(true); else _player->setLoop(false); _player->playMusic(); - return R_SUCCESS; + return SUCCESS; } int Music::pause(void) { if (!_musicInitialized) { - return R_FAILURE; + return FAILURE; } - return R_SUCCESS; + return SUCCESS; } int Music::resume(void) { if (!_musicInitialized) { - return R_FAILURE; + return FAILURE; } - return R_SUCCESS; + return SUCCESS; } int Music::stop(void) { if (!_musicInitialized) { - return R_FAILURE; + return FAILURE; } - return R_SUCCESS; + return SUCCESS; } } // End of namespace Saga diff --git a/saga/music.h b/saga/music.h index e7b0cd1783..21e6292859 100644 --- a/saga/music.h +++ b/saga/music.h @@ -34,8 +34,8 @@ namespace Saga { enum MUSIC_FLAGS { - R_MUSIC_LOOP = 0x0001, - R_MUSIC_DEFAULT = 0xffff + MUSIC_LOOP = 0x0001, + MUSIC_DEFAULT = 0xffff }; struct MUSIC_MIDITABLE { @@ -108,7 +108,7 @@ public: void hasNativeMT32(bool b) { _player->hasNativeMT32(b); } void setPassThrough(bool b) { _player->setPassThrough(b); } - int play(uint32 music_rn, uint16 flags = R_MUSIC_DEFAULT); + int play(uint32 music_rn, uint16 flags = MUSIC_DEFAULT); int pause(void); int resume(void); int stop(void); diff --git a/saga/objectmap.cpp b/saga/objectmap.cpp index 1a402aec37..c959256160 100644 --- a/saga/objectmap.cpp +++ b/saga/objectmap.cpp @@ -51,8 +51,8 @@ ObjectMap::~ObjectMap() { // Loads an object map resource ( objects ( clickareas ( points ) ) ) int ObjectMap::load(const byte *om_res, size_t om_res_len) { - R_OBJECTMAP_ENTRY *object_map; - R_CLICKAREA *clickarea; + OBJECTMAP_ENTRY *object_map; + CLICKAREA *clickarea; Point *point; int i, k, m; @@ -66,11 +66,11 @@ int ObjectMap::load(const byte *om_res, size_t om_res_len) { // Obtain object count N and allocate space for N objects _nObjects = readS.readUint16LE(); - _objectMaps = (R_OBJECTMAP_ENTRY *)malloc(_nObjects * sizeof *_objectMaps); + _objectMaps = (OBJECTMAP_ENTRY *)malloc(_nObjects * sizeof *_objectMaps); if (_objectMaps == NULL) { warning("Error: Memory allocation failed"); - return R_MEM; + return MEM; } // Load all N objects @@ -82,11 +82,11 @@ int ObjectMap::load(const byte *om_res, size_t om_res_len) { readS.readByte(); object_map->objectNum = readS.readUint16LE(); object_map->scriptNum = readS.readUint16LE(); - object_map->clickareas = (R_CLICKAREA *)malloc(object_map->nClickareas * sizeof *(object_map->clickareas)); + object_map->clickareas = (CLICKAREA *)malloc(object_map->nClickareas * sizeof *(object_map->clickareas)); if (object_map->clickareas == NULL) { warning("Error: Memory allocation failed"); - return R_MEM; + return MEM; } // Load all clickareas for this object @@ -98,7 +98,7 @@ int ObjectMap::load(const byte *om_res, size_t om_res_len) { clickarea->points = (Point *)malloc(clickarea->n_points * sizeof *(clickarea->points)); if (clickarea->points == NULL) { warning("Error: Memory allocation failed"); - return R_MEM; + return MEM; } // Load all points for this clickarea @@ -114,18 +114,18 @@ int ObjectMap::load(const byte *om_res, size_t om_res_len) { _objectsLoaded = true; - return R_SUCCESS; + return SUCCESS; } // Frees all storage allocated for the current object map data int ObjectMap::freeMem() { - R_OBJECTMAP_ENTRY *object_map; - R_CLICKAREA *clickarea; + OBJECTMAP_ENTRY *object_map; + CLICKAREA *clickarea; int i, k; if (!_objectsLoaded) { - return R_FAILURE; + return FAILURE; } for (i = 0; i < _nObjects; i++) { @@ -143,7 +143,7 @@ int ObjectMap::freeMem() { _objectsLoaded = false; - return R_SUCCESS; + return SUCCESS; } // Loads an object name list resource @@ -170,7 +170,7 @@ int ObjectMap::loadNames(const unsigned char *onl_res, size_t onl_res_len) { if (_names == NULL) { warning("Error: Memory allocation failed"); - return R_MEM; + return MEM; } for (i = 0; i < n_names; i++) { @@ -182,13 +182,13 @@ int ObjectMap::loadNames(const unsigned char *onl_res, size_t onl_res_len) { _namesLoaded = true; - return R_SUCCESS; + return SUCCESS; } // Frees all storage allocated for the current object name list data int ObjectMap::freeNames() { if (!_namesLoaded) { - return R_FAILURE; + return FAILURE; } if (_nNames) { @@ -196,13 +196,13 @@ int ObjectMap::freeNames() { } _namesLoaded = false; - return R_SUCCESS; + return SUCCESS; } // If 'object' is a valid object number in the currently loaded object // name list resource, the funciton sets '*name' to the descriptive string -// corresponding to 'object' and returns R_SUCCESS. Otherwise it returns -// R_FAILURE. +// corresponding to 'object' and returns SUCCESS. Otherwise it returns +// FAILURE. const char *ObjectMap::getName(int object) { assert(_namesLoaded); assert((object > 0) && (object <= _nNames)); @@ -227,8 +227,8 @@ const uint16 ObjectMap::getFlags(int object) { // If 'object' is a valid object number in the currently loaded object // name list resource, the funciton sets '*ep_num' to the entrypoint number -// corresponding to 'object' and returns R_SUCCESS. Otherwise, it returns -// R_FAILURE. +// corresponding to 'object' and returns SUCCESS. Otherwise, it returns +// FAILURE. const int ObjectMap::getEPNum(int object) { int i; @@ -246,9 +246,9 @@ const int ObjectMap::getEPNum(int object) { // Uses Gfx::drawLine to display all clickareas for each object in the // currently loaded object map resource. -int ObjectMap::draw(R_SURFACE *ds, const Point& imousePt, int color, int color2) { - R_OBJECTMAP_ENTRY *object_map; - R_CLICKAREA *clickarea; +int ObjectMap::draw(SURFACE *ds, const Point& imousePt, int color, int color2) { + OBJECTMAP_ENTRY *object_map; + CLICKAREA *clickarea; char txt_buf[32]; @@ -261,7 +261,7 @@ int ObjectMap::draw(R_SURFACE *ds, const Point& imousePt, int color, int color2) int i, k; if (!_objectsLoaded) { - return R_FAILURE; + return FAILURE; } if ((objectNum = hitTest(imousePt)) != -1) { @@ -298,13 +298,13 @@ int ObjectMap::draw(R_SURFACE *ds, const Point& imousePt, int color, int color2) _vm->_gfx->getWhite(), _vm->_gfx->getBlack(), FONT_OUTLINE); } - return R_SUCCESS; + return SUCCESS; } int ObjectMap::hitTest(const Point& imousePt) { Point imouse; - R_OBJECTMAP_ENTRY *object_map; - R_CLICKAREA *clickarea; + OBJECTMAP_ENTRY *object_map; + CLICKAREA *clickarea; Point *points; int n_points; diff --git a/saga/objectmap.h b/saga/objectmap.h index fded217be2..4e1d326507 100644 --- a/saga/objectmap.h +++ b/saga/objectmap.h @@ -42,7 +42,7 @@ enum OBJECT_FLAGS { OBJECT_PROJECT = (1<<3) }; -struct R_OBJECTMAP_ENTRY { +struct OBJECTMAP_ENTRY { byte flags; byte defaultVerb; @@ -50,7 +50,7 @@ struct R_OBJECTMAP_ENTRY { int scriptNum; int nClickareas; - R_CLICKAREA *clickareas; + CLICKAREA *clickareas; }; class ObjectMap{ @@ -65,7 +65,7 @@ public: const char *getName(int object); const uint16 getFlags(int object); const int getEPNum(int object); - int draw(R_SURFACE *draw_surface, const Point& imousePt, int color, int color2); + int draw(SURFACE *draw_surface, const Point& imousePt, int color, int color2); int hitTest(const Point& imousePt); void info(void); @@ -73,7 +73,7 @@ private: bool _objectsLoaded; int _nObjects; - R_OBJECTMAP_ENTRY *_objectMaps; + OBJECTMAP_ENTRY *_objectMaps; bool _namesLoaded; int _nNames; diff --git a/saga/palanim.cpp b/saga/palanim.cpp index 860333d8c5..fb15019af4 100644 --- a/saga/palanim.cpp +++ b/saga/palanim.cpp @@ -51,13 +51,13 @@ int PalAnim::loadPalAnim(const byte *resdata, size_t resdata_len) { } if (resdata == NULL) { - return R_FAILURE; + return FAILURE; } MemoryReadStream readS(resdata, resdata_len); if (GAME_GetGameType() == GID_IHNM) { - return R_SUCCESS; + return SUCCESS; } _entryCount = readS.readUint16LE(); @@ -67,7 +67,7 @@ int PalAnim::loadPalAnim(const byte *resdata, size_t resdata_len) { test_p = calloc(_entryCount, sizeof(PALANIM_ENTRY)); if (test_p == NULL) { warning("PalAnim::loadPalAnim(): Allocation failure"); - return R_MEM; + return MEM; } _entries = (PALANIM_ENTRY *)test_p; @@ -88,20 +88,20 @@ int PalAnim::loadPalAnim(const byte *resdata, size_t resdata_len) { test_p = calloc(1, sizeof(char) * pal_count); if (test_p == NULL) { warning("PalAnim::loadPalAnim(): Allocation failure"); - return R_MEM; + return MEM; } _entries[i].pal_index = (byte *)test_p; debug(2, "PalAnim::loadPalAnim(): Entry %d: Loading %d SAGA_COLOR structures.", i, color_count); - test_p = calloc(1, sizeof(R_COLOR) * color_count); + test_p = calloc(1, sizeof(COLOR) * color_count); if (test_p == NULL) { warning("PalAnim::loadPalAnim(): Allocation failure"); - return R_MEM; + return MEM; } - _entries[i].colors = (R_COLOR *)test_p; + _entries[i].colors = (COLOR *)test_p; for (p = 0; p < pal_count; p++) { _entries[i].pal_index[p] = readS.readByte(); @@ -115,28 +115,28 @@ int PalAnim::loadPalAnim(const byte *resdata, size_t resdata_len) { } _loaded = true; - return R_SUCCESS; + return SUCCESS; } int PalAnim::cycleStart() { - R_EVENT event; + EVENT event; if (!_loaded) { - return R_FAILURE; + return FAILURE; } - event.type = R_ONESHOT_EVENT; - event.code = R_PALANIM_EVENT; + event.type = ONESHOT_EVENT; + event.code = PALANIM_EVENT; event.op = EVENT_CYCLESTEP; event.time = PALANIM_CYCLETIME; _vm->_events->queue(&event); - return R_SUCCESS; + return SUCCESS; } int PalAnim::cycleStep(int vectortime) { - R_SURFACE *back_buf; + SURFACE *back_buf; static PALENTRY pal[256]; uint16 pal_index; @@ -146,10 +146,10 @@ int PalAnim::cycleStep(int vectortime) { uint16 cycle; uint16 cycle_limit; - R_EVENT event; + EVENT event; if (!_loaded) { - return R_FAILURE; + return FAILURE; } _vm->_gfx->getCurrentPal(pal); @@ -175,21 +175,21 @@ int PalAnim::cycleStep(int vectortime) { _vm->_gfx->setPalette(back_buf, pal); - event.type = R_ONESHOT_EVENT; - event.code = R_PALANIM_EVENT; + event.type = ONESHOT_EVENT; + event.code = PALANIM_EVENT; event.op = EVENT_CYCLESTEP; event.time = vectortime + PALANIM_CYCLETIME; _vm->_events->queue(&event); - return R_SUCCESS; + return SUCCESS; } int PalAnim::freePalAnim() { uint16 i; if (!_loaded) { - return R_FAILURE; + return FAILURE; } for (i = 0; i < _entryCount; i++) { @@ -205,7 +205,7 @@ int PalAnim::freePalAnim() { _loaded = false; - return R_SUCCESS; + return SUCCESS; } } // End of namespace Saga diff --git a/saga/palanim.h b/saga/palanim.h index d19fc62b24..390f8e94ac 100644 --- a/saga/palanim.h +++ b/saga/palanim.h @@ -35,7 +35,7 @@ struct PALANIM_ENTRY { uint16 color_count; uint16 cycle; byte *pal_index; - R_COLOR *colors; + COLOR *colors; }; struct PALANIM_DATA { diff --git a/saga/render.cpp b/saga/render.cpp index f401611412..4aaccd3b09 100644 --- a/saga/render.cpp +++ b/saga/render.cpp @@ -45,7 +45,7 @@ namespace Saga { const char *test_txt = "The quick brown fox jumped over the lazy dog. She sells sea shells down by the sea shore."; int Render::reg(void) { - return R_SUCCESS; + return SUCCESS; } Render::Render(SagaEngine *vm, OSystem *system) { @@ -53,7 +53,7 @@ Render::Render(SagaEngine *vm, OSystem *system) { _system = system; _initialized = false; - R_GAME_DISPLAYINFO disp_info; + GAME_DISPLAYINFO disp_info; int tmp_w, tmp_h, tmp_bytepp; // Initialize system graphics @@ -104,9 +104,9 @@ bool Render::initialized() { } int Render::drawScene() { - R_SURFACE *backbuf_surface; - R_GAME_DISPLAYINFO disp_info; - R_SCENE_INFO scene_info; + SURFACE *backbuf_surface; + GAME_DISPLAYINFO disp_info; + SCENE_INFO scene_info; SCENE_BGINFO bg_info; Point bg_pt; char txt_buf[20]; @@ -114,7 +114,7 @@ int Render::drawScene() { Point mouse_pt; if (!_initialized) { - return R_FAILURE; + return FAILURE; } _framecount++; @@ -137,7 +137,7 @@ int Render::drawScene() { if (_vm->_scene->_objectMap) _vm->_scene->_objectMap->draw(backbuf_surface, mouse_pt, _vm->_gfx->getWhite(), _vm->_gfx->getBlack()); if (_vm->_scene->_actionMap) - _vm->_scene->_actionMap->draw(backbuf_surface, _vm->_gfx->matchColor(R_RGB_RED)); + _vm->_scene->_actionMap->draw(backbuf_surface, _vm->_gfx->matchColor(RGB_RED)); } // Draw queued actors @@ -161,9 +161,9 @@ int Render::drawScene() { // Display "paused game" message, if applicable if (_flags & RF_RENDERPAUSE) { - int msg_len = strlen(R_PAUSEGAME_MSG); - int msg_w = _vm->_font->getStringWidth(BIG_FONT_ID, R_PAUSEGAME_MSG, msg_len, FONT_OUTLINE); - _vm->_font->draw(BIG_FONT_ID, backbuf_surface, R_PAUSEGAME_MSG, msg_len, + int msg_len = strlen(PAUSEGAME_MSG); + int msg_w = _vm->_font->getStringWidth(BIG_FONT_ID, PAUSEGAME_MSG, msg_len, FONT_OUTLINE); + _vm->_font->draw(BIG_FONT_ID, backbuf_surface, PAUSEGAME_MSG, msg_len, (backbuf_surface->buf_w - msg_w) / 2, 90, _vm->_gfx->getWhite(), _vm->_gfx->getBlack(), FONT_OUTLINE); } @@ -189,7 +189,7 @@ int Render::drawScene() { backbuf_surface->buf_w, backbuf_surface->buf_h); _system->updateScreen(); - return R_SUCCESS; + return SUCCESS; } unsigned int Render::getFrameCount() { @@ -225,18 +225,18 @@ void Render::toggleFlag(unsigned int flag) { _flags ^= flag; } -int Render::getBufferInfo(R_BUFFER_INFO *r_bufinfo) { - assert(r_bufinfo != NULL); +int Render::getBufferInfo(BUFFER_INFO *bufinfo) { + assert(bufinfo != NULL); - r_bufinfo->r_bg_buf = _bg_buf; - r_bufinfo->r_bg_buf_w = _bg_buf_w; - r_bufinfo->r_bg_buf_h = _bg_buf_h; + bufinfo->bg_buf = _bg_buf; + bufinfo->bg_buf_w = _bg_buf_w; + bufinfo->bg_buf_h = _bg_buf_h; - r_bufinfo->r_tmp_buf = _tmp_buf; - r_bufinfo->r_tmp_buf_w = _tmp_buf_w; - r_bufinfo->r_tmp_buf_h = _tmp_buf_h; + bufinfo->tmp_buf = _tmp_buf; + bufinfo->tmp_buf_w = _tmp_buf_w; + bufinfo->tmp_buf_h = _tmp_buf_h; - return R_SUCCESS; + return SUCCESS; } } // End of namespace Saga diff --git a/saga/render.h b/saga/render.h index a694f718e5..b798cc31c2 100644 --- a/saga/render.h +++ b/saga/render.h @@ -30,7 +30,7 @@ namespace Saga { -#define R_PAUSEGAME_MSG "PAWS GAME" +#define PAUSEGAME_MSG "PAWS GAME" enum RENDER_FLAGS { RF_SHOW_FPS = 0x01, RF_PALETTE_TEST = 0x02, @@ -40,13 +40,13 @@ enum RENDER_FLAGS { RF_GAMEPAUSE = 0x20 }; -struct R_BUFFER_INFO { - byte *r_bg_buf; - int r_bg_buf_w; - int r_bg_buf_h; - byte *r_tmp_buf; - int r_tmp_buf_w; - int r_tmp_buf_h; +struct BUFFER_INFO { + byte *bg_buf; + int bg_buf_w; + int bg_buf_h; + byte *tmp_buf; + int tmp_buf_w; + int tmp_buf_h; }; class Render { @@ -61,7 +61,7 @@ public: void toggleFlag(unsigned int); unsigned int getFrameCount(void); unsigned int resetFrameCount(void); - int getBufferInfo(R_BUFFER_INFO *); + int getBufferInfo(BUFFER_INFO *); private: static void fpsTimerCallback(void *refCon); @@ -72,7 +72,7 @@ private: bool _initialized; // Module data - R_SURFACE *_backbuf_surface; + SURFACE *_backbuf_surface; byte *_bg_buf; int _bg_buf_w; @@ -81,7 +81,7 @@ private: int _tmp_buf_w; int _tmp_buf_h; - R_SPRITELIST *_test_sprite; + SPRITELIST *_test_sprite; unsigned int _fps; unsigned int _framecount; diff --git a/saga/rscfile.cpp b/saga/rscfile.cpp index 7d9a699f7d..804de7f5ee 100644 --- a/saga/rscfile.cpp +++ b/saga/rscfile.cpp @@ -29,16 +29,16 @@ namespace Saga { -R_RSCFILE_CONTEXT *RSC_CreateContext() { - R_RSCFILE_CONTEXT empty_context; +RSCFILE_CONTEXT *RSC_CreateContext() { + RSCFILE_CONTEXT empty_context; empty_context.rc_file_fspec = NULL; empty_context.rc_file_loaded = 0; empty_context.rc_res_table = NULL; empty_context.rc_res_ct = 0; empty_context.rc_file = new File(); - R_RSCFILE_CONTEXT *new_context; + RSCFILE_CONTEXT *new_context; - new_context = (R_RSCFILE_CONTEXT *)malloc(sizeof *new_context); + new_context = (RSCFILE_CONTEXT *)malloc(sizeof *new_context); if (new_context == NULL) { return NULL; } @@ -48,27 +48,27 @@ R_RSCFILE_CONTEXT *RSC_CreateContext() { return new_context; } -int RSC_OpenContext(R_RSCFILE_CONTEXT *rsc_context, const char *fspec) { +int RSC_OpenContext(RSCFILE_CONTEXT *rsc_context, const char *fspec) { if (rsc_context->rc_file->isOpen()) { - return R_FAILURE; + return FAILURE; } if (!rsc_context->rc_file->open(fspec)) { - return R_FAILURE; + return FAILURE; } rsc_context->rc_file_fspec = fspec; - if (RSC_LoadRSC(rsc_context) != R_SUCCESS) { - return R_FAILURE; + if (RSC_LoadRSC(rsc_context) != SUCCESS) { + return FAILURE; } rsc_context->rc_file_loaded = 1; - return R_SUCCESS; + return SUCCESS; } -int RSC_CloseContext(R_RSCFILE_CONTEXT *rsc_context) { +int RSC_CloseContext(RSCFILE_CONTEXT *rsc_context) { if (rsc_context->rc_file->isOpen()) { rsc_context->rc_file->close(); } @@ -77,10 +77,10 @@ int RSC_CloseContext(R_RSCFILE_CONTEXT *rsc_context) { rsc_context->rc_file_loaded = 0; - return R_SUCCESS; + return SUCCESS; } -int RSC_DestroyContext(R_RSCFILE_CONTEXT *rsc_context) { +int RSC_DestroyContext(RSCFILE_CONTEXT *rsc_context) { RSC_CloseContext(rsc_context); if (rsc_context->rc_file_loaded) { @@ -89,10 +89,10 @@ int RSC_DestroyContext(R_RSCFILE_CONTEXT *rsc_context) { free(rsc_context); - return R_SUCCESS; + return SUCCESS; } -int RSC_LoadRSC(R_RSCFILE_CONTEXT *rsc) { +int RSC_LoadRSC(RSCFILE_CONTEXT *rsc) { uint32 res_tbl_ct; uint32 res_tbl_offset; @@ -101,17 +101,17 @@ int RSC_LoadRSC(R_RSCFILE_CONTEXT *rsc) { size_t tbl_len; uint32 i; - R_RSCFILE_RESOURCE *rsc_restbl; + RSCFILE_RESOURCE *rsc_restbl; if (rsc->rc_file->size() < RSC_MIN_FILESIZE) { - return R_FAILURE; + return FAILURE; } // Read resource table info from the rear end of file rsc->rc_file->seek((long)(rsc->rc_file->size() - 8), SEEK_SET); if (rsc->rc_file->read(tblinfo_buf, RSC_TABLEINFO_SIZE) != RSC_TABLEINFO_SIZE) { - return R_FAILURE; + return FAILURE; } MemoryReadStream readS(tblinfo_buf, RSC_TABLEINFO_SIZE); @@ -122,7 +122,7 @@ int RSC_LoadRSC(R_RSCFILE_CONTEXT *rsc) { // Check for sane table offset if (res_tbl_offset != rsc->rc_file->size() - RSC_TABLEINFO_SIZE - RSC_TABLEENTRY_SIZE * res_tbl_ct) { - return R_FAILURE; + return FAILURE; } // Load resource table @@ -130,20 +130,20 @@ int RSC_LoadRSC(R_RSCFILE_CONTEXT *rsc) { tbl_buf = (byte *)malloc(tbl_len); if (tbl_buf == NULL) { - return R_FAILURE; + return FAILURE; } rsc->rc_file->seek((long)res_tbl_offset, SEEK_SET); if (rsc->rc_file->read(tbl_buf, tbl_len) != tbl_len) { free(tbl_buf); - return R_FAILURE; + return FAILURE; } - rsc_restbl = (R_RSCFILE_RESOURCE *)malloc(res_tbl_ct * sizeof *rsc_restbl); + rsc_restbl = (RSCFILE_RESOURCE *)malloc(res_tbl_ct * sizeof *rsc_restbl); if (rsc_restbl == NULL) { free(tbl_buf); - return R_FAILURE; + return FAILURE; } MemoryReadStream readS1(tbl_buf, tbl_len); @@ -154,7 +154,7 @@ int RSC_LoadRSC(R_RSCFILE_CONTEXT *rsc) { if ((rsc_restbl[i].res_offset > rsc->rc_file->size()) || (rsc_restbl[i].res_size > rsc->rc_file->size())) { free(tbl_buf); free(rsc_restbl); - return R_FAILURE; + return FAILURE; } } @@ -163,12 +163,12 @@ int RSC_LoadRSC(R_RSCFILE_CONTEXT *rsc) { free(tbl_buf); - return R_SUCCESS; + return SUCCESS; } -int RSC_FreeRSC(R_RSCFILE_CONTEXT *rsc) { +int RSC_FreeRSC(RSCFILE_CONTEXT *rsc) { if (!rsc->rc_file_loaded) { - return R_FAILURE; + return FAILURE; } delete rsc->rc_file; @@ -176,52 +176,52 @@ int RSC_FreeRSC(R_RSCFILE_CONTEXT *rsc) { free(rsc->rc_res_table); - return R_SUCCESS; + return SUCCESS; } -uint32 RSC_GetResourceCount(R_RSCFILE_CONTEXT *rsc) { +uint32 RSC_GetResourceCount(RSCFILE_CONTEXT *rsc) { return (rsc == NULL) ? 0 : rsc->rc_res_ct; } -int RSC_GetResourceSize(R_RSCFILE_CONTEXT *rsc, uint32 res_num, uint32 *res_size) { +int RSC_GetResourceSize(RSCFILE_CONTEXT *rsc, uint32 res_num, uint32 *res_size) { if ((rsc == NULL) || (res_size == NULL)) { - return R_FAILURE; + return FAILURE; } if (res_num > (rsc->rc_res_ct - 1)) { - return R_FAILURE; + return FAILURE; } *res_size = rsc->rc_res_table[res_num].res_size; - return R_SUCCESS; + return SUCCESS; } -int RSC_GetResourceOffset(R_RSCFILE_CONTEXT *rsc, uint32 res_num, uint32 *res_offset) { +int RSC_GetResourceOffset(RSCFILE_CONTEXT *rsc, uint32 res_num, uint32 *res_offset) { if ((rsc == NULL) || (res_offset == NULL)) { - return R_FAILURE; + return FAILURE; } if (res_num > (rsc->rc_res_ct - 1)) { - return R_FAILURE; + return FAILURE; } *res_offset = rsc->rc_res_table[res_num].res_offset; - return R_SUCCESS; + return SUCCESS; } -int RSC_LoadResource(R_RSCFILE_CONTEXT *rsc, uint32 res_num, byte **res_p, size_t *res_size_p) { +int RSC_LoadResource(RSCFILE_CONTEXT *rsc, uint32 res_num, byte **res_p, size_t *res_size_p) { uint32 res_offset; size_t res_size; byte *res_buf; if ((rsc == NULL) || (res_p == NULL)) { - return R_FAILURE; + return FAILURE; } if (res_num > (rsc->rc_res_ct - 1)) { - return R_FAILURE; + return FAILURE; } res_offset = rsc->rc_res_table[res_num].res_offset; @@ -231,12 +231,12 @@ int RSC_LoadResource(R_RSCFILE_CONTEXT *rsc, uint32 res_num, byte **res_p, size_ res_buf = (byte *)malloc(res_size); if (res_buf == NULL) { - return R_MEM; + return MEM; } if (rsc->rc_file->read(res_buf, res_size) != res_size) { free(res_buf); - return R_FAILURE; + return FAILURE; } *res_p = res_buf; @@ -245,13 +245,13 @@ int RSC_LoadResource(R_RSCFILE_CONTEXT *rsc, uint32 res_num, byte **res_p, size_ *res_size_p = res_size; } - return R_SUCCESS; + return SUCCESS; } int RSC_FreeResource(byte *resource_ptr) { free(resource_ptr); - return R_SUCCESS; + return SUCCESS; } } // End of namespace Saga diff --git a/saga/rscfile.h b/saga/rscfile.h index 13f50fa8c9..2c88c4c5be 100644 --- a/saga/rscfile.h +++ b/saga/rscfile.h @@ -36,22 +36,22 @@ namespace Saga { #define RSC_MIN_FILESIZE (RSC_TABLEINFO_SIZE + RSC_TABLEENTRY_SIZE + 1) -struct R_RSCFILE_RESOURCE { +struct RSCFILE_RESOURCE { int res_type; size_t res_offset; size_t res_size; }; -struct R_RSCFILE_CONTEXT { +struct RSCFILE_CONTEXT { const char *rc_file_fspec; File *rc_file; int rc_file_loaded; - R_RSCFILE_RESOURCE *rc_res_table; + RSCFILE_RESOURCE *rc_res_table; size_t rc_res_ct; }; -int RSC_LoadRSC(R_RSCFILE_CONTEXT *rsc_context); -int RSC_FreeRSC(R_RSCFILE_CONTEXT *rsc); +int RSC_LoadRSC(RSCFILE_CONTEXT *rsc_context); +int RSC_FreeRSC(RSCFILE_CONTEXT *rsc); } // End of namespace Saga diff --git a/saga/rscfile_mod.h b/saga/rscfile_mod.h index c841f9f8c2..1efb879a18 100644 --- a/saga/rscfile_mod.h +++ b/saga/rscfile_mod.h @@ -30,14 +30,14 @@ namespace Saga { -R_RSCFILE_CONTEXT *RSC_CreateContext(); -int RSC_DestroyContext(R_RSCFILE_CONTEXT *); -int RSC_OpenContext(R_RSCFILE_CONTEXT *, const char *); -int RSC_CloseContext(R_RSCFILE_CONTEXT *); -uint32 RSC_GetResourceCount(R_RSCFILE_CONTEXT *); -int RSC_GetResourceSize(R_RSCFILE_CONTEXT *, uint32, uint32 *); -int RSC_GetResourceOffset(R_RSCFILE_CONTEXT *, uint32, uint32 *); -int RSC_LoadResource(R_RSCFILE_CONTEXT *, uint32, byte **, size_t *); +RSCFILE_CONTEXT *RSC_CreateContext(); +int RSC_DestroyContext(RSCFILE_CONTEXT *); +int RSC_OpenContext(RSCFILE_CONTEXT *, const char *); +int RSC_CloseContext(RSCFILE_CONTEXT *); +uint32 RSC_GetResourceCount(RSCFILE_CONTEXT *); +int RSC_GetResourceSize(RSCFILE_CONTEXT *, uint32, uint32 *); +int RSC_GetResourceOffset(RSCFILE_CONTEXT *, uint32, uint32 *); +int RSC_LoadResource(RSCFILE_CONTEXT *, uint32, byte **, size_t *); int RSC_FreeResource(byte *); } // End of namespace Saga diff --git a/saga/saga.cpp b/saga/saga.cpp index e25c8dd1d5..4b997887b7 100644 --- a/saga/saga.cpp +++ b/saga/saga.cpp @@ -71,7 +71,7 @@ REGISTER_PLUGIN("SAGA Engine", Engine_SAGA_gameList, Engine_SAGA_create, Engine_ namespace Saga { -#define R_MAX_TIME_DELTA 100 +#define MAX_TIME_DELTA 100 static void CF_quitfunc(int argc, char *argv[], void *refCon); static void CF_testfunc(int argc, char *argv[], void *refCon); @@ -116,18 +116,18 @@ void SagaEngine::go() { _console = new Console(this); - CVAR_RegisterFunc(CF_testfunc, "testfunc", "foo [ optional foo ]", R_CVAR_NONE, 0, -1, this); + CVAR_RegisterFunc(CF_testfunc, "testfunc", "foo [ optional foo ]", CVAR_NONE, 0, -1, this); - CVAR_Register_I(&_soundEnabled, "sound", NULL, R_CVAR_CFG, 0, 1); + CVAR_Register_I(&_soundEnabled, "sound", NULL, CVAR_CFG, 0, 1); - CVAR_Register_I(&_musicEnabled, "music", NULL, R_CVAR_CFG, 0, 1); + CVAR_Register_I(&_musicEnabled, "music", NULL, CVAR_CFG, 0, 1); - CVAR_RegisterFunc(CF_quitfunc, "quit", NULL, R_CVAR_NONE, 0, 0, this); + CVAR_RegisterFunc(CF_quitfunc, "quit", NULL, CVAR_NONE, 0, 0, this); // Process config file // FIXME /* - if (CFG_Read(NULL) != R_SUCCESS) { + if (CFG_Read(NULL) != SUCCESS) { warning("Couldn't read configuration file"); } */ @@ -135,7 +135,7 @@ void SagaEngine::go() { // Process command line // Detect game and open resource files - if (GAME_Init() != R_SUCCESS) { + if (GAME_Init() != SUCCESS) { return; } @@ -162,7 +162,7 @@ void SagaEngine::go() { _previousTicks = _system->getMillis(); // Initialize graphics - R_GAME_DISPLAYINFO disp_info; + GAME_DISPLAYINFO disp_info; GAME_GetDisplayInfo(&disp_info); _gfx = new Gfx(_system, disp_info.logical_w, disp_info.logical_h); @@ -228,8 +228,8 @@ void SagaEngine::go() { msec = currentTicks - _previousTicks; _previousTicks = currentTicks; } - if (msec > R_MAX_TIME_DELTA) { - msec = R_MAX_TIME_DELTA; + if (msec > MAX_TIME_DELTA) { + msec = MAX_TIME_DELTA; } _actor->direct(msec); _events->handleEvents(msec); diff --git a/saga/saga.h b/saga/saga.h index e1fd36763e..fe3f3f6e51 100644 --- a/saga/saga.h +++ b/saga/saga.h @@ -60,16 +60,16 @@ class PalAnim; using Common::MemoryReadStream; -#define R_PBOUNDS(n,max) (((n)>=(0))&&((n)<(max))) -#define R_MAXPATH 512 +#define PBOUNDS(n,max) (((n)>=(0))&&((n)<(max))) +#define MAXPATH 512 -struct R_RSCFILE_CONTEXT; -struct R_SEMAPHORE; +struct RSCFILE_CONTEXT; +struct SEMAPHORE; -enum R_ERRORCODE { - R_MEM = -2, - R_FAILURE = -1, - R_SUCCESS = 0 +enum ERRORCODE { + MEM = -2, + FAILURE = -1, + SUCCESS = 0 }; enum SAGAGameId { @@ -78,7 +78,7 @@ enum SAGAGameId { GID_IHNM }; -struct R_CLICKAREA { +struct CLICKAREA { int n_points; Point *points; }; @@ -128,16 +128,16 @@ public: const byte *getImagePal(const byte *image_data, size_t image_size); public: - R_TEXTLIST *textCreateList(); - void textDestroyList(R_TEXTLIST *textlist); - void textClearList(R_TEXTLIST *textlist); - int textDrawList(R_TEXTLIST *textlist, R_SURFACE *ds); - R_TEXTLIST_ENTRY *textAddEntry(R_TEXTLIST *textlist, R_TEXTLIST_ENTRY *entry); - int textDeleteEntry(R_TEXTLIST *textlist, R_TEXTLIST_ENTRY *entry); - int textSetDisplay(R_TEXTLIST_ENTRY *entry, int val); - int textDraw(int font_id, R_SURFACE *ds, const char *string, int text_x, int text_y, int color, + TEXTLIST *textCreateList(); + void textDestroyList(TEXTLIST *textlist); + void textClearList(TEXTLIST *textlist); + int textDrawList(TEXTLIST *textlist, SURFACE *ds); + TEXTLIST_ENTRY *textAddEntry(TEXTLIST *textlist, TEXTLIST_ENTRY *entry); + int textDeleteEntry(TEXTLIST *textlist, TEXTLIST_ENTRY *entry); + int textSetDisplay(TEXTLIST_ENTRY *entry, int val); + int textDraw(int font_id, SURFACE *ds, const char *string, int text_x, int text_y, int color, int effect_color, int flags); - int textProcessList(R_TEXTLIST *textlist, long ms); + int textProcessList(TEXTLIST *textlist, long ms); int transitionDissolve(byte *dst_img, int dst_w, int dst_h, int dst_p, const byte *src_img, int src_w, int src_h, int src_p, int flags, int x, int y, diff --git a/saga/scene.cpp b/saga/scene.cpp index cd581d055f..aa71c92e65 100644 --- a/saga/scene.cpp +++ b/saga/scene.cpp @@ -54,18 +54,18 @@ static void CF_objectinfo(int argc, char *argv[], void *refCon); int Scene::reg() { - CVAR_Register_I(&_sceneNumber, "scene", NULL, R_CVAR_READONLY, 0, 0); - CVAR_RegisterFunc(CF_scenechange, "scene_change", "<Scene number>", R_CVAR_NONE, 1, 1, this); - CVAR_RegisterFunc(CF_sceneinfo, "scene_info", NULL, R_CVAR_NONE, 0, 0, this); + CVAR_Register_I(&_sceneNumber, "scene", NULL, CVAR_READONLY, 0, 0); + CVAR_RegisterFunc(CF_scenechange, "scene_change", "<Scene number>", CVAR_NONE, 1, 1, this); + CVAR_RegisterFunc(CF_sceneinfo, "scene_info", NULL, CVAR_NONE, 0, 0, this); CVAR_RegisterFunc(CF_actioninfo, - "action_info", NULL, R_CVAR_NONE, 0, 0, this); - CVAR_RegisterFunc(CF_objectinfo, "object_info", NULL, R_CVAR_NONE, 0, 0, this); + "action_info", NULL, CVAR_NONE, 0, 0, this); + CVAR_RegisterFunc(CF_objectinfo, "object_info", NULL, CVAR_NONE, 0, 0, this); - return R_SUCCESS; + return SUCCESS; } Scene::Scene(SagaEngine *vm) : _vm(vm), _initialized(false) { - R_GAME_SCENEDESC gs_desc; + GAME_SCENEDESC gs_desc; byte *scene_lut_p; size_t scene_lut_len; int result; @@ -75,8 +75,8 @@ Scene::Scene(SagaEngine *vm) : _vm(vm), _initialized(false) { GAME_GetSceneInfo(&gs_desc); // Load scene module resource context - result = GAME_GetFileContext(&_sceneContext, R_GAME_RESOURCEFILE, 0); - if (result != R_SUCCESS) { + result = GAME_GetFileContext(&_sceneContext, GAME_RESOURCEFILE, 0); + if (result != SUCCESS) { warning("Scene::Scene(): Couldn't load scene resource context"); return; } @@ -90,7 +90,7 @@ Scene::Scene(SagaEngine *vm) : _vm(vm), _initialized(false) { // Load scene lookup table debug(0, "Loading scene LUT from resource %u.", gs_desc.scene_lut_rn); result = RSC_LoadResource(_sceneContext, gs_desc.scene_lut_rn, &scene_lut_p, &scene_lut_len); - if (result != R_SUCCESS) { + if (result != SUCCESS) { warning("Scene::Scene(): Error: couldn't load scene LUT"); return; } @@ -154,13 +154,13 @@ Scene::~Scene() { } } -int Scene::queueScene(R_SCENE_QUEUE *scene_queue) { +int Scene::queueScene(SCENE_QUEUE *scene_queue) { assert(_initialized); assert(scene_queue != NULL); ys_dll_add_tail(_sceneQueue, scene_queue, sizeof *scene_queue); - return R_SUCCESS; + return SUCCESS; } int Scene::clearSceneQueue() { @@ -168,23 +168,23 @@ int Scene::clearSceneQueue() { ys_dll_delete_all(_sceneQueue); - return R_SUCCESS; + return SUCCESS; } int Scene::startScene() { YS_DL_NODE *node; - R_SCENE_QUEUE *scene_qdat; + SCENE_QUEUE *scene_qdat; assert(_initialized); if (_sceneLoaded) { warning("Scene::start(): Error: Can't start game...scene already loaded"); - return R_FAILURE; + return FAILURE; } if (_inGame) { warning("Scene::start(): Error: Can't start game...game already started"); - return R_FAILURE; + return FAILURE; } switch (GAME_GetGameType()) { @@ -202,31 +202,31 @@ int Scene::startScene() { // Load the head node in scene queue node = ys_dll_head(_sceneQueue); if (node == NULL) { - return R_SUCCESS; + return SUCCESS; } - scene_qdat = (R_SCENE_QUEUE *)ys_dll_get_data(node); + scene_qdat = (SCENE_QUEUE *)ys_dll_get_data(node); assert(scene_qdat != NULL); loadScene(scene_qdat->scene_n, scene_qdat->load_flag, scene_qdat->scene_proc, scene_qdat->scene_desc, scene_qdat->fadeType); - return R_SUCCESS; + return SUCCESS; } int Scene::nextScene() { YS_DL_NODE *node; - R_SCENE_QUEUE *scene_qdat; + SCENE_QUEUE *scene_qdat; assert(_initialized); if (!_sceneLoaded) { warning("Scene::next(): Error: Can't advance scene...no scene loaded"); - return R_FAILURE; + return FAILURE; } if (_inGame) { warning("Scene::next(): Error: Can't advance scene...game already started"); - return R_FAILURE; + return FAILURE; } endScene(); @@ -234,7 +234,7 @@ int Scene::nextScene() { // Delete the current head node in scene queue node = ys_dll_head(_sceneQueue); if (node == NULL) { - return R_SUCCESS; + return SUCCESS; } ys_dll_delete(node); @@ -242,15 +242,15 @@ int Scene::nextScene() { // Load the head node in scene queue node = ys_dll_head(_sceneQueue); if (node == NULL) { - return R_SUCCESS; + return SUCCESS; } - scene_qdat = (R_SCENE_QUEUE *)ys_dll_get_data(node); + scene_qdat = (SCENE_QUEUE *)ys_dll_get_data(node); assert(scene_qdat != NULL); loadScene(scene_qdat->scene_n, scene_qdat->load_flag, scene_qdat->scene_proc, scene_qdat->scene_desc, scene_qdat->fadeType); - return R_SUCCESS; + return SUCCESS; } int Scene::skipScene() { @@ -258,30 +258,30 @@ int Scene::skipScene() { YS_DL_NODE *prev_node; YS_DL_NODE *skip_node = NULL; - R_SCENE_QUEUE *scene_qdat = NULL; - R_SCENE_QUEUE *skip_qdat = NULL; + SCENE_QUEUE *scene_qdat = NULL; + SCENE_QUEUE *skip_qdat = NULL; assert(_initialized); if (!_sceneLoaded) { warning("Scene::skip(): Error: Can't skip scene...no scene loaded"); - return R_FAILURE; + return FAILURE; } if (_inGame) { warning("Scene::skip(): Error: Can't skip scene...game already started"); - return R_FAILURE; + return FAILURE; } // Walk down scene queue and try to find a skip target node = ys_dll_head(_sceneQueue); if (node == NULL) { warning("Scene::skip(): Error: Can't skip scene...no scenes in queue"); - return R_FAILURE; + return FAILURE; } for (node = ys_dll_next(node); node != NULL; node = ys_dll_next(node)) { - scene_qdat = (R_SCENE_QUEUE *)ys_dll_get_data(node); + scene_qdat = (SCENE_QUEUE *)ys_dll_get_data(node); assert(scene_qdat != NULL); if (scene_qdat->scene_skiptarget) { @@ -302,7 +302,7 @@ int Scene::skipScene() { } // Search for a scene to skip to - return R_SUCCESS; + return SUCCESS; } int Scene::changeScene(int scene_num) { @@ -310,23 +310,23 @@ int Scene::changeScene(int scene_num) { if (!_sceneLoaded) { warning("Scene::changeScene(): Error: Can't change scene. No scene currently loaded. Game in invalid state"); - return R_FAILURE; + return FAILURE; } if ((scene_num < 0) || (scene_num > _sceneMax)) { warning("Scene::changeScene(): Error: Can't change scene. Invalid scene number"); - return R_FAILURE; + return FAILURE; } if (_sceneLUT[scene_num] == 0) { warning("Scene::changeScene(): Error: Can't change scene; invalid scene descriptor resource number (0)"); - return R_FAILURE; + return FAILURE; } endScene(); loadScene(scene_num, BY_SCENE, SC_defaultScene, NULL, false); - return R_SUCCESS; + return SUCCESS; } int Scene::getMode() { @@ -341,11 +341,11 @@ int Scene::getZInfo(SCENE_ZINFO *zinfo) { zinfo->beginSlope = _desc.beginSlope; zinfo->endSlope = _desc.endSlope; - return R_SUCCESS; + return SUCCESS; } int Scene::getBGInfo(SCENE_BGINFO *bginfo) { - R_GAME_DISPLAYINFO di; + GAME_DISPLAYINFO di; int x, y; assert(_initialized); @@ -371,21 +371,21 @@ int Scene::getBGInfo(SCENE_BGINFO *bginfo) { bginfo->bg_x = x; bginfo->bg_y = y; - return R_SUCCESS; + return SUCCESS; } int Scene::getBGPal(PALENTRY **pal) { assert(_initialized); *pal = _bg.pal; - return R_SUCCESS; + return SUCCESS; } int Scene::getBGMaskInfo(int *w, int *h, byte **buf, size_t *buf_len) { assert(_initialized); if (!_bgMask.loaded) { - return R_FAILURE; + return FAILURE; } *w = _bgMask.w; @@ -393,7 +393,7 @@ int Scene::getBGMaskInfo(int *w, int *h, byte **buf, size_t *buf_len) { *buf = _bgMask.buf; *buf_len = _bgMask.buf_len; - return R_SUCCESS; + return SUCCESS; } int Scene::isBGMaskPresent() { @@ -402,17 +402,17 @@ int Scene::isBGMaskPresent() { return _bgMask.loaded; } -int Scene::getInfo(R_SCENE_INFO *si) { +int Scene::getInfo(SCENE_INFO *si) { assert(_initialized); assert(si != NULL); si->text_list = _textList; - return R_SUCCESS; + return SUCCESS; } -int Scene::loadScene(int scene_num, int load_flag, R_SCENE_PROC scene_proc, R_SCENE_DESC *scene_desc_param, int fadeType) { - R_SCENE_INFO scene_info; +int Scene::loadScene(int scene_num, int load_flag, SCENE_PROC scene_proc, SCENE_DESC *scene_desc_param, int fadeType) { + SCENE_INFO scene_info; uint32 res_number = 0; int result; int i; @@ -421,7 +421,7 @@ int Scene::loadScene(int scene_num, int load_flag, R_SCENE_PROC scene_proc, R_SC if (_sceneLoaded) { warning("Scene::loadScene(): Error, a scene is already loaded"); - return R_FAILURE; + return FAILURE; } _animList = ys_dll_create(); @@ -447,7 +447,7 @@ int Scene::loadScene(int scene_num, int load_flag, R_SCENE_PROC scene_proc, R_SC break; default: warning("Scene::loadScene(): Error: Invalid scene load flag"); - return R_FAILURE; + return FAILURE; break; } @@ -458,14 +458,14 @@ int Scene::loadScene(int scene_num, int load_flag, R_SCENE_PROC scene_proc, R_SC assert(_sceneResNum != 0); debug(0, "Loading scene resource %u:", res_number); - if (loadSceneDescriptor(res_number) != R_SUCCESS) { + if (loadSceneDescriptor(res_number) != SUCCESS) { warning("Scene::loadScene(): Error reading scene descriptor"); - return R_FAILURE; + return FAILURE; } - if (loadSceneResourceList(_desc.resListRN) != R_SUCCESS) { + if (loadSceneResourceList(_desc.resListRN) != SUCCESS) { warning("Scene::loadScene(): Error reading scene resource list"); - return R_FAILURE; + return FAILURE; } } else { debug(0, "Loading memory scene resource."); @@ -475,37 +475,37 @@ int Scene::loadScene(int scene_num, int load_flag, R_SCENE_PROC scene_proc, R_SC for (i = 0; i < _resListEntries; i++) { result = RSC_LoadResource(_sceneContext, _resList[i].res_number, &_resList[i].res_data, &_resList[i].res_data_len); - if (result != R_SUCCESS) { + if (result != SUCCESS) { warning("Scene::loadScene(): Error: Allocation failure loading scene resource list"); - return R_FAILURE; + return FAILURE; } } // Process resources from scene resource list - if (processSceneResources() != R_SUCCESS) { + if (processSceneResources() != SUCCESS) { warning("Scene::loadScene(): Error loading scene resources"); - return R_FAILURE; + return FAILURE; } // Load scene script data if (_desc.scriptNum > 0) { - if (_vm->_script->loadScript(_desc.scriptNum) != R_SUCCESS) { + if (_vm->_script->loadScript(_desc.scriptNum) != SUCCESS) { warning("Scene::loadScene(): Error loading scene script"); - return R_FAILURE; + return FAILURE; } } _sceneLoaded = true; if (fadeType == SCENE_FADE || fadeType == SCENE_FADE_NO_INTERFACE) { - R_EVENT event; - R_EVENT *q_event; - static PALENTRY current_pal[R_PAL_ENTRIES]; + EVENT event; + EVENT *q_event; + static PALENTRY current_pal[PAL_ENTRIES]; // Fade to black out _vm->_gfx->getCurrentPal(current_pal); - event.type = R_IMMEDIATE_EVENT; - event.code = R_PAL_EVENT; + event.type = IMMEDIATE_EVENT; + event.code = PAL_EVENT; event.op = EVENT_PALTOBLACK; event.time = 0; event.duration = PALETTE_FADE_DURATION; @@ -514,8 +514,8 @@ int Scene::loadScene(int scene_num, int load_flag, R_SCENE_PROC scene_proc, R_SC if (fadeType != SCENE_FADE_NO_INTERFACE) { // Activate user interface - event.type = R_IMMEDIATE_EVENT; - event.code = R_INTERFACE_EVENT; + event.type = IMMEDIATE_EVENT; + event.code = INTERFACE_EVENT; event.op = EVENT_ACTIVATE; event.time = 0; event.duration = 0; @@ -523,8 +523,8 @@ int Scene::loadScene(int scene_num, int load_flag, R_SCENE_PROC scene_proc, R_SC } // Display scene background, but stay with black palette - event.type = R_IMMEDIATE_EVENT; - event.code = R_BG_EVENT; + event.type = IMMEDIATE_EVENT; + event.code = BG_EVENT; event.op = EVENT_DISPLAY; event.param = NO_SET_PALETTE; event.time = 0; @@ -533,8 +533,8 @@ int Scene::loadScene(int scene_num, int load_flag, R_SCENE_PROC scene_proc, R_SC // Start the scene pre script, but stay with black palette if (_desc.startScriptNum > 0) { - event.type = R_ONESHOT_EVENT; - event.code = R_SCRIPT_EVENT; + event.type = ONESHOT_EVENT; + event.code = SCRIPT_EVENT; event.op = EVENT_BLOCKING; event.time = 0; event.param = _desc.startScriptNum; @@ -547,8 +547,8 @@ int Scene::loadScene(int scene_num, int load_flag, R_SCENE_PROC scene_proc, R_SC } // Fade in from black to the scene background palette - event.type = R_IMMEDIATE_EVENT; - event.code = R_PAL_EVENT; + event.type = IMMEDIATE_EVENT; + event.code = PAL_EVENT; event.op = EVENT_BLACKTOPAL; event.time = 0; event.duration = PALETTE_FADE_DURATION; @@ -567,7 +567,7 @@ int Scene::loadScene(int scene_num, int load_flag, R_SCENE_PROC scene_proc, R_SC _sceneProc(SCENE_BEGIN, &scene_info, this); - return R_SUCCESS; + return SUCCESS; } int Scene::loadSceneDescriptor(uint32 res_number) { @@ -576,14 +576,14 @@ int Scene::loadSceneDescriptor(uint32 res_number) { int result; result = RSC_LoadResource(_sceneContext, res_number, &scene_desc_data, &scene_desc_len); - if (result != R_SUCCESS) { + if (result != SUCCESS) { warning("Scene::loadSceneDescriptor(): Error: couldn't load scene descriptor"); - return R_FAILURE; + return FAILURE; } if (scene_desc_len != SAGA_SCENE_DESC_LEN) { warning("Scene::loadSceneDescriptor(): Error: scene descriptor length invalid"); - return R_FAILURE; + return FAILURE; } MemoryReadStream readS(scene_desc_data, scene_desc_len); @@ -599,7 +599,7 @@ int Scene::loadSceneDescriptor(uint32 res_number) { RSC_FreeResource(scene_desc_data); - return R_SUCCESS; + return SUCCESS; } int Scene::loadSceneResourceList(uint32 reslist_rn) { @@ -610,9 +610,9 @@ int Scene::loadSceneResourceList(uint32 reslist_rn) { // Load the scene resource table result = RSC_LoadResource(_sceneContext, reslist_rn, &resource_list, &resource_list_len); - if (result != R_SUCCESS) { + if (result != SUCCESS) { warning("Scene::loadSceneResourceList(): Error: couldn't load scene resource list"); - return R_FAILURE; + return FAILURE; } MemoryReadStream readS(resource_list, resource_list_len); @@ -620,11 +620,11 @@ int Scene::loadSceneResourceList(uint32 reslist_rn) { // Allocate memory for scene resource list _resListEntries = resource_list_len / SAGA_RESLIST_ENTRY_LEN; debug(0, "Scene resource list contains %d entries.", _resListEntries); - _resList = (R_SCENE_RESLIST *)calloc(_resListEntries, sizeof *_resList); + _resList = (SCENE_RESLIST *)calloc(_resListEntries, sizeof *_resList); if (_resList == NULL) { warning("Scene::loadSceneResourceList(): Error: Memory allocation failed"); - return R_MEM; + return MEM; } // Load scene resource list from raw scene @@ -638,7 +638,7 @@ int Scene::loadSceneResourceList(uint32 reslist_rn) { RSC_FreeResource(resource_list); - return R_SUCCESS; + return SUCCESS; } int Scene::processSceneResources() { @@ -657,7 +657,7 @@ int Scene::processSceneResources() { case SAGA_BG_IMAGE: // Scene background resource if (_bg.loaded) { warning("Scene::processSceneResources(): Multiple background resources encountered"); - return R_FAILURE; + return FAILURE; } debug(0, "Loading background resource."); @@ -670,14 +670,14 @@ int Scene::processSceneResources() { &_bg.buf, &_bg.buf_len, &_bg.w, - &_bg.h) != R_SUCCESS) { + &_bg.h) != SUCCESS) { warning("Scene::ProcessSceneResources(): Error loading background resource: %u", _resList[i].res_number); - return R_FAILURE; + return FAILURE; } pal_p = _vm->getImagePal(_bg.res_buf, _bg.res_len); memcpy(_bg.pal, pal_p, sizeof _bg.pal); - _sceneMode = R_SCENE_MODE_NORMAL; + _sceneMode = SCENE_MODE_NORMAL; break; case SAGA_BG_MASK: // Scene background mask resource if (_bgMask.loaded) { @@ -697,9 +697,9 @@ int Scene::processSceneResources() { case SAGA_OBJECT_MAP: debug(0, "Loading object map resource..."); if (_objectMap->load(res_data, - res_data_len) != R_SUCCESS) { + res_data_len) != SUCCESS) { warning("Scene::ProcessSceneResources(): Error loading object map resource"); - return R_FAILURE; + return FAILURE; } break; case SAGA_ACTION_MAP: @@ -707,49 +707,49 @@ int Scene::processSceneResources() { _actionMap = new ActionMap(_vm, res_data, res_data_len); break; case SAGA_ISO_TILESET: - if (_sceneMode == R_SCENE_MODE_NORMAL) { + if (_sceneMode == SCENE_MODE_NORMAL) { warning("Scene::ProcessSceneResources(): Isometric tileset incompatible with normal scene mode"); - return R_FAILURE; + return FAILURE; } debug(0, "Loading isometric tileset resource."); - if (_vm->_isoMap->loadTileset(res_data, res_data_len) != R_SUCCESS) { + if (_vm->_isoMap->loadTileset(res_data, res_data_len) != SUCCESS) { warning("Scene::ProcessSceneResources(): Error loading isometric tileset resource"); - return R_FAILURE; + return FAILURE; } - _sceneMode = R_SCENE_MODE_ISO; + _sceneMode = SCENE_MODE_ISO; break; case SAGA_ISO_METAMAP: - if (_sceneMode == R_SCENE_MODE_NORMAL) { + if (_sceneMode == SCENE_MODE_NORMAL) { warning("Scene::ProcessSceneResources(): Isometric metamap incompatible with normal scene mode"); - return R_FAILURE; + return FAILURE; } debug(0, "Loading isometric metamap resource."); - if (_vm->_isoMap->loadMetamap(res_data, res_data_len) != R_SUCCESS) { + if (_vm->_isoMap->loadMetamap(res_data, res_data_len) != SUCCESS) { warning("Scene::ProcessSceneResources(): Error loading isometric metamap resource"); - return R_FAILURE; + return FAILURE; } - _sceneMode = R_SCENE_MODE_ISO; + _sceneMode = SCENE_MODE_ISO; break; case SAGA_ISO_METATILESET: - if (_sceneMode == R_SCENE_MODE_NORMAL) { + if (_sceneMode == SCENE_MODE_NORMAL) { warning("Scene::ProcessSceneResources(): Isometric metatileset incompatible with normal scene mode"); - return R_FAILURE; + return FAILURE; } debug(0, "Loading isometric metatileset resource."); - if (_vm->_isoMap->loadMetaTileset(res_data, res_data_len) != R_SUCCESS) { + if (_vm->_isoMap->loadMetaTileset(res_data, res_data_len) != SUCCESS) { warning("Scene::ProcessSceneResources(): Error loading isometric tileset resource"); - return R_FAILURE; + return FAILURE; } - _sceneMode = R_SCENE_MODE_ISO; + _sceneMode = SCENE_MODE_ISO; break; case SAGA_ANIM_1: case SAGA_ANIM_2: @@ -767,13 +767,13 @@ int Scene::processSceneResources() { new_animinfo = (SCENE_ANIMINFO *)malloc(sizeof *new_animinfo); if (new_animinfo == NULL) { warning("Scene::ProcessSceneResources(): Memory allocation error"); - return R_MEM; + return MEM; } if (_vm->_anim->load(_resList[i].res_data, - _resList[i].res_data_len, &new_anim_id) != R_SUCCESS) { + _resList[i].res_data_len, &new_anim_id) != SUCCESS) { warning("Scene::ProcessSceneResources(): Error loading animation resource"); - return R_FAILURE; + return FAILURE; } new_animinfo->anim_handle = new_anim_id; @@ -797,12 +797,12 @@ int Scene::processSceneResources() { break; } } - return R_SUCCESS; + return SUCCESS; } -int Scene::draw(R_SURFACE *dst_s) { - R_GAME_DISPLAYINFO disp_info; - R_BUFFER_INFO buf_info; +int Scene::draw(SURFACE *dst_s) { + GAME_DISPLAYINFO disp_info; + BUFFER_INFO buf_info; Point bg_pt; assert(_initialized); @@ -815,24 +815,24 @@ int Scene::draw(R_SURFACE *dst_s) { switch (_sceneMode) { - case R_SCENE_MODE_NORMAL: - _vm->_gfx->bufToSurface(dst_s, buf_info.r_bg_buf, disp_info.logical_w, + case SCENE_MODE_NORMAL: + _vm->_gfx->bufToSurface(dst_s, buf_info.bg_buf, disp_info.logical_w, MAX(disp_info.scene_h, _bg.h), NULL, &bg_pt); break; - case R_SCENE_MODE_ISO: + case SCENE_MODE_ISO: _vm->_isoMap->draw(dst_s); break; default: // Unknown scene mode - return R_FAILURE; + return FAILURE; break; }; - return R_SUCCESS; + return SUCCESS; } int Scene::endScene() { - R_SCENE_INFO scene_info; + SCENE_INFO scene_info; assert(_initialized); @@ -888,7 +888,7 @@ int Scene::endScene() { _sceneLoaded = false; - return R_SUCCESS; + return SUCCESS; } void Scene::sceneChangeCmd(int argc, char *argv[]) { @@ -907,7 +907,7 @@ void Scene::sceneChangeCmd(int argc, char *argv[]) { clearSceneQueue(); - if (changeScene(scene_num) == R_SUCCESS) { + if (changeScene(scene_num) == SUCCESS) { _vm->_console->print("Scene changed."); } else { _vm->_console->print("Couldn't change scene!"); @@ -938,7 +938,7 @@ static void CF_sceneinfo(int argc, char *argv[], void *refCon) { ((Scene *)refCon)->sceneInfoCmd(argc, argv); } -int Scene::SC_defaultScene(int param, R_SCENE_INFO *scene_info, void *refCon) { +int Scene::SC_defaultScene(int param, SCENE_INFO *scene_info, void *refCon) { return ((Scene *)refCon)->defaultScene(param, scene_info); } @@ -957,25 +957,25 @@ static void CF_objectinfo(int argc, char *argv[], void *refCon) { } -int Scene::defaultScene(int param, R_SCENE_INFO *scene_info) { - R_EVENT event; +int Scene::defaultScene(int param, SCENE_INFO *scene_info) { + EVENT event; switch (param) { case SCENE_BEGIN: _vm->_sound->stopVoice(); if (_desc.musicRN >= 0) { - event.type = R_ONESHOT_EVENT; - event.code = R_MUSIC_EVENT; + event.type = ONESHOT_EVENT; + event.code = MUSIC_EVENT; event.param = _desc.musicRN; - event.param2 = R_MUSIC_DEFAULT; + event.param2 = MUSIC_DEFAULT; event.op = EVENT_PLAY; event.time = 0; _vm->_events->queue(&event); } else { - event.type = R_ONESHOT_EVENT; - event.code = R_MUSIC_EVENT; + event.type = ONESHOT_EVENT; + event.code = MUSIC_EVENT; event.op = EVENT_STOP; event.time = 0; @@ -983,8 +983,8 @@ int Scene::defaultScene(int param, R_SCENE_INFO *scene_info) { } // Set scene background - event.type = R_ONESHOT_EVENT; - event.code = R_BG_EVENT; + event.type = ONESHOT_EVENT; + event.code = BG_EVENT; event.op = EVENT_DISPLAY; event.param = SET_PALETTE; event.time = 0; @@ -992,16 +992,16 @@ int Scene::defaultScene(int param, R_SCENE_INFO *scene_info) { _vm->_events->queue(&event); // Activate user interface - event.type = R_ONESHOT_EVENT; - event.code = R_INTERFACE_EVENT; + event.type = ONESHOT_EVENT; + event.code = INTERFACE_EVENT; event.op = EVENT_ACTIVATE; event.time = 0; _vm->_events->queue(&event); // Begin palette cycle animation if present - event.type = R_ONESHOT_EVENT; - event.code = R_PALANIM_EVENT; + event.type = ONESHOT_EVENT; + event.code = PALANIM_EVENT; event.op = EVENT_CYCLESTART; event.time = 0; @@ -1013,8 +1013,8 @@ int Scene::defaultScene(int param, R_SCENE_INFO *scene_info) { // Start the scene main script if (_desc.sceneScriptNum > 0) { - event.type = R_ONESHOT_EVENT; - event.code = R_SCRIPT_EVENT; + event.type = ONESHOT_EVENT; + event.code = SCRIPT_EVENT; event.op = EVENT_NONBLOCKING; event.time = 0; event.param = _desc.sceneScriptNum; diff --git a/saga/scene.h b/saga/scene.h index 0f7176b7d7..0e8a459a86 100644 --- a/saga/scene.h +++ b/saga/scene.h @@ -33,10 +33,10 @@ namespace Saga { class ActionMap; class ObjectMap; -enum R_SCENE_MODES { - R_SCENE_MODE_INVALID, - R_SCENE_MODE_NORMAL, - R_SCENE_MODE_ISO +enum SCENE_MODES { + SCENE_MODE_INVALID, + SCENE_MODE_NORMAL, + SCENE_MODE_ISO }; struct SCENE_ZINFO { @@ -54,13 +54,13 @@ struct SCENE_BGINFO { size_t bg_buflen; }; -struct R_SCENE_INFO { +struct SCENE_INFO { SCENE_ZINFO z_info; SCENE_BGINFO bg_info; - R_TEXTLIST *text_list; + TEXTLIST *text_list; }; -typedef int (R_SCENE_PROC) (int, R_SCENE_INFO *, void *); +typedef int (SCENE_PROC) (int, SCENE_INFO *, void *); #define PALETTE_FADE_DURATION 1000 @@ -99,7 +99,7 @@ enum SAGA_RESOURCE_TYPES { #define SAGA_RESLIST_ENTRY_LEN 4 -struct R_SCENE_RESLIST { +struct SCENE_RESLIST { uint32 res_number; int res_type; byte *res_data; @@ -108,7 +108,7 @@ struct R_SCENE_RESLIST { #define SAGA_SCENE_DESC_LEN 16 -struct R_SCENE_DESC { +struct SCENE_DESC { int16 flags; int16 resListRN; int16 endSlope; @@ -117,7 +117,7 @@ struct R_SCENE_DESC { uint16 sceneScriptNum; uint16 startScriptNum; int16 musicRN; - R_SCENE_RESLIST *resList; + SCENE_RESLIST *resList; size_t resListCnt; }; @@ -145,23 +145,23 @@ enum SCENE_FADE_TYPES { SCENE_FADE_NO_INTERFACE = 2 }; -struct R_SCENE_QUEUE { +struct SCENE_QUEUE { uint32 scene_n; - R_SCENE_DESC *scene_desc; + SCENE_DESC *scene_desc; int load_flag; - R_SCENE_PROC *scene_proc; + SCENE_PROC *scene_proc; int scene_skiptarget; int fadeType; }; ///// IHNM-specific stuff -#define R_IHNM_PALFADE_TIME 1000 -#define R_IHNM_INTRO_FRAMETIME 80 -#define R_IHNM_DGLOGO_TIME 8000 -#define R_IHNM_TITLE_TIME 16000 +#define IHNM_PALFADE_TIME 1000 +#define IHNM_INTRO_FRAMETIME 80 +#define IHNM_DGLOGO_TIME 8000 +#define IHNM_TITLE_TIME 16000 ///// ITE-specific stuff -#define R_INTRO_STRMAX 256 +#define INTRO_STRMAX 256 #define ITE_INTRO_FRAMETIME 90 @@ -175,7 +175,7 @@ struct R_SCENE_QUEUE { #define CREDIT_DURATION1 4000 -enum R_INTRO_SCENE_DIALOGUE_INFO { +enum INTRO_SCENE_DIALOGUE_INFO { INTRO_CAVE1_START = 0, INTRO_CAVE1_END = 4, @@ -189,10 +189,10 @@ enum R_INTRO_SCENE_DIALOGUE_INFO { INTRO_CAVE4_END = 14 }; -struct R_INTRO_DIALOGUE { +struct INTRO_DIALOGUE { uint32 i_voice_rn; const char *i_cvar_name; - char i_str[R_INTRO_STRMAX]; + char i_str[INTRO_STRMAX]; }; struct INTRO_CAPTION { @@ -220,15 +220,15 @@ class Scene { int nextScene(); int skipScene(); int endScene(); - int queueScene(R_SCENE_QUEUE *scene_queue); - int draw(R_SURFACE *); + int queueScene(SCENE_QUEUE *scene_queue); + int draw(SURFACE *); int getMode(); int getBGMaskInfo(int *w, int *h, byte **buf, size_t *buf_len); int isBGMaskPresent(void); int getBGInfo(SCENE_BGINFO *bginfo); int getZInfo(SCENE_ZINFO *zinfo); int getBGPal(PALENTRY **pal); - int getInfo(R_SCENE_INFO *si); + int getInfo(SCENE_INFO *si); int clearSceneQueue(void); int changeScene(int scene_num); @@ -239,7 +239,7 @@ class Scene { void sceneChangeCmd(int argc, char *argv[]); private: - int loadScene(int scene, int load_flag, R_SCENE_PROC scene_proc, R_SCENE_DESC *, + int loadScene(int scene, int load_flag, SCENE_PROC scene_proc, SCENE_DESC *, int fadeIn); int loadSceneDescriptor(uint32 res_number); int loadSceneResourceList(uint32 res_number); @@ -249,7 +249,7 @@ class Scene { SagaEngine *_vm; bool _initialized; - R_RSCFILE_CONTEXT *_sceneContext; + RSCFILE_CONTEXT *_sceneContext; int *_sceneLUT; int _sceneCount; int _sceneMax; @@ -261,18 +261,18 @@ class Scene { int _sceneResNum; bool _inGame; bool _loadDesc; - R_SCENE_DESC _desc; + SCENE_DESC _desc; int _resListEntries; - R_SCENE_RESLIST *_resList; + SCENE_RESLIST *_resList; int _animEntries; YS_DL_LIST *_animList; - R_SCENE_PROC *_sceneProc; - R_TEXTLIST *_textList; + SCENE_PROC *_sceneProc; + TEXTLIST *_textList; SCENE_IMAGE _bg; SCENE_IMAGE _bgMask; - static int SC_defaultScene(int param, R_SCENE_INFO *scene_info, void *refCon); - int defaultScene(int param, R_SCENE_INFO *scene_info); + static int SC_defaultScene(int param, SCENE_INFO *scene_info, void *refCon); + int defaultScene(int param, SCENE_INFO *scene_info); public: ActionMap *_actionMap; @@ -283,39 +283,39 @@ class Scene { int ITEStartProc(); public: - static int SC_IHNMIntroMovieProc1(int param, R_SCENE_INFO *scene_info, void *refCon); - static int SC_IHNMIntroMovieProc2(int param, R_SCENE_INFO *scene_info, void *refCon); - static int SC_IHNMIntroMovieProc3(int param, R_SCENE_INFO *scene_info, void *refCon); - static int SC_IHNMHateProc(int param, R_SCENE_INFO *scene_info, void *refCon); + static int SC_IHNMIntroMovieProc1(int param, SCENE_INFO *scene_info, void *refCon); + static int SC_IHNMIntroMovieProc2(int param, SCENE_INFO *scene_info, void *refCon); + static int SC_IHNMIntroMovieProc3(int param, SCENE_INFO *scene_info, void *refCon); + static int SC_IHNMHateProc(int param, SCENE_INFO *scene_info, void *refCon); private: - int IHNMIntroMovieProc1(int param, R_SCENE_INFO *scene_info); - int IHNMIntroMovieProc2(int param, R_SCENE_INFO *scene_info); - int IHNMIntroMovieProc3(int param, R_SCENE_INFO *scene_info); - int IHNMHateProc(int param, R_SCENE_INFO *scene_info); + int IHNMIntroMovieProc1(int param, SCENE_INFO *scene_info); + int IHNMIntroMovieProc2(int param, SCENE_INFO *scene_info); + int IHNMIntroMovieProc3(int param, SCENE_INFO *scene_info); + int IHNMHateProc(int param, SCENE_INFO *scene_info); public: int ITEIntroRegisterLang(void); - static int SC_ITEIntroAnimProc(int param, R_SCENE_INFO *scene_info, void *refCon); - static int SC_ITEIntroCave1Proc(int param, R_SCENE_INFO *scene_info, void *refCon); - static int SC_ITEIntroCave2Proc(int param, R_SCENE_INFO *scene_info, void *refCon); - static int SC_ITEIntroCave3Proc(int param, R_SCENE_INFO *scene_info, void *refCon); - static int SC_ITEIntroCave4Proc(int param, R_SCENE_INFO *scene_info, void *refCon); - static int SC_ITEIntroValleyProc(int param, R_SCENE_INFO *scene_info, void *refCon); - static int SC_ITEIntroTreeHouseProc(int param, R_SCENE_INFO *scene_info, void *refCon); - static int SC_ITEIntroFairePathProc(int param, R_SCENE_INFO *scene_info, void *refCon); - static int SC_ITEIntroFaireTentProc(int param, R_SCENE_INFO *scene_info, void *refCon); + static int SC_ITEIntroAnimProc(int param, SCENE_INFO *scene_info, void *refCon); + static int SC_ITEIntroCave1Proc(int param, SCENE_INFO *scene_info, void *refCon); + static int SC_ITEIntroCave2Proc(int param, SCENE_INFO *scene_info, void *refCon); + static int SC_ITEIntroCave3Proc(int param, SCENE_INFO *scene_info, void *refCon); + static int SC_ITEIntroCave4Proc(int param, SCENE_INFO *scene_info, void *refCon); + static int SC_ITEIntroValleyProc(int param, SCENE_INFO *scene_info, void *refCon); + static int SC_ITEIntroTreeHouseProc(int param, SCENE_INFO *scene_info, void *refCon); + static int SC_ITEIntroFairePathProc(int param, SCENE_INFO *scene_info, void *refCon); + static int SC_ITEIntroFaireTentProc(int param, SCENE_INFO *scene_info, void *refCon); private: - int ITEIntroAnimProc(int param, R_SCENE_INFO *scene_info); - int ITEIntroCave1Proc(int param, R_SCENE_INFO *scene_info); - int ITEIntroCave2Proc(int param, R_SCENE_INFO *scene_info); - int ITEIntroCave3Proc(int param, R_SCENE_INFO *scene_info); - int ITEIntroCave4Proc(int param, R_SCENE_INFO *scene_info); - int ITEIntroValleyProc(int param, R_SCENE_INFO *scene_info); - int ITEIntroTreeHouseProc(int param, R_SCENE_INFO *scene_info); - int ITEIntroFairePathProc(int param, R_SCENE_INFO *scene_info); - int ITEIntroFaireTentProc(int param, R_SCENE_INFO *scene_info); + int ITEIntroAnimProc(int param, SCENE_INFO *scene_info); + int ITEIntroCave1Proc(int param, SCENE_INFO *scene_info); + int ITEIntroCave2Proc(int param, SCENE_INFO *scene_info); + int ITEIntroCave3Proc(int param, SCENE_INFO *scene_info); + int ITEIntroCave4Proc(int param, SCENE_INFO *scene_info); + int ITEIntroValleyProc(int param, SCENE_INFO *scene_info); + int ITEIntroTreeHouseProc(int param, SCENE_INFO *scene_info); + int ITEIntroFairePathProc(int param, SCENE_INFO *scene_info); + int ITEIntroFaireTentProc(int param, SCENE_INFO *scene_info); }; diff --git a/saga/script.cpp b/saga/script.cpp index ca2d7805f0..50035fa5d8 100644 --- a/saga/script.cpp +++ b/saga/script.cpp @@ -40,17 +40,17 @@ static void CF_script_exec(int argc, char *argv[], void *refCon); static void CF_script_togglestep(int argc, char *argv[], void *refCon); int Script::reg() { - CVAR_RegisterFunc(CF_script_info, "script_info", NULL, R_CVAR_NONE, 0, 0, this); - CVAR_RegisterFunc(CF_script_exec, "script_exec", "<Script number>", R_CVAR_NONE, 1, 1, this); - CVAR_RegisterFunc(CF_script_togglestep, "script_togglestep", NULL, R_CVAR_NONE, 0, 0, this); + CVAR_RegisterFunc(CF_script_info, "script_info", NULL, CVAR_NONE, 0, 0, this); + CVAR_RegisterFunc(CF_script_exec, "script_exec", "<Script number>", CVAR_NONE, 1, 1, this); + CVAR_RegisterFunc(CF_script_togglestep, "script_togglestep", NULL, CVAR_NONE, 0, 0, this); - return R_SUCCESS; + return SUCCESS; } // Initializes the scripting module. // Loads script resource look-up table, initializes script data system Script::Script() { - R_RSCFILE_CONTEXT *s_lut_ctxt; + RSCFILE_CONTEXT *s_lut_ctxt; byte *rsc_ptr; size_t rsc_len; int prevTell; @@ -70,27 +70,27 @@ Script::Script() { debug(0, "Initializing scripting subsystem"); // Load script resource file context - result = GAME_GetFileContext(&_scriptContext, R_GAME_SCRIPTFILE, 0); - if (result != R_SUCCESS) { + result = GAME_GetFileContext(&_scriptContext, GAME_SCRIPTFILE, 0); + if (result != SUCCESS) { error("Couldn't get script file context"); } // Load script LUT resource - result = GAME_GetFileContext(&s_lut_ctxt, R_GAME_RESOURCEFILE, 0); - if (result != R_SUCCESS) { + result = GAME_GetFileContext(&s_lut_ctxt, GAME_RESOURCEFILE, 0); + if (result != SUCCESS) { error("Couldn't get resource file context"); } result = RSC_LoadResource(s_lut_ctxt, ITE_SCRIPT_LUT, &rsc_ptr, &rsc_len); - if (result != R_SUCCESS) { + if (result != SUCCESS) { error("Error: Couldn't load script resource look-up table"); } // Create logical script LUT from resource - if (rsc_len % R_S_LUT_ENTRYLEN_ITECD == 0) { - _scriptLUTEntryLen = R_S_LUT_ENTRYLEN_ITECD; - } else if (rsc_len % R_S_LUT_ENTRYLEN_ITEDISK == 0) { - _scriptLUTEntryLen = R_S_LUT_ENTRYLEN_ITEDISK; + if (rsc_len % S_LUT_ENTRYLEN_ITECD == 0) { + _scriptLUTEntryLen = S_LUT_ENTRYLEN_ITECD; + } else if (rsc_len % S_LUT_ENTRYLEN_ITEDISK == 0) { + _scriptLUTEntryLen = S_LUT_ENTRYLEN_ITEDISK; } else { error("Error: Invalid script lookup table length"); } @@ -99,7 +99,7 @@ Script::Script() { _scriptLUTMax = rsc_len / _scriptLUTEntryLen; // Allocate space for logical LUT - _scriptLUT = (R_SCRIPT_LUT_ENTRY *)malloc(_scriptLUTMax * sizeof(R_SCRIPT_LUT_ENTRY)); + _scriptLUT = (SCRIPT_LUT_ENTRY *)malloc(_scriptLUTMax * sizeof(SCRIPT_LUT_ENTRY)); if (_scriptLUT == NULL) { error("Error: Couldn't allocate memory for script resource look-up table"); } @@ -140,7 +140,7 @@ Script::Script() { // Shut down script module gracefully; free all allocated module resources Script::~Script() { YS_DL_NODE *thread_node; - R_SCRIPT_THREAD *thread; + SCRIPT_THREAD *thread; if (!_initialized) { error("Script not initialized"); @@ -155,7 +155,7 @@ Script::~Script() { for (thread_node = ys_dll_head(_threadList); thread_node != NULL; thread_node = ys_dll_next(thread_node)) { - thread = (R_SCRIPT_THREAD *)ys_dll_get_data(thread_node); + thread = (SCRIPT_THREAD *)ys_dll_get_data(thread_node); SThreadDestroy(thread); } @@ -164,7 +164,7 @@ Script::~Script() { // Loads a script; including script bytecode and dialogue list int Script::loadScript(int script_num) { - R_SCRIPTDATA *script_data; + SCRIPTDATA *script_data; byte *bytecode_p; size_t bytecode_len; uint32 scriptl_rn; @@ -177,13 +177,13 @@ int Script::loadScript(int script_num) { int result; if (GAME_GetGameType() == GID_IHNM) { - return R_SUCCESS; + return SUCCESS; } // Validate script number if ((script_num < 0) || (script_num > _scriptLUTMax)) { warning("Script::loadScript(): Invalid script number"); - return R_FAILURE; + return FAILURE; } // Release old script data if present @@ -192,10 +192,10 @@ int Script::loadScript(int script_num) { // Initialize script data structure debug(0, "Loading script data for script #%d", script_num); - script_data = (R_SCRIPTDATA *)malloc(sizeof *script_data); + script_data = (SCRIPTDATA *)malloc(sizeof *script_data); if (script_data == NULL) { warning("Memory allocation failed"); - return R_MEM; + return MEM; } script_data->loaded = 0; @@ -209,10 +209,10 @@ int Script::loadScript(int script_num) { scriptl_rn = _scriptLUT[script_num].script_rn; result = RSC_LoadResource(_scriptContext, scriptl_rn, &bytecode_p, &bytecode_len); - if (result != R_SUCCESS) { + if (result != SUCCESS) { warning("Error loading script bytecode resource"); free(script_data); - return R_FAILURE; + return FAILURE; } script_data->bytecode = loadBytecode(bytecode_p, bytecode_len); @@ -221,7 +221,7 @@ int Script::loadScript(int script_num) { warning("Error interpreting script bytecode resource"); free(script_data); RSC_FreeResource(bytecode_p); - return R_FAILURE; + return FAILURE; } // Load script dialogue list @@ -229,11 +229,11 @@ int Script::loadScript(int script_num) { // Load dialogue list resource result = RSC_LoadResource(_scriptContext, diagl_rn, &diagl_p, &diagl_len); - if (result != R_SUCCESS) { + if (result != SUCCESS) { warning("Error loading dialogue list resource"); free(script_data); RSC_FreeResource(bytecode_p); - return R_FAILURE; + return FAILURE; } // Convert dialogue list resource to logical dialogue list @@ -243,7 +243,7 @@ int Script::loadScript(int script_num) { free(script_data); RSC_FreeResource(bytecode_p); RSC_FreeResource(diagl_p); - return R_FAILURE; + return FAILURE; } // Load voice resource lookup table @@ -252,12 +252,12 @@ int Script::loadScript(int script_num) { // Load voice LUT resource result = RSC_LoadResource(_scriptContext, voicelut_rn, &voicelut_p, &voicelut_len); - if (result != R_SUCCESS) { + if (result != SUCCESS) { warning("Error loading voice LUT resource"); free(script_data); RSC_FreeResource(bytecode_p); RSC_FreeResource(diagl_p); - return R_FAILURE; + return FAILURE; } // Convert voice LUT resource to logical voice LUT @@ -268,7 +268,7 @@ int Script::loadScript(int script_num) { RSC_FreeResource(bytecode_p); RSC_FreeResource(diagl_p); RSC_FreeResource(voicelut_p); - return R_FAILURE; + return FAILURE; } } @@ -276,17 +276,17 @@ int Script::loadScript(int script_num) { script_data->loaded = 1; _currentScript = script_data; - return R_SUCCESS; + return SUCCESS; } // Frees all resources associated with current script. int Script::freeScript() { if (_currentScript == NULL) { - return R_FAILURE; + return FAILURE; } if (!_currentScript->loaded) { - return R_FAILURE; + return FAILURE; } debug(0, "Releasing script data."); @@ -314,14 +314,14 @@ int Script::freeScript() { _currentScript = NULL; - return R_SUCCESS; + return SUCCESS; } // Reads the entrypoint table from a script bytecode resource in memory. // Returns NULL on failure. -R_SCRIPT_BYTECODE *Script::loadBytecode(byte *bytecode_p, size_t bytecode_len) { - R_PROC_TBLENTRY *bc_ep_tbl = NULL; - R_SCRIPT_BYTECODE *bc_new_data = NULL; +SCRIPT_BYTECODE *Script::loadBytecode(byte *bytecode_p, size_t bytecode_len) { + PROC_TBLENTRY *bc_ep_tbl = NULL; + SCRIPT_BYTECODE *bc_new_data = NULL; unsigned long n_entrypoints; // Number of entrypoints size_t ep_tbl_offset; // Offset of bytecode entrypoint table @@ -337,12 +337,12 @@ R_SCRIPT_BYTECODE *Script::loadBytecode(byte *bytecode_p, size_t bytecode_len) { ep_tbl_offset = scriptS.readUint32LE(); // Check that the entrypoint table offset is valid. - if ((bytecode_len - ep_tbl_offset) < (n_entrypoints * R_SCRIPT_TBLENTRY_LEN)) { + if ((bytecode_len - ep_tbl_offset) < (n_entrypoints * SCRIPT_TBLENTRY_LEN)) { warning("Invalid table offset"); return NULL; } - if (n_entrypoints > R_SCRIPT_MAX) { + if (n_entrypoints > SCRIPT_MAX) { warning("Script limit exceeded"); return NULL; } @@ -350,13 +350,13 @@ R_SCRIPT_BYTECODE *Script::loadBytecode(byte *bytecode_p, size_t bytecode_len) { // Allocate a new bytecode resource information structure and table of // entrypoints - bc_new_data = (R_SCRIPT_BYTECODE *)malloc(sizeof *bc_new_data); + bc_new_data = (SCRIPT_BYTECODE *)malloc(sizeof *bc_new_data); if (bc_new_data == NULL) { warning("Memory allocation failure loading script bytecode"); return NULL; } - bc_ep_tbl = (R_PROC_TBLENTRY *)malloc(n_entrypoints * sizeof *bc_ep_tbl); + bc_ep_tbl = (PROC_TBLENTRY *)malloc(n_entrypoints * sizeof *bc_ep_tbl); if (bc_ep_tbl == NULL) { warning("Memory allocation failure creating script entrypoint table"); free(bc_new_data); @@ -396,8 +396,8 @@ R_SCRIPT_BYTECODE *Script::loadBytecode(byte *bytecode_p, size_t bytecode_len) { // Reads a logical dialogue list from a dialogue list resource in memory. // Returns NULL on failure. -R_DIALOGUE_LIST *Script::loadDialogue(const byte *dialogue_p, size_t dialogue_len) { - R_DIALOGUE_LIST *dialogue_list; +DIALOGUE_LIST *Script::loadDialogue(const byte *dialogue_p, size_t dialogue_len) { + DIALOGUE_LIST *dialogue_list; uint16 n_dialogue; uint16 i; size_t offset; @@ -405,7 +405,7 @@ R_DIALOGUE_LIST *Script::loadDialogue(const byte *dialogue_p, size_t dialogue_le debug(0, "Loading dialogue list..."); // Allocate dialogue list structure - dialogue_list = (R_DIALOGUE_LIST *)malloc(sizeof *dialogue_list); + dialogue_list = (DIALOGUE_LIST *)malloc(sizeof *dialogue_list); if (dialogue_list == NULL) { return NULL; } @@ -458,13 +458,13 @@ R_DIALOGUE_LIST *Script::loadDialogue(const byte *dialogue_p, size_t dialogue_le // Reads a logical voice LUT from a voice LUT resource in memory. // Returns NULL on failure. -R_VOICE_LUT *Script::loadVoiceLUT(const byte *voicelut_p, size_t voicelut_len, R_SCRIPTDATA *script) { - R_VOICE_LUT *voice_lut; +VOICE_LUT *Script::loadVoiceLUT(const byte *voicelut_p, size_t voicelut_len, SCRIPTDATA *script) { + VOICE_LUT *voice_lut; uint16 n_voices; uint16 i; - voice_lut = (R_VOICE_LUT *)malloc(sizeof *voice_lut); + voice_lut = (VOICE_LUT *)malloc(sizeof *voice_lut); if (voice_lut == NULL) { return NULL; } diff --git a/saga/script.h b/saga/script.h index 04af017413..71ebcefc4c 100644 --- a/saga/script.h +++ b/saga/script.h @@ -31,27 +31,27 @@ namespace Saga { -#define R_SCRIPT_DATABUF_NUM 5 -#define R_SCRIPT_DATABUF_LEN 1024 +#define SCRIPT_DATABUF_NUM 5 +#define SCRIPT_DATABUF_LEN 1024 -#define R_S_LUT_ENTRYLEN_ITECD 22 -#define R_S_LUT_ENTRYLEN_ITEDISK 16 +#define S_LUT_ENTRYLEN_ITECD 22 +#define S_LUT_ENTRYLEN_ITEDISK 16 -#define R_SCRIPT_TBLENTRY_LEN 4 +#define SCRIPT_TBLENTRY_LEN 4 -#define R_SCRIPT_MAX 5000 -#define R_SCRIPTLIST_HDR 12 -#define R_SCRIPT_STRINGLIMIT 255 -#define R_TAB " " +#define SCRIPT_MAX 5000 +#define SCRIPTLIST_HDR 12 +#define SCRIPT_STRINGLIMIT 255 +#define TAB " " #define S_ERROR_PREFIX "SError: " #define S_WARN_PREFIX "SWarning: " -#define R_SFUNC_NUM 78 +#define SFUNC_NUM 78 typedef unsigned int SDataWord_T; -enum R_SCRIPT_VERBS { +enum SCRIPT_VERBS { S_VERB_WALKTO = 0, S_VERB_LOOKAT = 2, S_VERB_PICKUP = 1, @@ -64,7 +64,7 @@ enum R_SCRIPT_VERBS { #define STHREAD_TIMESLICE 8 -struct R_SEMAPHORE { +struct SEMAPHORE { int hold_count; }; @@ -94,7 +94,7 @@ enum { kTWaitPause }; -struct R_SCRIPT_THREAD { +struct SCRIPT_THREAD { int flags; int waitType; @@ -103,7 +103,7 @@ struct R_SCRIPT_THREAD { unsigned long ep_offset; // Entrypoint offset unsigned long i_offset; // Instruction offset - R_SEMAPHORE sem; // FIXME: no equivalent. should be replaced with flags + SEMAPHORE sem; // FIXME: no equivalent. should be replaced with flags // The scripts are allowed to access the stack like any other memory // area. It's therefore probably quite important that our stacks work @@ -137,49 +137,49 @@ struct R_SCRIPT_THREAD { } }; -struct R_PROC_TBLENTRY { +struct PROC_TBLENTRY { size_t name_offset; size_t offset; }; -struct R_SCRIPT_BYTECODE { +struct SCRIPT_BYTECODE { unsigned char *bytecode_p; size_t bytecode_len; size_t ep_tbl_offset; unsigned long n_entrypoints; - R_PROC_TBLENTRY *entrypoints; + PROC_TBLENTRY *entrypoints; }; -struct R_DIALOGUE_LIST { +struct DIALOGUE_LIST { unsigned int n_dialogue; const char **str; size_t *str_off; }; -struct R_VOICE_LUT { +struct VOICE_LUT { int n_voices; int *voices; }; -struct R_SCRIPTDATA { +struct SCRIPTDATA { int loaded; - R_SCRIPT_BYTECODE *bytecode; - R_DIALOGUE_LIST *diag; - R_VOICE_LUT *voice; + SCRIPT_BYTECODE *bytecode; + DIALOGUE_LIST *diag; + VOICE_LUT *voice; }; -struct R_SCRIPT_LUT_ENTRY { +struct SCRIPT_LUT_ENTRY { int script_rn; int diag_list_rn; int voice_lut_rn; }; -struct R_SCRIPT_DATABUF { +struct SCRIPT_DATABUF { SDataWord_T *data; int len; }; -#define R_SCRIPTFUNC_PARAMS R_SCRIPT_THREAD *thread +#define SCRIPTFUNC_PARAMS SCRIPT_THREAD *thread class Script { public: @@ -189,16 +189,16 @@ public: int reg(void); int loadScript(int scriptNum); int freeScript(); - R_SCRIPT_BYTECODE *loadBytecode(byte *bytecode_p, size_t bytecode_len); - R_DIALOGUE_LIST *loadDialogue(const byte *dialogue_p, size_t dialogue_len); - R_VOICE_LUT *loadVoiceLUT(const byte *voicelut_p, size_t voicelut_len, R_SCRIPTDATA *script); - int disassemble(R_SCRIPT_BYTECODE *script_list, R_DIALOGUE_LIST *diag_list); + SCRIPT_BYTECODE *loadBytecode(byte *bytecode_p, size_t bytecode_len); + DIALOGUE_LIST *loadDialogue(const byte *dialogue_p, size_t dialogue_len); + VOICE_LUT *loadVoiceLUT(const byte *voicelut_p, size_t voicelut_len, SCRIPTDATA *script); + int disassemble(SCRIPT_BYTECODE *script_list, DIALOGUE_LIST *diag_list); bool isInitialized() const { return _initialized; } bool isVoiceLUTPresent() const { return _voiceLUTPresent; } - R_SCRIPTDATA *currentScript() { return _currentScript; } - void setBuffer(int idx, R_SCRIPT_DATABUF *ptr) { _dataBuf[idx] = ptr; } - R_SCRIPT_DATABUF *dataBuffer(int idx) { return _dataBuf[idx]; } + SCRIPTDATA *currentScript() { return _currentScript; } + void setBuffer(int idx, SCRIPT_DATABUF *ptr) { _dataBuf[idx] = ptr; } + SCRIPT_DATABUF *dataBuffer(int idx) { return _dataBuf[idx]; } YS_DL_LIST *threadList() { return _threadList; } void scriptInfo(int argc, char *argv[]); @@ -207,12 +207,12 @@ public: protected: bool _initialized; bool _voiceLUTPresent; - R_RSCFILE_CONTEXT *_scriptContext; - R_SCRIPT_LUT_ENTRY *_scriptLUT; + RSCFILE_CONTEXT *_scriptContext; + SCRIPT_LUT_ENTRY *_scriptLUT; int _scriptLUTMax; uint16 _scriptLUTEntryLen; - R_SCRIPTDATA *_currentScript; - R_SCRIPT_DATABUF *_dataBuf[R_SCRIPT_DATABUF_NUM]; + SCRIPTDATA *_currentScript; + SCRIPT_DATABUF *_dataBuf[SCRIPT_DATABUF_NUM]; YS_DL_LIST *_threadList; bool _skipSpeeches; @@ -221,86 +221,86 @@ protected: public: int _dbg_singlestep; int _dbg_dostep; - R_SCRIPT_THREAD *_dbg_thread; - R_TEXTLIST_ENTRY *_dbg_txtentry; + SCRIPT_THREAD *_dbg_thread; + TEXTLIST_ENTRY *_dbg_txtentry; public: - R_SCRIPT_THREAD *SThreadCreate(); - int SThreadExecute(R_SCRIPT_THREAD *thread, int ep_num); + SCRIPT_THREAD *SThreadCreate(); + int SThreadExecute(SCRIPT_THREAD *thread, int ep_num); int SThreadExecThreads(uint msec); - int SThreadHoldSem(R_SEMAPHORE *sem); - int SThreadReleaseSem(R_SEMAPHORE *sem); + int SThreadHoldSem(SEMAPHORE *sem); + int SThreadReleaseSem(SEMAPHORE *sem); int SThreadDebugStep(); void SThreadCompleteThread(void); - int SThreadDestroy(R_SCRIPT_THREAD *thread); + int SThreadDestroy(SCRIPT_THREAD *thread); void SThreadAbortAll(void); private: - void setFramePtr(R_SCRIPT_THREAD *thread, int newPtr); - unsigned char *SThreadGetReadPtr(R_SCRIPT_THREAD *thread); + void setFramePtr(SCRIPT_THREAD *thread, int newPtr); + unsigned char *SThreadGetReadPtr(SCRIPT_THREAD *thread); unsigned long SThreadGetReadOffset(const byte *read_p); - size_t SThreadGetReadLen(R_SCRIPT_THREAD *thread); - int SThreadRun(R_SCRIPT_THREAD *thread, int instr_limit); - int SThreadSetEntrypoint(R_SCRIPT_THREAD *thread, int ep_num); + size_t SThreadGetReadLen(SCRIPT_THREAD *thread); + int SThreadRun(SCRIPT_THREAD *thread, int instr_limit); + int SThreadSetEntrypoint(SCRIPT_THREAD *thread, int ep_num); private: - typedef int (Script::*SFunc_T)(R_SCRIPTFUNC_PARAMS); + typedef int (Script::*SFunc_T)(SCRIPTFUNC_PARAMS); - struct R_SFUNC_ENTRY { + struct SFUNC_ENTRY { int sfunc_num; int sfunc_argc; SFunc_T sfunc_fp; }; - const R_SFUNC_ENTRY *_SFuncList; + const SFUNC_ENTRY *_SFuncList; void setupScriptFuncList(void); - int SDebugPrintInstr(R_SCRIPT_THREAD *thread); - - int SF_sleep(R_SCRIPTFUNC_PARAMS); - int SF_takeObject(R_SCRIPTFUNC_PARAMS); - int SF_objectIsCarried(R_SCRIPTFUNC_PARAMS); - int SF_setStatusText(R_SCRIPTFUNC_PARAMS); - int SF_commandMode(R_SCRIPTFUNC_PARAMS); - int SF_actorWalkTo(R_SCRIPTFUNC_PARAMS); - int SF_setFacing(R_SCRIPTFUNC_PARAMS); - int SF_startBgdAnim(R_SCRIPTFUNC_PARAMS); - int SF_freezeInterface(R_SCRIPTFUNC_PARAMS); - int SF_dialogMode(R_SCRIPTFUNC_PARAMS); - int SF_startAnim(R_SCRIPTFUNC_PARAMS); - int SF_stopBgdAnim(R_SCRIPTFUNC_PARAMS); - int SF_actorWalkToAsync(R_SCRIPTFUNC_PARAMS); - int SF_moveTo(R_SCRIPTFUNC_PARAMS); - int SF_actorWalk(R_SCRIPTFUNC_PARAMS); - int SF_cycleActorFrames(R_SCRIPTFUNC_PARAMS); - int SF_setFrame(R_SCRIPTFUNC_PARAMS); - int SF_setRightPortrait(R_SCRIPTFUNC_PARAMS); - int SF_setLeftPortrait(R_SCRIPTFUNC_PARAMS); - int SF_linkAnim(R_SCRIPTFUNC_PARAMS); - int SF_placeActor(R_SCRIPTFUNC_PARAMS); - int SF_checkUserInterrupt(R_SCRIPTFUNC_PARAMS); - int SF_moveRelative(R_SCRIPTFUNC_PARAMS); - int SF_doAction(R_SCRIPTFUNC_PARAMS); - int SF_faceTowards(R_SCRIPTFUNC_PARAMS); - int SF_setFollower(R_SCRIPTFUNC_PARAMS); - int SF_setBgdAnimSpeed(R_SCRIPTFUNC_PARAMS); - int SF_centerActor(R_SCRIPTFUNC_PARAMS); - int SF_setActorState(R_SCRIPTFUNC_PARAMS); - int SF_finishBgdAnim(R_SCRIPTFUNC_PARAMS); - int SF_swapActors(R_SCRIPTFUNC_PARAMS); - int SF_scriptSpecialWalk(R_SCRIPTFUNC_PARAMS); - int SF_walkRelative(R_SCRIPTFUNC_PARAMS); - int SF_throwActor(R_SCRIPTFUNC_PARAMS); - int SF_waitWalk(R_SCRIPTFUNC_PARAMS); - int SF_changeActorScene(R_SCRIPTFUNC_PARAMS); - int SF_climb(R_SCRIPTFUNC_PARAMS); - int SF_setActorZ(R_SCRIPTFUNC_PARAMS); - int SF_getActorX(R_SCRIPTFUNC_PARAMS); - int SF_getActorY(R_SCRIPTFUNC_PARAMS); - int SF_playMusic(R_SCRIPTFUNC_PARAMS); - int SF_enableEscape(R_SCRIPTFUNC_PARAMS); - int SF_playSound(R_SCRIPTFUNC_PARAMS); - int SF_gotoScene(R_SCRIPTFUNC_PARAMS); + int SDebugPrintInstr(SCRIPT_THREAD *thread); + + int SF_sleep(SCRIPTFUNC_PARAMS); + int SF_takeObject(SCRIPTFUNC_PARAMS); + int SF_objectIsCarried(SCRIPTFUNC_PARAMS); + int SF_setStatusText(SCRIPTFUNC_PARAMS); + int SF_commandMode(SCRIPTFUNC_PARAMS); + int SF_actorWalkTo(SCRIPTFUNC_PARAMS); + int SF_setFacing(SCRIPTFUNC_PARAMS); + int SF_startBgdAnim(SCRIPTFUNC_PARAMS); + int SF_freezeInterface(SCRIPTFUNC_PARAMS); + int SF_dialogMode(SCRIPTFUNC_PARAMS); + int SF_startAnim(SCRIPTFUNC_PARAMS); + int SF_stopBgdAnim(SCRIPTFUNC_PARAMS); + int SF_actorWalkToAsync(SCRIPTFUNC_PARAMS); + int SF_moveTo(SCRIPTFUNC_PARAMS); + int SF_actorWalk(SCRIPTFUNC_PARAMS); + int SF_cycleActorFrames(SCRIPTFUNC_PARAMS); + int SF_setFrame(SCRIPTFUNC_PARAMS); + int SF_setRightPortrait(SCRIPTFUNC_PARAMS); + int SF_setLeftPortrait(SCRIPTFUNC_PARAMS); + int SF_linkAnim(SCRIPTFUNC_PARAMS); + int SF_placeActor(SCRIPTFUNC_PARAMS); + int SF_checkUserInterrupt(SCRIPTFUNC_PARAMS); + int SF_moveRelative(SCRIPTFUNC_PARAMS); + int SF_doAction(SCRIPTFUNC_PARAMS); + int SF_faceTowards(SCRIPTFUNC_PARAMS); + int SF_setFollower(SCRIPTFUNC_PARAMS); + int SF_setBgdAnimSpeed(SCRIPTFUNC_PARAMS); + int SF_centerActor(SCRIPTFUNC_PARAMS); + int SF_setActorState(SCRIPTFUNC_PARAMS); + int SF_finishBgdAnim(SCRIPTFUNC_PARAMS); + int SF_swapActors(SCRIPTFUNC_PARAMS); + int SF_scriptSpecialWalk(SCRIPTFUNC_PARAMS); + int SF_walkRelative(SCRIPTFUNC_PARAMS); + int SF_throwActor(SCRIPTFUNC_PARAMS); + int SF_waitWalk(SCRIPTFUNC_PARAMS); + int SF_changeActorScene(SCRIPTFUNC_PARAMS); + int SF_climb(SCRIPTFUNC_PARAMS); + int SF_setActorZ(SCRIPTFUNC_PARAMS); + int SF_getActorX(SCRIPTFUNC_PARAMS); + int SF_getActorY(SCRIPTFUNC_PARAMS); + int SF_playMusic(SCRIPTFUNC_PARAMS); + int SF_enableEscape(SCRIPTFUNC_PARAMS); + int SF_playSound(SCRIPTFUNC_PARAMS); + int SF_gotoScene(SCRIPTFUNC_PARAMS); }; } // End of namespace Saga diff --git a/saga/sdata.cpp b/saga/sdata.cpp index e1a26a8b8c..533f171ab2 100644 --- a/saga/sdata.cpp +++ b/saga/sdata.cpp @@ -35,36 +35,36 @@ SData::SData() { debug(0, "Initializing script data buffers"); - for (i = 0; i < R_SCRIPT_DATABUF_NUM; i++) { + for (i = 0; i < SCRIPT_DATABUF_NUM; i++) { alloc_ptr = malloc(sizeof *_vm->_script->dataBuffer(0)); if (alloc_ptr == NULL) { error("Couldn't allocate memory for script data buffer %d", i); } - _vm->_script->setBuffer(i, (R_SCRIPT_DATABUF *)alloc_ptr); + _vm->_script->setBuffer(i, (SCRIPT_DATABUF *)alloc_ptr); } - alloc_ptr = calloc(R_SCRIPT_DATABUF_LEN, sizeof(SDataWord_T)); + alloc_ptr = calloc(SCRIPT_DATABUF_LEN, sizeof(SDataWord_T)); if (alloc_ptr == NULL) { error("Couldn't allocate memory for shared script buffer"); } // Buffer 0 is the shared data buffer. All scripts can access this. - _vm->_script->dataBuffer(0)->len = R_SCRIPT_DATABUF_LEN; + _vm->_script->dataBuffer(0)->len = SCRIPT_DATABUF_LEN; _vm->_script->dataBuffer(0)->data = (SDataWord_T *)alloc_ptr; // FIXME: Buffer 1 is the script's static area. The original // interpreter uses part of buffer 0 for this, but I don't yet // understand quite how. - _vm->_script->setBuffer(1, (R_SCRIPT_DATABUF *)alloc_ptr); - _vm->_script->dataBuffer(1)->len = R_SCRIPT_DATABUF_LEN; + _vm->_script->setBuffer(1, (SCRIPT_DATABUF *)alloc_ptr); + _vm->_script->dataBuffer(1)->len = SCRIPT_DATABUF_LEN; _vm->_script->dataBuffer(1)->data = (SDataWord_T *)alloc_ptr; // Remaining buffers are per-script. - for (i = 2; i < R_SCRIPT_DATABUF_NUM; i++) { + for (i = 2; i < SCRIPT_DATABUF_NUM; i++) { _vm->_script->dataBuffer(i)->len = 0; _vm->_script->dataBuffer(i)->data = NULL; } @@ -75,35 +75,35 @@ SData::~SData() { } int SData::getWord(int n_buf, int n_word, SDataWord_T *data) { - if ((n_buf < 0) || (n_buf >= R_SCRIPT_DATABUF_NUM)) { - return R_FAILURE; + if ((n_buf < 0) || (n_buf >= SCRIPT_DATABUF_NUM)) { + return FAILURE; } if ((n_word < 0) || (n_word >= _vm->_script->dataBuffer(n_buf)->len)) { - return R_FAILURE; + return FAILURE; } if (data == NULL) { - return R_FAILURE; + return FAILURE; } *data = _vm->_script->dataBuffer(n_buf)->data[n_word]; - return R_SUCCESS; + return SUCCESS; } int SData::putWord(int n_buf, int n_word, SDataWord_T data) { - if ((n_buf < 0) || (n_buf >= R_SCRIPT_DATABUF_NUM)) { - return R_FAILURE; + if ((n_buf < 0) || (n_buf >= SCRIPT_DATABUF_NUM)) { + return FAILURE; } if ((n_word < 0) || (n_word >= _vm->_script->dataBuffer(n_buf)->len)) { - return R_FAILURE; + return FAILURE; } _vm->_script->dataBuffer(n_buf)->data[n_word] = data; - return R_SUCCESS; + return SUCCESS; } int SData::setBit(int n_buf, SDataWord_T n_bit, int bitstate) { @@ -112,12 +112,12 @@ int SData::setBit(int n_buf, SDataWord_T n_bit, int bitstate) { SDataWord_T bit_pattern = 0x01; - if ((n_buf < 0) || (n_buf >= R_SCRIPT_DATABUF_NUM)) { - return R_FAILURE; + if ((n_buf < 0) || (n_buf >= SCRIPT_DATABUF_NUM)) { + return FAILURE; } if (n_bit >= (unsigned long)_vm->_script->dataBuffer(n_buf)->len * (sizeof(SDataWord_T) * CHAR_BIT)) { - return R_FAILURE; + return FAILURE; } n_word = n_bit / (sizeof(SDataWord_T) * CHAR_BIT); @@ -131,7 +131,7 @@ int SData::setBit(int n_buf, SDataWord_T n_bit, int bitstate) { _vm->_script->dataBuffer(n_buf)->data[n_word] &= ~bit_pattern; } - return R_SUCCESS; + return SUCCESS; } int SData::getBit(int n_buf, SDataWord_T n_bit, int *bitstate) { @@ -140,12 +140,12 @@ int SData::getBit(int n_buf, SDataWord_T n_bit, int *bitstate) { SDataWord_T bit_pattern = 0x01; - if ((n_buf < 0) || (n_buf >= R_SCRIPT_DATABUF_NUM)) { - return R_FAILURE; + if ((n_buf < 0) || (n_buf >= SCRIPT_DATABUF_NUM)) { + return FAILURE; } if (n_bit >= (SDataWord_T) _vm->_script->dataBuffer(n_buf)->len * (sizeof(SDataWord_T) * CHAR_BIT)) { - return R_FAILURE; + return FAILURE; } n_word = n_bit / (sizeof(SDataWord_T) * CHAR_BIT); @@ -155,7 +155,7 @@ int SData::getBit(int n_buf, SDataWord_T n_bit, int *bitstate) { *bitstate = (_vm->_script->dataBuffer(n_buf)->data[n_word] & bit_pattern) ? 1 : 0; - return R_SUCCESS; + return SUCCESS; } int SData::readWordS(SDataWord_T word) { diff --git a/saga/sdebug.cpp b/saga/sdebug.cpp index 107dcc1198..866a9da9f7 100644 --- a/saga/sdebug.cpp +++ b/saga/sdebug.cpp @@ -36,15 +36,15 @@ namespace Saga { #define SD_DISPLAY_LEN 128 #define SD_ADDTXT( x ) strncat( disp_buf, x, SD_DISPLAY_LEN ); -int Script::SDebugPrintInstr(R_SCRIPT_THREAD *thread) { - R_TEXTLIST_ENTRY tl_e; +int Script::SDebugPrintInstr(SCRIPT_THREAD *thread) { + TEXTLIST_ENTRY tl_e; char tmp_buf[80] = { 0 }; static char disp_buf[SD_DISPLAY_LEN] = { 0 }; int in_char; // int op_offset; int n_switch; int i; - R_SCENE_INFO si; + SCENE_INFO si; _vm->_scene->getInfo(&si); @@ -104,7 +104,7 @@ int Script::SDebugPrintInstr(R_SCRIPT_THREAD *thread) { SD_ADDTXT(tmp_buf); /* if(( param >= 0 ) && ( param < diag_list->n_dialogue )) { - printf(" ; \"%.*s\"", R_SCRIPT_STRINGLIMIT, diag_list->str[param] ); + printf(" ; \"%.*s\"", SCRIPT_STRINGLIMIT, diag_list->str[param] ); } else { printf(" ; Invalid dialogue string.\n" ); @@ -328,10 +328,10 @@ int Script::SDebugPrintInstr(R_SCRIPT_THREAD *thread) { for (i = 0; i < n_switch; i++) { switch_num = readS.readUint16LE(); switch_jmp = readS.readUint16LE(); - // printf( R_TAB "CASE %04X, %04X\n", switch_num, switch_jmp); + // printf( TAB "CASE %04X, %04X\n", switch_num, switch_jmp); } default_jmp = readS.readUint16LE(); - //printf( R_TAB "DEF %04X", default_jmp); + //printf( TAB "DEF %04X", default_jmp); } break; // Random branch @@ -351,7 +351,7 @@ int Script::SDebugPrintInstr(R_SCRIPT_THREAD *thread) { //printf("\n"); switch_num = readS.readUint16LE(); switch_jmp = readS.readUint16LE(); - //printf( R_TAB "WEIGHT %04X, %04X", switch_num, switch_jmp); + //printf( TAB "WEIGHT %04X, %04X", switch_num, switch_jmp); } } break; @@ -515,7 +515,7 @@ int Script::SDebugPrintInstr(R_SCRIPT_THREAD *thread) { _dbg_txtentry = _vm->textAddEntry(si.text_list, &tl_e); _vm->textSetDisplay(_dbg_txtentry, 1); - return R_SUCCESS; + return SUCCESS; } } // End of namespace Saga diff --git a/saga/sfuncs.cpp b/saga/sfuncs.cpp index fa04a6f5fa..ac84580c1c 100644 --- a/saga/sfuncs.cpp +++ b/saga/sfuncs.cpp @@ -42,7 +42,7 @@ namespace Saga { #define OPCODE(x) &Script::x void Script::setupScriptFuncList(void) { - static const R_SFUNC_ENTRY SFuncList[R_SFUNC_NUM] = { + static const SFUNC_ENTRY SFuncList[SFUNC_NUM] = { {0, 0, NULL}, {1, 1, OPCODE(SF_sleep)}, {2, 1, OPCODE(SF_takeObject)}, @@ -127,7 +127,7 @@ void Script::setupScriptFuncList(void) { // Script function #1 (0x01) blocking // Suspends thread execution for the specified time period -int Script::SF_sleep(R_SCRIPTFUNC_PARAMS) { +int Script::SF_sleep(SCRIPTFUNC_PARAMS) { SDataWord_T time_param; long time; @@ -138,19 +138,19 @@ int Script::SF_sleep(R_SCRIPTFUNC_PARAMS) { thread->flags |= kTFlagWaiting; // put thread to sleep thread->waitType = kTWaitDelay; } - return R_SUCCESS; + return SUCCESS; } // Script function #2 (0x02) -int Script::SF_takeObject(R_SCRIPTFUNC_PARAMS) { +int Script::SF_takeObject(SCRIPTFUNC_PARAMS) { thread->pop(); - return R_SUCCESS; + return SUCCESS; } // Script function #3 (0x03) // Unknown function; pops a parameter and pushes a return value // Param1: unknown -int Script::SF_objectIsCarried(R_SCRIPTFUNC_PARAMS) { +int Script::SF_objectIsCarried(SCRIPTFUNC_PARAMS) { // INCOMPLETE SDataWord_T param1; param1 = thread->pop(); @@ -160,20 +160,20 @@ int Script::SF_objectIsCarried(R_SCRIPTFUNC_PARAMS) { thread->retVal = 0; - return R_SUCCESS; + return SUCCESS; } // Script function #4 (0x04) nonblocking // Set the command display to the specified text string // Param1: dialogue index of string -int Script::SF_setStatusText(R_SCRIPTFUNC_PARAMS) { +int Script::SF_setStatusText(SCRIPTFUNC_PARAMS) { SDataWord_T param = thread->pop(); return _vm->_interface->setStatusText(currentScript()->diag->str[param]); } // Script function #5 (0x05) -int Script::SF_commandMode(R_SCRIPTFUNC_PARAMS) { +int Script::SF_commandMode(SCRIPTFUNC_PARAMS) { return _vm->_interface->setMode(kPanelCommand); } @@ -182,7 +182,7 @@ int Script::SF_commandMode(R_SCRIPTFUNC_PARAMS) { // Param1: actor id // Param2: actor destination x // Param3: actor destination y -int Script::SF_actorWalkTo(R_SCRIPTFUNC_PARAMS) { +int Script::SF_actorWalkTo(SCRIPTFUNC_PARAMS) { SDataWord_T actor_parm; SDataWord_T x_parm; SDataWord_T y_parm; @@ -198,7 +198,7 @@ int Script::SF_actorWalkTo(R_SCRIPTFUNC_PARAMS) { actor_idx = _vm->_actor->getActorIndex(actor_id); if (actor_idx < 0) { _vm->_console->print(S_WARN_PREFIX "SF.08: Actor id 0x%X not found.", actor_id); - return R_FAILURE; + return FAILURE; } pt.x = _vm->_sdata->readWordS(x_parm); @@ -206,23 +206,23 @@ int Script::SF_actorWalkTo(R_SCRIPTFUNC_PARAMS) { _vm->_actor->walkTo(actor_idx, &pt, 0, &thread->sem); - return R_SUCCESS; + return SUCCESS; } // Script function #7 (0x07) -int Script::SF_doAction(R_SCRIPTFUNC_PARAMS) { +int Script::SF_doAction(SCRIPTFUNC_PARAMS) { thread->pop(); thread->pop(); thread->pop(); thread->pop(); - return R_SUCCESS; + return SUCCESS; } // Script function #8 (0x08) nonblocking // Sets the orientation of the specified actor. // Param1: actor id // Param2: actor orientation -int Script::SF_setFacing(R_SCRIPTFUNC_PARAMS) { +int Script::SF_setFacing(SCRIPTFUNC_PARAMS) { SDataWord_T actor_parm; SDataWord_T orient_parm; int actor_id; @@ -237,24 +237,24 @@ int Script::SF_setFacing(R_SCRIPTFUNC_PARAMS) { actor_idx = _vm->_actor->getActorIndex(actor_id); if (actor_idx < 0) { _vm->_console->print(S_WARN_PREFIX "SF.08: Actor id 0x%X not found.", actor_id); - return R_FAILURE; + return FAILURE; } _vm->_actor->setOrientation(actor_idx, orientation); - return R_SUCCESS; + return SUCCESS; } // Script function #9 (0x09) -int Script::SF_startBgdAnim(R_SCRIPTFUNC_PARAMS) { +int Script::SF_startBgdAnim(SCRIPTFUNC_PARAMS) { thread->pop(); thread->pop(); - return R_SUCCESS; + return SUCCESS; } // Script function #10 (0x0A) -int Script::SF_stopBgdAnim(R_SCRIPTFUNC_PARAMS) { +int Script::SF_stopBgdAnim(SCRIPTFUNC_PARAMS) { thread->pop(); - return R_SUCCESS; + return SUCCESS; } // Script function #11 (0x0B) nonblocking @@ -262,7 +262,7 @@ int Script::SF_stopBgdAnim(R_SCRIPTFUNC_PARAMS) { // continues to run. If the parameter is false, the user interface is // reenabled. // Param1: boolean -int Script::SF_freezeInterface(R_SCRIPTFUNC_PARAMS) { +int Script::SF_freezeInterface(SCRIPTFUNC_PARAMS) { SDataWord_T b_param; b_param = thread->pop(); @@ -273,47 +273,47 @@ int Script::SF_freezeInterface(R_SCRIPTFUNC_PARAMS) { _vm->_interface->activate(); } - return R_SUCCESS; + return SUCCESS; } // Script function #12 (0x0C) // Disables mouse input, etc. -int Script::SF_dialogMode(R_SCRIPTFUNC_PARAMS) { +int Script::SF_dialogMode(SCRIPTFUNC_PARAMS) { return _vm->_interface->setMode(kPanelDialogue); } // Script function #14 (0x0E) -int Script::SF_faceTowards(R_SCRIPTFUNC_PARAMS) { +int Script::SF_faceTowards(SCRIPTFUNC_PARAMS) { thread->pop(); thread->pop(); - return R_SUCCESS; + return SUCCESS; } // Script function #15 (0x0F) -int Script::SF_setFollower(R_SCRIPTFUNC_PARAMS) { +int Script::SF_setFollower(SCRIPTFUNC_PARAMS) { thread->pop(); thread->pop(); - return R_SUCCESS; + return SUCCESS; } // Script function #16 (0x10) -int Script::SF_gotoScene(R_SCRIPTFUNC_PARAMS) { +int Script::SF_gotoScene(SCRIPTFUNC_PARAMS) { thread->pop(); thread->pop(); - return R_SUCCESS; + return SUCCESS; } // Script function #23 (0x17) -int Script::SF_setBgdAnimSpeed(R_SCRIPTFUNC_PARAMS) { +int Script::SF_setBgdAnimSpeed(SCRIPTFUNC_PARAMS) { thread->pop(); thread->pop(); - return R_SUCCESS; + return SUCCESS; } // Script function #25 (0x19) -int Script::SF_centerActor(R_SCRIPTFUNC_PARAMS) { +int Script::SF_centerActor(SCRIPTFUNC_PARAMS) { thread->pop(); - return R_SUCCESS; + return SUCCESS; } // Script function #26 (0x1A) nonblocking @@ -321,7 +321,7 @@ int Script::SF_centerActor(R_SCRIPTFUNC_PARAMS) { // Param1: ? // Param2: frames of animation to play or -1 to loop // Param3: animation id -int Script::SF_startAnim(R_SCRIPTFUNC_PARAMS) { +int Script::SF_startAnim(SCRIPTFUNC_PARAMS) { // FIXME: implementation is wrong. Should link animation SDataWord_T unk_parm; SDataWord_T frame_parm; @@ -336,12 +336,12 @@ int Script::SF_startAnim(R_SCRIPTFUNC_PARAMS) { frame_count = _vm->_sdata->readWordS(frame_parm); anim_id = _vm->_sdata->readWordS(anim_id_parm); - if (_vm->_anim->play(anim_id, 0) != R_SUCCESS) { + if (_vm->_anim->play(anim_id, 0) != SUCCESS) { _vm->_console->print(S_WARN_PREFIX "SF.26: Anim::play() failed. Anim id: %u\n", anim_id); - return R_FAILURE; + return FAILURE; } - return R_SUCCESS; + return SUCCESS; } // Script function #27 (0x1B) nonblocking @@ -349,7 +349,7 @@ int Script::SF_startAnim(R_SCRIPTFUNC_PARAMS) { // Param1: actor id // Param2: actor destination x // Param3: actor destination y -int Script::SF_actorWalkToAsync(R_SCRIPTFUNC_PARAMS) { +int Script::SF_actorWalkToAsync(SCRIPTFUNC_PARAMS) { SDataWord_T actor_parm; SDataWord_T x_parm; SDataWord_T y_parm; @@ -366,21 +366,21 @@ int Script::SF_actorWalkToAsync(R_SCRIPTFUNC_PARAMS) { if (actor_idx < 0) { _vm->_console->print(S_WARN_PREFIX "SF.08: Actor id 0x%X not found.", actor_id); - return R_FAILURE; + return FAILURE; } pt.x = _vm->_sdata->readWordS(x_parm); pt.y = _vm->_sdata->readWordS(y_parm); _vm->_actor->walkTo(actor_idx, &pt, 0, NULL); - return R_SUCCESS; + return SUCCESS; } // Script function #29 (0x1D) -int Script::SF_setActorState(R_SCRIPTFUNC_PARAMS) { +int Script::SF_setActorState(SCRIPTFUNC_PARAMS) { thread->pop(); thread->pop(); - return R_SUCCESS; + return SUCCESS; } // Script function #30 (0x1E) nonblocking @@ -389,7 +389,7 @@ int Script::SF_setActorState(R_SCRIPTFUNC_PARAMS) { // Param1: actor id // Param2: actor pos x // Param3: actor pos y -int Script::SF_moveTo(R_SCRIPTFUNC_PARAMS) { +int Script::SF_moveTo(SCRIPTFUNC_PARAMS) { SDataWord_T actor_parm; SDataWord_T x_parm; SDataWord_T y_parm; @@ -408,29 +408,29 @@ int Script::SF_moveTo(R_SCRIPTFUNC_PARAMS) { if (!_vm->_actor->actorExists(actor_id)) { result = _vm->_actor->create(actor_id, pt.x, pt.y); - if (result != R_SUCCESS) { + if (result != SUCCESS) { _vm->_console->print(S_WARN_PREFIX "SF.30: Couldn't create actor 0x%X.", actor_id); - return R_FAILURE; + return FAILURE; } } else { actor_idx = _vm->_actor->getActorIndex(actor_id); _vm->_actor->move(actor_idx, &pt); } - return R_SUCCESS; + return SUCCESS; } // Script function #33 (0x21) -int Script::SF_finishBgdAnim(R_SCRIPTFUNC_PARAMS) { +int Script::SF_finishBgdAnim(SCRIPTFUNC_PARAMS) { thread->pop(); - return R_SUCCESS; + return SUCCESS; } // Script function #34 (0x22) -int Script::SF_swapActors(R_SCRIPTFUNC_PARAMS) { +int Script::SF_swapActors(SCRIPTFUNC_PARAMS) { thread->pop(); thread->pop(); - return R_SUCCESS; + return SUCCESS; } // Script function #36 (0x24) ? @@ -439,7 +439,7 @@ int Script::SF_swapActors(R_SCRIPTFUNC_PARAMS) { // Param2: actor destination x // Param3: actor destination y // Param4: unknown -int Script::SF_actorWalk(R_SCRIPTFUNC_PARAMS) { +int Script::SF_actorWalk(SCRIPTFUNC_PARAMS) { // INCOMPLETE SDataWord_T actor_parm; SDataWord_T x_parm; @@ -456,7 +456,7 @@ int Script::SF_actorWalk(R_SCRIPTFUNC_PARAMS) { actor_idx = _vm->_actor->getActorIndex(_vm->_sdata->readWordS(actor_parm)); if (actor_idx < 0) { _vm->_console->print(S_WARN_PREFIX "SF.36: Actor id 0x%X not found.", (int)actor_parm); - return R_FAILURE; + return FAILURE; } pt.x = _vm->_sdata->readWordS(x_parm); @@ -468,7 +468,7 @@ int Script::SF_actorWalk(R_SCRIPTFUNC_PARAMS) { _vm->_actor->walkTo(actor_idx, &pt, 0, &thread->sem); #endif - return R_SUCCESS; + return SUCCESS; } // Script function #37 (0x25) nonblocking @@ -477,7 +477,7 @@ int Script::SF_actorWalk(R_SCRIPTFUNC_PARAMS) { // Param2: unknown // Param3: actor action state // Param4: unknown -int Script::SF_cycleActorFrames(R_SCRIPTFUNC_PARAMS) { +int Script::SF_cycleActorFrames(SCRIPTFUNC_PARAMS) { // INCOMPLETE SDataWord_T actor_parm; SDataWord_T unk1_parm; @@ -496,12 +496,12 @@ int Script::SF_cycleActorFrames(R_SCRIPTFUNC_PARAMS) { action = _vm->_sdata->readWordS(action_parm); actor_idx = _vm->_actor->getActorIndex(actor_id); - if (_vm->_actor->setAction(actor_idx, action, ACTION_NONE) != R_SUCCESS) { + if (_vm->_actor->setAction(actor_idx, action, ACTION_NONE) != SUCCESS) { _vm->_console->print(S_WARN_PREFIX "SF.37: Actor::setAction() failed."); - return R_FAILURE; + return FAILURE; } - return R_SUCCESS; + return SUCCESS; } // Script function #38 (0x26) nonblocking @@ -509,7 +509,7 @@ int Script::SF_cycleActorFrames(R_SCRIPTFUNC_PARAMS) { // Param1: actor id // Param2: actor action state // Param3: unknown -int Script::SF_setFrame(R_SCRIPTFUNC_PARAMS) { +int Script::SF_setFrame(SCRIPTFUNC_PARAMS) { // INCOMPLETE SDataWord_T actor_parm; @@ -529,17 +529,17 @@ int Script::SF_setFrame(R_SCRIPTFUNC_PARAMS) { action = _vm->_sdata->readWordS(action_parm); actor_idx = _vm->_actor->getActorIndex(actor_id); - if (_vm->_actor->setAction(actor_idx, action, ACTION_NONE) != R_SUCCESS) { + if (_vm->_actor->setAction(actor_idx, action, ACTION_NONE) != SUCCESS) { _vm->_console->print(S_WARN_PREFIX "SF.38: Actor::setAction() failed."); - return R_FAILURE; + return FAILURE; } - return R_SUCCESS; + return SUCCESS; } // Script function #39 (0x27) // Sets the right-hand portrait -int Script::SF_setRightPortrait(R_SCRIPTFUNC_PARAMS) { +int Script::SF_setRightPortrait(SCRIPTFUNC_PARAMS) { SDataWord_T param = thread->pop(); return _vm->_interface->setRightPortrait(param); @@ -547,7 +547,7 @@ int Script::SF_setRightPortrait(R_SCRIPTFUNC_PARAMS) { // Script function #40 (0x28) // Sets the left-hand portrait -int Script::SF_setLeftPortrait(R_SCRIPTFUNC_PARAMS) { +int Script::SF_setLeftPortrait(SCRIPTFUNC_PARAMS) { SDataWord_T param = thread->pop(); return _vm->_interface->setLeftPortrait(param); @@ -560,7 +560,7 @@ int Script::SF_setLeftPortrait(R_SCRIPTFUNC_PARAMS) { // Param2: total linked frame count // Param3: animation id link target // Param4: animation id link source -int Script::SF_linkAnim(R_SCRIPTFUNC_PARAMS) { +int Script::SF_linkAnim(SCRIPTFUNC_PARAMS) { SDataWord_T unk_parm; SDataWord_T tframes_parm; SDataWord_T anim1_parm; @@ -577,21 +577,21 @@ int Script::SF_linkAnim(R_SCRIPTFUNC_PARAMS) { anim_id1 = _vm->_sdata->readWordU(anim1_parm); anim_id2 = _vm->_sdata->readWordU(anim2_parm); - if (_vm->_anim->link(anim_id1, anim_id2) != R_SUCCESS) { + if (_vm->_anim->link(anim_id1, anim_id2) != SUCCESS) { _vm->_console->print(S_WARN_PREFIX "SF.41: Anim::link() failed. (%u->%u)\n", anim_id1, anim_id2); - return R_FAILURE; + return FAILURE; } - return R_SUCCESS; + return SUCCESS; } // Script function #42 (0x2A) -int Script::SF_scriptSpecialWalk(R_SCRIPTFUNC_PARAMS) { +int Script::SF_scriptSpecialWalk(SCRIPTFUNC_PARAMS) { thread->pop(); thread->pop(); thread->pop(); thread->pop(); - return R_SUCCESS; + return SUCCESS; } // Script function #43 (0x2B) nonblocking @@ -603,7 +603,7 @@ int Script::SF_scriptSpecialWalk(R_SCRIPTFUNC_PARAMS) { // Param4: ? // Param5: actor action // Param6: ? -int Script::SF_placeActor(R_SCRIPTFUNC_PARAMS) { +int Script::SF_placeActor(SCRIPTFUNC_PARAMS) { // INCOMPLETE SDataWord_T actor_parm; SDataWord_T x_parm; @@ -630,9 +630,9 @@ int Script::SF_placeActor(R_SCRIPTFUNC_PARAMS) { if (!_vm->_actor->actorExists(actor_id)) { result = _vm->_actor->create(actor_id, pt.x, pt.y); - if (result != R_SUCCESS) { + if (result != SUCCESS) { _vm->_console->print(S_WARN_PREFIX "SF.43: Couldn't create actor 0x%X.", actor_id); - return R_FAILURE; + return FAILURE; } } else { actor_idx = _vm->_actor->getActorIndex(actor_id); @@ -643,93 +643,93 @@ int Script::SF_placeActor(R_SCRIPTFUNC_PARAMS) { _vm->_actor->setDefaultAction(actor_idx, action_state, ACTION_NONE); _vm->_actor->setAction(actor_idx, action_state, ACTION_NONE); - return R_SUCCESS; + return SUCCESS; } // Script function #44 (0x2C) nonblocking // Checks to see if the user has interrupted a currently playing // game cinematic. Pushes a zero or positive value if the game // has not been interrupted. -int Script::SF_checkUserInterrupt(R_SCRIPTFUNC_PARAMS) { +int Script::SF_checkUserInterrupt(SCRIPTFUNC_PARAMS) { thread->retVal = (_skipSpeeches == true); - return R_SUCCESS; + return SUCCESS; } // Script function #45 (0x2D) -int Script::SF_walkRelative(R_SCRIPTFUNC_PARAMS) { +int Script::SF_walkRelative(SCRIPTFUNC_PARAMS) { thread->pop(); thread->pop(); thread->pop(); thread->pop(); thread->pop(); - return R_SUCCESS; + return SUCCESS; } // Script function #46 (0x2E) -int Script::SF_moveRelative(R_SCRIPTFUNC_PARAMS) { +int Script::SF_moveRelative(SCRIPTFUNC_PARAMS) { thread->pop(); thread->pop(); thread->pop(); thread->pop(); thread->pop(); - return R_SUCCESS; + return SUCCESS; } // Script function #52 (0x34) -int Script::SF_throwActor(R_SCRIPTFUNC_PARAMS) { +int Script::SF_throwActor(SCRIPTFUNC_PARAMS) { thread->pop(); thread->pop(); thread->pop(); thread->pop(); thread->pop(); thread->pop(); - return R_SUCCESS; + return SUCCESS; } // Script function #53 (0x35) -int Script::SF_waitWalk(R_SCRIPTFUNC_PARAMS) { +int Script::SF_waitWalk(SCRIPTFUNC_PARAMS) { thread->pop(); - return R_SUCCESS; + return SUCCESS; } // Script function #55 (0x37) -int Script::SF_changeActorScene(R_SCRIPTFUNC_PARAMS) { +int Script::SF_changeActorScene(SCRIPTFUNC_PARAMS) { thread->pop(); thread->pop(); - return R_SUCCESS; + return SUCCESS; } // Script function #56 (0x38) -int Script::SF_climb(R_SCRIPTFUNC_PARAMS) { +int Script::SF_climb(SCRIPTFUNC_PARAMS) { thread->pop(); thread->pop(); thread->pop(); thread->pop(); - return R_SUCCESS; + return SUCCESS; } // Script function #58 (0x3A) -int Script::SF_setActorZ(R_SCRIPTFUNC_PARAMS) { +int Script::SF_setActorZ(SCRIPTFUNC_PARAMS) { thread->pop(); thread->pop(); - return R_SUCCESS; + return SUCCESS; } // Script function #60 (0x3C) -int Script::SF_getActorX(R_SCRIPTFUNC_PARAMS) { +int Script::SF_getActorX(SCRIPTFUNC_PARAMS) { thread->pop(); - return R_SUCCESS; + return SUCCESS; } // Script function #61 (0x3D) -int Script::SF_getActorY(R_SCRIPTFUNC_PARAMS) { +int Script::SF_getActorY(SCRIPTFUNC_PARAMS) { thread->pop(); - return R_SUCCESS; + return SUCCESS; } // Script function #63 (0x3F) -int Script::SF_playMusic(R_SCRIPTFUNC_PARAMS) { +int Script::SF_playMusic(SCRIPTFUNC_PARAMS) { SDataWord_T param = thread->pop() + 9; if (param >= 9 && param <= 34) @@ -737,11 +737,11 @@ int Script::SF_playMusic(R_SCRIPTFUNC_PARAMS) { else _vm->_music->stop(); - return R_SUCCESS; + return SUCCESS; } // Script function #69 -int Script::SF_enableEscape(R_SCRIPTFUNC_PARAMS) { +int Script::SF_enableEscape(SCRIPTFUNC_PARAMS) { if (thread->pop()) _abortEnabled = true; else { @@ -749,7 +749,7 @@ int Script::SF_enableEscape(R_SCRIPTFUNC_PARAMS) { _abortEnabled = false; } - return R_SUCCESS; + return SUCCESS; } static struct { @@ -824,7 +824,7 @@ static struct { }; // Script function #70 (0x46) -int Script::SF_playSound(R_SCRIPTFUNC_PARAMS) { +int Script::SF_playSound(SCRIPTFUNC_PARAMS) { SDataWord_T param = thread->pop() - 13; if (/* param >= 0 && */ param < ARRAYSIZE(sfxTable)) @@ -832,7 +832,7 @@ int Script::SF_playSound(R_SCRIPTFUNC_PARAMS) { else _vm->_sound->stopSound(); - return R_SUCCESS; + return SUCCESS; } } // End of namespace Saga diff --git a/saga/sndres.cpp b/saga/sndres.cpp index f8ed8b41e7..c36845d99c 100644 --- a/saga/sndres.cpp +++ b/saga/sndres.cpp @@ -39,13 +39,13 @@ SndRes::SndRes(SagaEngine *vm) : _vm(vm) { int result; /* Load sound module resource file contexts */ - result = GAME_GetFileContext(&_sfx_ctxt, R_GAME_SOUNDFILE, 0); - if (result != R_SUCCESS) { + result = GAME_GetFileContext(&_sfx_ctxt, GAME_SOUNDFILE, 0); + if (result != SUCCESS) { return; } - result = GAME_GetFileContext(&_voice_ctxt, R_GAME_VOICEFILE, 0); - if (result != R_SUCCESS) { + result = GAME_GetFileContext(&_voice_ctxt, GAME_VOICEFILE, 0); + if (result != SUCCESS) { return; } @@ -56,22 +56,22 @@ SndRes::SndRes(SagaEngine *vm) : _vm(vm) { } int SndRes::playSound(uint32 sound_rn, int volume) { - R_SOUNDBUFFER snd_buffer; + SOUNDBUFFER snd_buffer; debug(0, "SndRes::playSound(%ld)", sound_rn); - if (load(_sfx_ctxt, sound_rn, &snd_buffer) != R_SUCCESS) { -debug(0, "Failed to load sound"); - return R_FAILURE; + if (load(_sfx_ctxt, sound_rn, &snd_buffer) != SUCCESS) { + debug(0, "Failed to load sound"); + return FAILURE; } _vm->_sound->playSound(&snd_buffer, volume); - return R_SUCCESS; + return SUCCESS; } int SndRes::playVoice(uint32 voice_rn) { - R_SOUNDBUFFER snd_buffer; + SOUNDBUFFER snd_buffer; int result; debug(0, "SndRes::playVoice(%ld)", voice_rn); @@ -91,7 +91,7 @@ int SndRes::playVoice(uint32 voice_rn) { f.open("P2_A.iaf"); if (!f.isOpen()) - return R_FAILURE; + return FAILURE; size = f.size(); byte *snd_res = (byte *)malloc(size); @@ -105,7 +105,7 @@ int SndRes::playVoice(uint32 voice_rn) { snd_buffer.s_buf = snd_res; snd_buffer.s_buf_len = size; snd_buffer.s_signed = 1; - result = R_SUCCESS; + result = SUCCESS; } else { result = loadVocSound(snd_res, size, &snd_buffer); RSC_FreeResource(snd_res); @@ -113,16 +113,16 @@ int SndRes::playVoice(uint32 voice_rn) { } else result = load(_voice_ctxt, voice_rn, &snd_buffer); - if (result != R_SUCCESS) { - return R_FAILURE; + if (result != SUCCESS) { + return FAILURE; } _vm->_sound->playVoice(&snd_buffer); - return R_SUCCESS; + return SUCCESS; } -int SndRes::load(R_RSCFILE_CONTEXT *snd_ctxt, uint32 snd_rn, R_SOUNDBUFFER *snd_buf_i) { +int SndRes::load(RSCFILE_CONTEXT *snd_ctxt, uint32 snd_rn, SOUNDBUFFER *snd_buf_i) { byte *snd_res; size_t snd_res_len; @@ -131,12 +131,12 @@ int SndRes::load(R_RSCFILE_CONTEXT *snd_ctxt, uint32 snd_rn, R_SOUNDBUFFER *snd_ assert((snd_ctxt != NULL) && (snd_buf_i != NULL)); result = RSC_LoadResource(snd_ctxt, snd_rn, &snd_res, &snd_res_len); - if (result != R_SUCCESS) { - return R_FAILURE; + if (result != SUCCESS) { + return FAILURE; } switch (_snd_info.res_type) { - case R_GAME_SOUND_PCM: + case GAME_SOUND_PCM: 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; @@ -144,51 +144,51 @@ int SndRes::load(R_RSCFILE_CONTEXT *snd_ctxt, uint32 snd_rn, R_SOUNDBUFFER *snd_ snd_buf_i->s_buf_len = snd_res_len; snd_buf_i->s_signed = 1; break; - case R_GAME_SOUND_VOC: + case GAME_SOUND_VOC: result = loadVocSound(snd_res, snd_res_len, snd_buf_i); RSC_FreeResource(snd_res); - if (result != R_SUCCESS) { - return R_FAILURE; + if (result != SUCCESS) { + return FAILURE; } break; default: /* Unknown sound type */ RSC_FreeResource(snd_res); - return R_FAILURE; + return FAILURE; } - return R_SUCCESS; + return SUCCESS; } -int SndRes::loadVocSound(byte *snd_res, size_t snd_res_len, R_SOUNDBUFFER *snd_buf_i) { - R_VOC_HEADER_BLOCK voc_hb; - R_VOC_GENBLOCK voc_gb; - R_VOC_BLOCK1 voc_b1; +int SndRes::loadVocSound(byte *snd_res, size_t snd_res_len, SOUNDBUFFER *snd_buf_i) { + VOC_HEADER_BLOCK voc_hb; + VOC_GENBLOCK voc_gb; + VOC_BLOCK1 voc_b1; byte *data; long byte_rate; size_t i; - if (snd_res_len < R_VOC_HEADER_BLOCK_LEN) { - return R_FAILURE; + if (snd_res_len < VOC_HEADER_BLOCK_LEN) { + return FAILURE; } MemoryReadStream readS(snd_res, snd_res_len); - for (i = 0; i < R_VOC_FILE_DESC_LEN; i++) + for (i = 0; i < VOC_FILE_DESC_LEN; i++) voc_hb.ft_desc[i] = readS.readByte(); - if (memcmp(voc_hb.ft_desc, R_VOC_FILE_DESC, R_VOC_FILE_DESC_LEN) != 0) { + if (memcmp(voc_hb.ft_desc, VOC_FILE_DESC, VOC_FILE_DESC_LEN) != 0) { /* Voc file desc string not found */ - return R_FAILURE; + return FAILURE; } voc_hb.db_offset = readS.readUint16LE(); voc_hb.voc_version = readS.readUint16LE(); voc_hb.voc_fileid = readS.readUint16LE(); - if ((int32)(snd_res_len - readS.pos()) < (int32)(voc_hb.db_offset + R_VOC_GENBLOCK_LEN)) { - return R_FAILURE; + if ((int32)(snd_res_len - readS.pos()) < (int32)(voc_hb.db_offset + VOC_GENBLOCK_LEN)) { + return FAILURE; } while (readS.pos() < voc_hb.db_offset) @@ -196,13 +196,13 @@ int SndRes::loadVocSound(byte *snd_res, size_t snd_res_len, R_SOUNDBUFFER *snd_b for (;;) { /* Read generic block header */ - if (snd_res_len - readS.pos() < R_VOC_GENBLOCK_LEN) { - return R_FAILURE; + if (snd_res_len - readS.pos() < VOC_GENBLOCK_LEN) { + return FAILURE; } voc_gb.block_id = readS.readByte(); if (voc_gb.block_id == 0) { - return R_FAILURE; + return FAILURE; } voc_gb.block_len = readS.readUint24LE(); @@ -215,10 +215,10 @@ int SndRes::loadVocSound(byte *snd_res, size_t snd_res_len, R_SOUNDBUFFER *snd_b if (voc_b1.pack_method != 0) { debug(0, "Packed VOC files not supported"); - return R_FAILURE; + return FAILURE; } - byte_rate = R_VOC_TIME_BASE / (R_VOC_TIME_CBASE - (voc_b1.time_constant << 8)); + byte_rate = VOC_TIME_BASE / (VOC_TIME_CBASE - (voc_b1.time_constant << 8)); snd_buf_i->s_stereo = 0; snd_buf_i->s_samplebits = 8; @@ -227,14 +227,14 @@ int SndRes::loadVocSound(byte *snd_res, size_t snd_res_len, R_SOUNDBUFFER *snd_b data = (byte *)malloc(snd_buf_i->s_buf_len); if (!data) { - return R_FAILURE; + return FAILURE; } readS.read(data, snd_buf_i->s_buf_len); snd_buf_i->s_buf = data; snd_buf_i->s_signed = 0; - return R_SUCCESS; + return SUCCESS; default: for (i = 0; i < voc_gb.block_len; i++) readS.readByte(); @@ -242,7 +242,7 @@ int SndRes::loadVocSound(byte *snd_res, size_t snd_res_len, R_SOUNDBUFFER *snd_b } } - return R_SUCCESS; + return SUCCESS; } int SndRes::getVoiceLength(uint32 voice_rn) { @@ -252,7 +252,7 @@ int SndRes::getVoiceLength(uint32 voice_rn) { double ms_f; int ms_i = -1; - int result = R_FAILURE; + int result = FAILURE; assert(_init); @@ -264,30 +264,30 @@ int SndRes::getVoiceLength(uint32 voice_rn) { if (GAME_GetGameType() == GID_ITE && voice_rn == 4) { if (f.open("p2_a.voc")) { - result = R_SUCCESS; + result = SUCCESS; length = f.size(); - res_type = R_GAME_SOUND_VOC; + res_type = GAME_SOUND_VOC; f.close(); } else if (f.open("P2_A.iaf")) { - result = R_SUCCESS; + result = SUCCESS; length = f.size(); - res_type = R_GAME_SOUND_PCM; + res_type = GAME_SOUND_PCM; f.close(); } } - if (result == R_FAILURE) { + if (result == FAILURE) { result = RSC_GetResourceSize(_voice_ctxt, voice_rn, &length); - if (result != R_SUCCESS) { + if (result != SUCCESS) { return -1; } } - if (res_type == R_GAME_SOUND_PCM) { + if (res_type == GAME_SOUND_PCM) { ms_f = (double)length / (_snd_info.sample_size / CHAR_BIT) / (_snd_info.freq) * 1000.0; ms_i = (int)ms_f; - } else if (res_type == R_GAME_SOUND_VOC) { + } else if (res_type == GAME_SOUND_VOC) { // Rough hack, fix this to be accurate ms_f = (double)length / 14705 * 1000.0; ms_i = (int)ms_f; @@ -321,7 +321,7 @@ int SndRes::ITEVOC_Resample(long src_freq, long dst_freq, byte *src_buf, resamp_len = (size_t) (src_buf_len * 1.5); resamp_buf = (byte *)malloc(resamp_len); if (resamp_buf == NULL) { - return R_FAILURE; + return FAILURE; } read_pa = src_buf; @@ -350,7 +350,7 @@ int SndRes::ITEVOC_Resample(long src_freq, long dst_freq, byte *src_buf, *dst_buf = resamp_buf; *dst_buf_len = resamp_len; - return R_SUCCESS; + return SUCCESS; } } // End of namespace Saga diff --git a/saga/sndres.h b/saga/sndres.h index 1453b6f056..53de34641a 100644 --- a/saga/sndres.h +++ b/saga/sndres.h @@ -32,29 +32,29 @@ namespace Saga { -#define R_VOC_TIME_BASE 256000000L -#define R_VOC_TIME_CBASE 65536L +#define VOC_TIME_BASE 256000000L +#define VOC_TIME_CBASE 65536L -#define R_VOC_FILE_DESC_LEN 20 -#define R_VOC_FILE_DESC "Creative Voice File\x1A" +#define VOC_FILE_DESC_LEN 20 +#define VOC_FILE_DESC "Creative Voice File\x1A" -struct R_VOC_HEADER_BLOCK { +struct VOC_HEADER_BLOCK { 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 +#define VOC_HEADER_BLOCK_LEN 26 -struct R_VOC_GENBLOCK { +struct VOC_GENBLOCK { int block_id; // BYTE uint32 block_len; // BYTE[3] }; -#define R_VOC_GENBLOCK_LEN 4 +#define VOC_GENBLOCK_LEN 4 -struct R_VOC_BLOCK1 { +struct VOC_BLOCK1 { int block_id; // BYTE uint32 block_len; // BYTE[3] uint16 time_constant; // BYTE @@ -74,15 +74,15 @@ public: size_t src_buf_len, byte **dst_buf, size_t *dst_buf_len); private: - int load(R_RSCFILE_CONTEXT *snd_ctxt, uint32 snd_rn, R_SOUNDBUFFER *snd_buf_i); - int loadVocSound(byte *snd_res, size_t snd_res_len, R_SOUNDBUFFER *snd_buf_i); + int load(RSCFILE_CONTEXT *snd_ctxt, uint32 snd_rn, SOUNDBUFFER *snd_buf_i); + int loadVocSound(byte *snd_res, size_t snd_res_len, SOUNDBUFFER *snd_buf_i); int _init; - R_RSCFILE_CONTEXT *_sfx_ctxt; - R_RSCFILE_CONTEXT *_voice_ctxt; + RSCFILE_CONTEXT *_sfx_ctxt; + RSCFILE_CONTEXT *_voice_ctxt; - R_GAME_SOUNDINFO _snd_info; + GAME_SOUNDINFO _snd_info; SagaEngine *_vm; }; diff --git a/saga/sound.cpp b/saga/sound.cpp index 513f607b98..a6859134ae 100644 --- a/saga/sound.cpp +++ b/saga/sound.cpp @@ -44,11 +44,11 @@ Sound::~Sound() { _soundInitialized = 0; } -int Sound::playSoundBuffer(PlayingSoundHandle *handle, R_SOUNDBUFFER *buf, int volume, bool loop) { +int Sound::playSoundBuffer(PlayingSoundHandle *handle, SOUNDBUFFER *buf, int volume, bool loop) { byte flags; if (!_soundInitialized) { - return R_FAILURE; + return FAILURE; } flags = SoundMixer::FLAG_AUTOFREE; @@ -68,7 +68,7 @@ int Sound::playSoundBuffer(PlayingSoundHandle *handle, R_SOUNDBUFFER *buf, int v #if 0 int game_id = GAME_GetGame(); - if((game_id == R_GAME_ITE_DISK) || (game_id == R_GAME_ITE_DEMO)) { + if((game_id == GAME_ITE_DISK) || (game_id == GAME_ITE_DEMO)) { flags = SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE; } else { flags = SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_16BITS | @@ -78,75 +78,75 @@ int Sound::playSoundBuffer(PlayingSoundHandle *handle, R_SOUNDBUFFER *buf, int v _mixer->playRaw(handle, buf->s_buf, buf->s_buf_len, buf->s_freq, flags, -1, volume); - return R_SUCCESS; + return SUCCESS; } -int Sound::playSound(R_SOUNDBUFFER *buf, int volume) { +int Sound::playSound(SOUNDBUFFER *buf, int volume) { return playSoundBuffer(&_effectHandle, buf, 2 * volume, false); } int Sound::pauseSound() { if (!_soundInitialized) { - return R_FAILURE; + return FAILURE; } _mixer->pauseHandle(_effectHandle, true); - return R_SUCCESS; + return SUCCESS; } int Sound::resumeSound() { if (!_soundInitialized) { - return R_FAILURE; + return FAILURE; } _mixer->pauseHandle(_effectHandle, false); - return R_SUCCESS; + return SUCCESS; } int Sound::stopSound() { if (!_soundInitialized) { - return R_FAILURE; + return FAILURE; } _mixer->stopHandle(_effectHandle); - return R_SUCCESS; + return SUCCESS; } -int Sound::playVoice(R_SOUNDBUFFER *buf) { +int Sound::playVoice(SOUNDBUFFER *buf) { return playSoundBuffer(&_voiceHandle, buf, 255, false); } int Sound::pauseVoice() { if (!_soundInitialized) { - return R_FAILURE; + return FAILURE; } _mixer->pauseHandle(_voiceHandle, true); - return R_SUCCESS; + return SUCCESS; } int Sound::resumeVoice() { if (!_soundInitialized) { - return R_FAILURE; + return FAILURE; } _mixer->pauseHandle(_voiceHandle, false); - return R_SUCCESS; + return SUCCESS; } int Sound::stopVoice() { if (!_soundInitialized) { - return R_FAILURE; + return FAILURE; } _mixer->stopHandle(_voiceHandle); - return R_SUCCESS; + return SUCCESS; } } // End of namespace Saga diff --git a/saga/sound.h b/saga/sound.h index bccb872735..46d05f5ede 100644 --- a/saga/sound.h +++ b/saga/sound.h @@ -32,7 +32,7 @@ namespace Saga { -struct R_SOUNDBUFFER { +struct SOUNDBUFFER { uint16 s_freq; int s_samplebits; int s_stereo; @@ -48,19 +48,19 @@ public: Sound(SagaEngine *vm, SoundMixer *mixer, int enabled); ~Sound(); - int playSound(R_SOUNDBUFFER *buf, int volume); + int playSound(SOUNDBUFFER *buf, int volume); int pauseSound(); int resumeSound(); int stopSound(); - int playVoice(R_SOUNDBUFFER *buf); + int playVoice(SOUNDBUFFER *buf); int pauseVoice(); int resumeVoice(); int stopVoice(); private: - int playSoundBuffer(PlayingSoundHandle *handle, R_SOUNDBUFFER *buf, int volume, bool loop); + int playSoundBuffer(PlayingSoundHandle *handle, SOUNDBUFFER *buf, int volume, bool loop); int _soundInitialized; int _enabled; diff --git a/saga/sprite.cpp b/saga/sprite.cpp index e9a136c214..d0fa8cb076 100644 --- a/saga/sprite.cpp +++ b/saga/sprite.cpp @@ -42,14 +42,14 @@ Sprite::Sprite(SagaEngine *vm) : _vm(vm), _initialized(false) { debug(0, "Initializing sprite subsystem..."); // Load sprite module resource context - result = GAME_GetFileContext(&_spriteContext, R_GAME_RESOURCEFILE, 0); - if (result != R_SUCCESS) { + result = GAME_GetFileContext(&_spriteContext, GAME_RESOURCEFILE, 0); + if (result != SUCCESS) { return; } - _decodeBufLen = R_DECODE_BUF_LEN; + _decodeBufLen = DECODE_BUF_LEN; - _decodeBuf = (byte *)malloc(R_DECODE_BUF_LEN); + _decodeBuf = (byte *)malloc(DECODE_BUF_LEN); if (_decodeBuf == NULL) { return; } @@ -67,20 +67,20 @@ Sprite::~Sprite(void) { free(_decodeBuf); } -int Sprite::loadList(int resource_num, R_SPRITELIST **sprite_list_p) { - R_SPRITELIST *new_slist; +int Sprite::loadList(int resource_num, SPRITELIST **sprite_list_p) { + SPRITELIST *new_slist; byte *spritelist_data; size_t spritelist_len; uint16 sprite_count; uint16 i; - new_slist = (R_SPRITELIST *)malloc(sizeof *new_slist); + new_slist = (SPRITELIST *)malloc(sizeof *new_slist); if (new_slist == NULL) { - return R_MEM; + return MEM; } - if (RSC_LoadResource(_spriteContext, resource_num, &spritelist_data, &spritelist_len) != R_SUCCESS) { - return R_FAILURE; + if (RSC_LoadResource(_spriteContext, resource_num, &spritelist_data, &spritelist_len) != SUCCESS) { + return FAILURE; } MemoryReadStream readS(spritelist_data, spritelist_len); @@ -89,10 +89,10 @@ 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 = (SPRITELIST_OFFSET *)malloc(sprite_count * sizeof *new_slist->offset_list); if (new_slist->offset_list == NULL) { free(new_slist); - return R_MEM; + return MEM; } for (i = 0; i < sprite_count; i++) { @@ -106,10 +106,10 @@ int Sprite::loadList(int resource_num, R_SPRITELIST **sprite_list_p) { *sprite_list_p = new_slist; - return R_SUCCESS; + return SUCCESS; } -int Sprite::appendList(int resource_num, R_SPRITELIST *spritelist) { +int Sprite::appendList(int resource_num, SPRITELIST *spritelist) { byte *spritelist_data; size_t spritelist_len; void *test_p; @@ -118,12 +118,12 @@ int Sprite::appendList(int resource_num, R_SPRITELIST *spritelist) { uint16 sprite_count; int i; - if (spritelist->append_count >= (R_APPENDMAX - 1)) { - return R_FAILURE; + if (spritelist->append_count >= (APPENDMAX - 1)) { + return FAILURE; } - if (RSC_LoadResource(_spriteContext, resource_num, &spritelist_data, &spritelist_len) != R_SUCCESS) { - return R_FAILURE; + if (RSC_LoadResource(_spriteContext, resource_num, &spritelist_data, &spritelist_len) != SUCCESS) { + return FAILURE; } MemoryReadStream readS(spritelist_data, spritelist_len); @@ -135,10 +135,10 @@ int Sprite::appendList(int resource_num, R_SPRITELIST *spritelist) { test_p = realloc(spritelist->offset_list, new_sprite_count * sizeof *spritelist->offset_list); if (test_p == NULL) { - return R_MEM; + return MEM; } - spritelist->offset_list = (R_SPRITELIST_OFFSET *)test_p; + spritelist->offset_list = (SPRITELIST_OFFSET *)test_p; spritelist->sprite_count = new_sprite_count; spritelist->append_count++; @@ -150,14 +150,14 @@ int Sprite::appendList(int resource_num, R_SPRITELIST *spritelist) { spritelist->sprite_data[spritelist->append_count] = spritelist_data; - return R_SUCCESS; + return SUCCESS; } -int Sprite::getListLen(R_SPRITELIST *spritelist) { +int Sprite::getListLen(SPRITELIST *spritelist) { return spritelist->sprite_count; } -int Sprite::freeSprite(R_SPRITELIST *spritelist) { +int Sprite::freeSprite(SPRITELIST *spritelist) { int i; for (i = 0; i <= spritelist->append_count; i++) { @@ -168,10 +168,10 @@ int Sprite::freeSprite(R_SPRITELIST *spritelist) { free(spritelist->offset_list); free(spritelist); - return R_SUCCESS; + return SUCCESS; } -int Sprite::draw(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_num, int spr_x, int spr_y) { +int Sprite::draw(SURFACE *ds, SPRITELIST *sprite_list, int sprite_num, int spr_x, int spr_y) { int offset; int offset_idx; byte *sprite_p; @@ -187,7 +187,7 @@ int Sprite::draw(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_num, int s int y_align; if (!_initialized) { - return R_FAILURE; + return FAILURE; } offset = sprite_list->offset_list[sprite_num].offset; @@ -244,10 +244,10 @@ int Sprite::draw(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_num, int s src_row_p += s_width; } - return R_SUCCESS; + return SUCCESS; } -int Sprite::drawOccluded(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_num, int spr_x, int spr_y) { +int Sprite::drawOccluded(SURFACE *ds, SPRITELIST *sprite_list, int sprite_num, int spr_x, int spr_y) { int offset; int offset_idx; byte *sprite_p; @@ -263,14 +263,14 @@ int Sprite::drawOccluded(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_nu int s_height; int x_align; int y_align; - int z_lut[R_SPRITE_ZMAX]; + int z_lut[SPRITE_ZMAX]; int e_slope; // Clipinfo variables Point spr_pt; Rect spr_src_rect; Rect spr_dst_rect; - R_CLIPINFO ci; + CLIPINFO ci; // BG mask variables int mask_w; @@ -285,7 +285,7 @@ int Sprite::drawOccluded(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_nu int actor_z; if (!_initialized) { - return R_FAILURE; + return FAILURE; } if (!_vm->_scene->isBGMaskPresent()) { @@ -294,7 +294,7 @@ int Sprite::drawOccluded(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_nu if (sprite_num >= sprite_list->sprite_count) { warning("Invalid sprite number (%d) for sprite list %d", sprite_num, sprite_list->slist_rn); - return R_FAILURE; + return FAILURE; } // Get sprite data from list @@ -321,7 +321,7 @@ int Sprite::drawOccluded(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_nu e_slope = zinfo.endSlope; - for (i = 0; i < R_SPRITE_ZMAX; i++) { + for (i = 0; i < SPRITE_ZMAX; i++) { z_lut[i] = (int)(e_slope + ((137.0 - e_slope) / 14.0) * (15.0 - i)); } @@ -352,7 +352,7 @@ int Sprite::drawOccluded(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_nu _vm->_gfx->getClipInfo(&ci); if (ci.nodraw) { - return R_SUCCESS; + return SUCCESS; } decodeRLESprite(sprite_data_p, 64000, _decodeBuf, s_width * s_height); @@ -369,7 +369,7 @@ int Sprite::drawOccluded(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_nu mask_p = mask_row_p; for (x = 0; x < ci.draw_w; x++) { if (*src_p != 0) { - mask_z = *mask_p & R_SPRITE_ZMASK; + mask_z = *mask_p & SPRITE_ZMASK; if (actor_z > z_lut[mask_z]) { *dst_p = *src_p; } @@ -390,7 +390,7 @@ int Sprite::drawOccluded(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_nu _vm->textDraw(2, ds, buf, spr_x - x_align, spr_y - y_align, 255, 0, FONT_OUTLINE); } */ - return R_SUCCESS; + return SUCCESS; } int Sprite::decodeRLESprite(const byte *inbuf, size_t inbuf_len, byte *outbuf, size_t outbuf_len) { @@ -446,7 +446,7 @@ int Sprite::decodeRLESprite(const byte *inbuf, size_t inbuf_len, byte *outbuf, s } } - return R_SUCCESS; + return SUCCESS; } } // End of namespace Saga diff --git a/saga/sprite.h b/saga/sprite.h index ca5c2d8630..5ec28a74c5 100644 --- a/saga/sprite.h +++ b/saga/sprite.h @@ -28,14 +28,14 @@ namespace Saga { -#define R_APPENDMAX 4 +#define APPENDMAX 4 -#define R_SPRITE_ZMAX 16 -#define R_SPRITE_ZMASK 0x0F +#define SPRITE_ZMAX 16 +#define SPRITE_ZMASK 0x0F -#define R_DECODE_BUF_LEN 64000 +#define DECODE_BUF_LEN 64000 -struct R_SPRITELIST_ENTRY { +struct SPRITELIST_ENTRY { int x_align; int y_align; int width; @@ -43,17 +43,17 @@ struct R_SPRITELIST_ENTRY { }; -struct R_SPRITELIST_OFFSET { +struct SPRITELIST_OFFSET { uint16 data_idx; size_t offset; }; -struct R_SPRITELIST { +struct SPRITELIST { int append_count; int sprite_count; - R_SPRITELIST_OFFSET *offset_list; + SPRITELIST_OFFSET *offset_list; int slist_rn; - byte *sprite_data[R_APPENDMAX]; + byte *sprite_data[APPENDMAX]; }; @@ -61,19 +61,19 @@ class Sprite { public: Sprite(SagaEngine *vm); ~Sprite(void); - int loadList(int resource_num, R_SPRITELIST **sprite_list_p); - int appendList(int resource_num, R_SPRITELIST *spritelist); - int getListLen(R_SPRITELIST *spritelist); - int freeSprite(R_SPRITELIST *spritelist); - int draw(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_num, int spr_x, int spr_y); - int drawOccluded(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_num, int spr_x, int spr_y); + int loadList(int resource_num, SPRITELIST **sprite_list_p); + int appendList(int resource_num, SPRITELIST *spritelist); + int getListLen(SPRITELIST *spritelist); + int freeSprite(SPRITELIST *spritelist); + int draw(SURFACE *ds, SPRITELIST *sprite_list, int sprite_num, int spr_x, int spr_y); + int drawOccluded(SURFACE *ds, SPRITELIST *sprite_list, int sprite_num, int spr_x, int spr_y); private: int decodeRLESprite(const byte *inbuf, size_t inbuf_len, byte *outbuf, size_t outbuf_len); SagaEngine *_vm; bool _initialized; - R_RSCFILE_CONTEXT *_spriteContext; + RSCFILE_CONTEXT *_spriteContext; byte *_decodeBuf; size_t _decodeBufLen; }; diff --git a/saga/sthread.cpp b/saga/sthread.cpp index f8f6edb747..c8be77c7fc 100644 --- a/saga/sthread.cpp +++ b/saga/sthread.cpp @@ -35,21 +35,21 @@ namespace Saga { -void Script::setFramePtr(R_SCRIPT_THREAD *thread, int newPtr) { +void Script::setFramePtr(SCRIPT_THREAD *thread, int newPtr) { thread->framePtr = newPtr; dataBuffer(3)->len = ARRAYSIZE(thread->stackBuf) - thread->framePtr; dataBuffer(3)->data = (SDataWord_T *) &(thread->stackBuf[newPtr]); } -R_SCRIPT_THREAD *Script::SThreadCreate() { +SCRIPT_THREAD *Script::SThreadCreate() { YS_DL_NODE *new_node; - R_SCRIPT_THREAD *new_thread; + SCRIPT_THREAD *new_thread; if (!isInitialized()) { return NULL; } - new_thread = (R_SCRIPT_THREAD *)calloc(1, sizeof *new_thread); + new_thread = (SCRIPT_THREAD *)calloc(1, sizeof *new_thread); if (new_thread == NULL) { return NULL; } @@ -57,7 +57,7 @@ R_SCRIPT_THREAD *Script::SThreadCreate() { new_node = ys_dll_add_head(threadList(), new_thread, sizeof *new_thread); free(new_thread); - new_thread = (R_SCRIPT_THREAD *)ys_dll_get_data(new_node); + new_thread = (SCRIPT_THREAD *)ys_dll_get_data(new_node); new_thread->stackPtr = ARRAYSIZE(new_thread->stackBuf) - 1; setFramePtr(new_thread, new_thread->stackPtr); @@ -71,31 +71,31 @@ R_SCRIPT_THREAD *Script::SThreadCreate() { return new_thread; } -int Script::SThreadDestroy(R_SCRIPT_THREAD *thread) { +int Script::SThreadDestroy(SCRIPT_THREAD *thread) { YS_DL_NODE *walk_p; - R_SCRIPT_THREAD *th; + SCRIPT_THREAD *th; if (thread == NULL) { - return R_FAILURE; + return FAILURE; } for (walk_p = ys_dll_head(threadList()); walk_p != NULL; walk_p = ys_dll_next(walk_p)) { - th = (R_SCRIPT_THREAD *)ys_dll_get_data(walk_p); + th = (SCRIPT_THREAD *)ys_dll_get_data(walk_p); if (thread == th) { ys_dll_delete(walk_p); break; } } - return R_SUCCESS; + return SUCCESS; } int Script::SThreadExecThreads(uint msec) { YS_DL_NODE *walk_p, *next_p; - R_SCRIPT_THREAD *thread; + SCRIPT_THREAD *thread; if (!isInitialized()) { - return R_FAILURE; + return FAILURE; } walk_p = ys_dll_head(threadList()); @@ -103,7 +103,7 @@ int Script::SThreadExecThreads(uint msec) { while (walk_p != NULL) { next_p = ys_dll_next(walk_p); - thread = (R_SCRIPT_THREAD *)ys_dll_get_data(walk_p); + thread = (SCRIPT_THREAD *)ys_dll_get_data(walk_p); if (thread->flags & (kTFlagFinished | kTFlagAborted)) { //if (thread->flags & kTFlagFinished) // FIXME. Missing function @@ -134,7 +134,7 @@ int Script::SThreadExecThreads(uint msec) { walk_p = next_p; } - return R_SUCCESS; + return SUCCESS; } void Script::SThreadCompleteThread(void) { @@ -142,8 +142,8 @@ void Script::SThreadCompleteThread(void) { SThreadExecThreads(0); } -int Script::SThreadSetEntrypoint(R_SCRIPT_THREAD *thread, int ep_num) { - R_SCRIPT_BYTECODE *bytecode; +int Script::SThreadSetEntrypoint(SCRIPT_THREAD *thread, int ep_num) { + SCRIPT_BYTECODE *bytecode; int max_entrypoint; assert(isInitialized()); @@ -152,20 +152,20 @@ int Script::SThreadSetEntrypoint(R_SCRIPT_THREAD *thread, int ep_num) { max_entrypoint = bytecode->n_entrypoints; if ((ep_num < 0) || (ep_num >= max_entrypoint)) { - return R_FAILURE; + return FAILURE; } thread->ep_num = ep_num; thread->ep_offset = bytecode->entrypoints[ep_num].offset; - return R_SUCCESS; + return SUCCESS; } -int Script::SThreadExecute(R_SCRIPT_THREAD *thread, int ep_num) { +int Script::SThreadExecute(SCRIPT_THREAD *thread, int ep_num) { assert(isInitialized()); if ((currentScript() == NULL) || (!currentScript()->loaded)) { - return R_FAILURE; + return FAILURE; } SThreadSetEntrypoint(thread, ep_num); @@ -173,7 +173,7 @@ int Script::SThreadExecute(R_SCRIPT_THREAD *thread, int ep_num) { thread->i_offset = thread->ep_offset; thread->flags = kTFlagNone; - return R_SUCCESS; + return SUCCESS; } void Script::SThreadAbortAll(void) { @@ -186,7 +186,7 @@ void Script::SThreadAbortAll(void) { _vm->_script->SThreadExecThreads(0); } -unsigned char *Script::SThreadGetReadPtr(R_SCRIPT_THREAD *thread) { +unsigned char *Script::SThreadGetReadPtr(SCRIPT_THREAD *thread) { return currentScript()->bytecode->bytecode_p + thread->i_offset; } @@ -194,24 +194,24 @@ unsigned long Script::SThreadGetReadOffset(const byte *read_p) { return (unsigned long)(read_p - (unsigned char *)currentScript()->bytecode->bytecode_p); } -size_t Script::SThreadGetReadLen(R_SCRIPT_THREAD *thread) { +size_t Script::SThreadGetReadLen(SCRIPT_THREAD *thread) { return currentScript()->bytecode->bytecode_len - thread->i_offset; } -int Script::SThreadHoldSem(R_SEMAPHORE *sem) { +int Script::SThreadHoldSem(SEMAPHORE *sem) { if (sem == NULL) { - return R_FAILURE; + return FAILURE; } sem->hold_count++; - return R_SUCCESS; + return SUCCESS; } -int Script::SThreadReleaseSem(R_SEMAPHORE *sem) { +int Script::SThreadReleaseSem(SEMAPHORE *sem) { if (sem == NULL) { - return R_FAILURE; + return FAILURE; } sem->hold_count--; @@ -219,7 +219,7 @@ int Script::SThreadReleaseSem(R_SEMAPHORE *sem) { sem->hold_count = 0; } - return R_SUCCESS; + return SUCCESS; } int Script::SThreadDebugStep() { @@ -227,10 +227,10 @@ int Script::SThreadDebugStep() { _dbg_dostep = 1; } - return R_SUCCESS; + return SUCCESS; } -int Script::SThreadRun(R_SCRIPT_THREAD *thread, int instr_limit) { +int Script::SThreadRun(SCRIPT_THREAD *thread, int instr_limit) { int instr_count; uint32 saved_offset; SDataWord_T param1; @@ -256,7 +256,7 @@ int Script::SThreadRun(R_SCRIPT_THREAD *thread, int instr_limit) { instr_limit = 1; _dbg_dostep = 0; } else { - return R_SUCCESS; + return SUCCESS; } } @@ -382,7 +382,7 @@ int Script::SThreadRun(R_SCRIPT_THREAD *thread, int instr_limit) { n_args = scriptS.readByte(); func_num = scriptS.readUint16LE(); - if (func_num >= R_SFUNC_NUM) { + if (func_num >= SFUNC_NUM) { _vm->_console->print(S_ERROR_PREFIX "Invalid script function number: (%X)\n", func_num); thread->flags |= kTFlagAborted; break; @@ -398,7 +398,7 @@ int Script::SThreadRun(R_SCRIPT_THREAD *thread, int instr_limit) { } } else { sfuncRetVal = (this->*sfunc)(thread); - if (sfuncRetVal != R_SUCCESS) { + if (sfuncRetVal != SUCCESS) { _vm->_console->print(S_WARN_PREFIX "%X: Script function %d failed.\n", thread->i_offset, func_num); } @@ -835,7 +835,7 @@ int Script::SThreadRun(R_SCRIPT_THREAD *thread, int instr_limit) { } } - return R_SUCCESS; + return SUCCESS; } } // End of namespace Saga diff --git a/saga/text.cpp b/saga/text.cpp index f218ec98bd..f48ab11806 100644 --- a/saga/text.cpp +++ b/saga/text.cpp @@ -33,7 +33,7 @@ namespace Saga { -int SagaEngine::textDraw(int font_id, R_SURFACE *ds, const char *string, int text_x, int text_y, int color, +int SagaEngine::textDraw(int font_id, SURFACE *ds, const char *string, int text_x, int text_y, int color, int effect_color, int flags) { int string_w; int string_len; @@ -55,34 +55,34 @@ int SagaEngine::textDraw(int font_id, R_SURFACE *ds, const char *string, int tex if (flags & FONT_CENTERED) { // 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; + if (text_x < TEXT_CENTERLIMIT) { + text_x = TEXT_CENTERLIMIT; } - if (text_x > ds->buf_w - R_TEXT_CENTERLIMIT) { - text_x = ds->buf_w - R_TEXT_CENTERLIMIT; + if (text_x > ds->buf_w - TEXT_CENTERLIMIT) { + text_x = ds->buf_w - TEXT_CENTERLIMIT; } - if (text_x < (R_TEXT_MARGIN * 2)) { + if (text_x < (TEXT_MARGIN * 2)) { // Text can't be centered if it's too close to the margin - return R_FAILURE; + return FAILURE; } string_w = _font->getStringWidth(font_id, string, string_len, flags); if (text_x < (ds->buf_w / 2)) { // Fit to right side - fit_w = (text_x - R_TEXT_MARGIN) * 2; + fit_w = (text_x - TEXT_MARGIN) * 2; } else { // Fit to left side - fit_w = ((ds->buf_w - R_TEXT_MARGIN) - text_x) * 2; + fit_w = ((ds->buf_w - TEXT_MARGIN) - text_x) * 2; } if (fit_w >= string_w) { // 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); - return R_SUCCESS; + return SUCCESS; } // String won't fit on one line @@ -112,13 +112,13 @@ int SagaEngine::textDraw(int font_id, R_SURFACE *ds, const char *string, int tex // This word won't fit if (wc == 0) { // The first word in the line didn't fit. abort - return R_SUCCESS; + return 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); - text_y += h + R_TEXT_LINESPACING; + text_y += h + TEXT_LINESPACING; w_total = 0; len_total = 0; wc = 0; @@ -133,7 +133,7 @@ int SagaEngine::textDraw(int font_id, R_SURFACE *ds, const char *string, int tex // 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; + return SUCCESS; } search_p = measure_p + 1; } @@ -143,13 +143,13 @@ int SagaEngine::textDraw(int font_id, R_SURFACE *ds, const char *string, int tex _font->draw(font_id, ds, string, string_len, text_x, text_y, color, effect_color, flags); } - return R_SUCCESS; + return SUCCESS; } -R_TEXTLIST *SagaEngine::textCreateList() { - R_TEXTLIST *new_textlist; +TEXTLIST *SagaEngine::textCreateList() { + TEXTLIST *new_textlist; - new_textlist = (R_TEXTLIST *)malloc(sizeof *new_textlist); + new_textlist = (TEXTLIST *)malloc(sizeof *new_textlist); if (new_textlist == NULL) { return NULL; @@ -165,7 +165,7 @@ R_TEXTLIST *SagaEngine::textCreateList() { return new_textlist; } -void SagaEngine::textClearList(R_TEXTLIST *tlist) { +void SagaEngine::textClearList(TEXTLIST *tlist) { if (tlist != NULL) { ys_dll_delete_all(tlist->list); } @@ -173,7 +173,7 @@ void SagaEngine::textClearList(R_TEXTLIST *tlist) { return; } -void SagaEngine::textDestroyList(R_TEXTLIST *tlist) { +void SagaEngine::textDestroyList(TEXTLIST *tlist) { if (tlist != NULL) { ys_dll_destroy(tlist->list); } @@ -182,31 +182,31 @@ void SagaEngine::textDestroyList(R_TEXTLIST *tlist) { return; } -int SagaEngine::textDrawList(R_TEXTLIST *textlist, R_SURFACE *ds) { - R_TEXTLIST_ENTRY *entry_p; +int SagaEngine::textDrawList(TEXTLIST *textlist, SURFACE *ds) { + 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)) { - entry_p = (R_TEXTLIST_ENTRY *)ys_dll_get_data(walk_p); + entry_p = (TEXTLIST_ENTRY *)ys_dll_get_data(walk_p); if (entry_p->display != 0) { textDraw(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; + return SUCCESS; } -int SagaEngine::textProcessList(R_TEXTLIST *textlist, long ms) { - R_TEXTLIST_ENTRY *entry_p; +int SagaEngine::textProcessList(TEXTLIST *textlist, long ms) { + 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) { temp_p = ys_dll_next(walk_p); - entry_p = (R_TEXTLIST_ENTRY *)ys_dll_get_data(walk_p); + entry_p = (TEXTLIST_ENTRY *)ys_dll_get_data(walk_p); if (entry_p->flags & TEXT_TIMEOUT) { entry_p->time -= ms; if (entry_p->time <= 0) { @@ -215,34 +215,34 @@ int SagaEngine::textProcessList(R_TEXTLIST *textlist, long ms) { } } - return R_SUCCESS; + return SUCCESS; } -R_TEXTLIST_ENTRY *SagaEngine::textAddEntry(R_TEXTLIST *textlist, R_TEXTLIST_ENTRY *entry) { +TEXTLIST_ENTRY *SagaEngine::textAddEntry(TEXTLIST *textlist, TEXTLIST_ENTRY *entry) { YS_DL_NODE *new_node = NULL; if (entry != NULL) { new_node = ys_dll_add_tail(textlist->list, entry, sizeof *entry); } - return (new_node != NULL) ? (R_TEXTLIST_ENTRY *)new_node->data : NULL; + return (new_node != NULL) ? (TEXTLIST_ENTRY *)new_node->data : NULL; } -int SagaEngine::textSetDisplay(R_TEXTLIST_ENTRY *entry, int val) { +int SagaEngine::textSetDisplay(TEXTLIST_ENTRY *entry, int val) { if (entry != NULL) { entry->display = !!val; - return R_SUCCESS; + return SUCCESS; } - return R_FAILURE; + return FAILURE; } -int SagaEngine::textDeleteEntry(R_TEXTLIST *textlist, R_TEXTLIST_ENTRY *entry) { +int SagaEngine::textDeleteEntry(TEXTLIST *textlist, TEXTLIST_ENTRY *entry) { YS_DL_NODE *walk_p; if (entry == NULL) { - return R_FAILURE; + return FAILURE; } for (walk_p = ys_dll_head(textlist->list); walk_p != NULL; walk_p = ys_dll_next(walk_p)) { @@ -252,7 +252,7 @@ int SagaEngine::textDeleteEntry(R_TEXTLIST *textlist, R_TEXTLIST_ENTRY *entry) { } } - return R_SUCCESS; + return SUCCESS; } } // End of namespace Saga diff --git a/saga/text.h b/saga/text.h index 1bdcf3c5f1..f56113f278 100644 --- a/saga/text.h +++ b/saga/text.h @@ -30,21 +30,21 @@ namespace Saga { -#define R_TEXT_CENTERLIMIT 50 -#define R_TEXT_MARGIN 10 -#define R_TEXT_LINESPACING 2 +#define TEXT_CENTERLIMIT 50 +#define TEXT_MARGIN 10 +#define TEXT_LINESPACING 2 -struct R_TEXTLIST { +struct TEXTLIST { YS_DL_LIST *list; }; -enum R_TEXT_FLAGS { +enum TEXT_FLAGS { TEXT_TIMEOUT = 0x01 }; -struct R_TEXTLIST_ENTRY { - R_TEXTLIST_ENTRY *next; - R_TEXTLIST_ENTRY *prev; +struct TEXTLIST_ENTRY { + TEXTLIST_ENTRY *next; + TEXTLIST_ENTRY *prev; int display; int id; int text_x; @@ -55,7 +55,7 @@ struct R_TEXTLIST_ENTRY { int font_id; long time; const char *string; - R_TEXTLIST_ENTRY() { memset(this, 0, sizeof(*this)); } + TEXTLIST_ENTRY() { memset(this, 0, sizeof(*this)); } }; |