diff options
author | Paweł Kołodziejski | 2004-05-01 06:50:20 +0000 |
---|---|---|
committer | Paweł Kołodziejski | 2004-05-01 06:50:20 +0000 |
commit | 7792c3fd5ec79067262415685b3125d41cc37688 (patch) | |
tree | 3d189d1105bc90d3750f50a4cb9f45a8140598dc /saga | |
parent | e8cb50e17fc15270ee493f8c1b1623c20e47071e (diff) | |
download | scummvm-rg350-7792c3fd5ec79067262415685b3125d41cc37688.tar.gz scummvm-rg350-7792c3fd5ec79067262415685b3125d41cc37688.tar.bz2 scummvm-rg350-7792c3fd5ec79067262415685b3125d41cc37688.zip |
indent
svn-id: r13691
Diffstat (limited to 'saga')
-rw-r--r-- | saga/events.cpp | 293 | ||||
-rw-r--r-- | saga/events.h | 17 | ||||
-rw-r--r-- | saga/events_mod.h | 78 |
3 files changed, 95 insertions, 293 deletions
diff --git a/saga/events.cpp b/saga/events.cpp index 3db350da08..5cc1b5e072 100644 --- a/saga/events.cpp +++ b/saga/events.cpp @@ -20,23 +20,15 @@ * $Header$ * */ -/* - Description: - - Event management module +// Event management module - Notes: -*/ #include "saga.h" #include "reinherit.h" #include "yslib.h" -/* - * Uses the following modules: -\*--------------------------------------------------------------------------*/ #include "animation_mod.h" #include "console_mod.h" #include "scene_mod.h" @@ -49,9 +41,6 @@ #include "sndres.h" #include "music.h" -/* - * Begin module -\*--------------------------------------------------------------------------*/ #include "events_mod.h" #include "events.h" @@ -59,31 +48,22 @@ namespace Saga { static YS_DL_LIST *EventList; -int EVENT_Init(void) -{ +int EVENT_Init() { R_printf(R_STDOUT, "Initializing event subsystem...\n"); - EventList = ys_dll_create(); - return (EventList != NULL) ? R_SUCCESS : R_FAILURE; } -int EVENT_Shutdown(void) -{ +int EVENT_Shutdown() { R_printf(R_STDOUT, "Shutting down event subsystem...\n"); - EVENT_FreeList(); - return R_SUCCESS; } -int EVENT_HandleEvents(long msec) -/*--------------------------------------------------------------------------*\ - * Function to process event list once per frame. - * First advances event times, then processes each event with the appropriate - * handler depending on the type of event. -\*--------------------------------------------------------------------------*/ -{ +// Function to process event list once per frame. +// First advances event times, then processes each event with the appropriate +// handler depending on the type of event. +int EVENT_HandleEvents(long msec) { YS_DL_NODE *walk_node; YS_DL_NODE *next_node; @@ -92,21 +72,17 @@ int EVENT_HandleEvents(long msec) long delta_time; int result; - /* Advance event times - * \*------------------------------------------------------------- */ + // Advance event times ProcessEventTime(msec); - /* Process each event in list - * \*------------------------------------------------------------- */ - for (walk_node = ys_dll_head(EventList); - walk_node != NULL; walk_node = next_node) { - + // 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); - /* Save next event in case current event is handled and removed */ + // Save next event in case current event is handled and removed next_node = ys_dll_next(walk_node); - /* Call the appropriate event handler for the specific event type */ + // Call the appropriate event handler for the specific event type switch (event_p->type) { case R_ONESHOT_EVENT: @@ -123,27 +99,23 @@ int EVENT_HandleEvents(long msec) default: result = R_EVENT_INVALIDCODE; - R_printf(R_STDERR, - "Invalid event code encountered.\n"); + R_printf(R_STDERR, "Invalid event code encountered.\n"); break; } - /* Process the event appropriately based on result code from - * handler */ - if ((result == R_EVENT_DELETE) || - (result == R_EVENT_INVALIDCODE)) { - - /* If there is no event chain, delete the base event. */ + // Process the event appropriately based on result code from + // handler + if ((result == R_EVENT_DELETE) || (result == R_EVENT_INVALIDCODE)) { + // If there is no event chain, delete the base event. if (event_p->chain == NULL) { ys_dll_delete(walk_node); } else { - /* If there is an event chain present, move the next event - * in the chain up, adjust it by the previous delta time, - * and reprocess the event by adjusting next_node. */ + // If there is an event chain present, move the next event + // in the chain up, adjust it by the previous delta time, + // and reprocess the event by adjusting next_node. */ delta_time = event_p->time; - ys_dll_replace(walk_node, event_p->chain, - sizeof *event_p); + ys_dll_replace(walk_node, event_p->chain, sizeof *event_p); event_p = (R_EVENT *)ys_dll_get_data(walk_node); event_p->time += delta_time; @@ -151,19 +123,15 @@ int EVENT_HandleEvents(long msec) next_node = walk_node; } } else if (result == R_EVENT_BREAK) { - break; } - - } /* end for () */ + } return R_SUCCESS; } -int HandleContinuous(R_EVENT * event) -{ - - double event_pc = 0.0; /* Event completion percentage */ +int HandleContinuous(R_EVENT *event) { + double event_pc = 0.0; // Event completion percentage int event_done = 0; R_BUFFER_INFO buf_info; @@ -173,93 +141,64 @@ int HandleContinuous(R_EVENT * event) event_pc = ((double)event->duration - event->time) / event->duration; if (event_pc >= 1.0) { - /* Cap percentage to 100 */ + // Cap percentage to 100 event_pc = 1.0; event_done = 1; } if (event_pc < 0.0) { - /* Event not signaled, skip it */ + // Event not signaled, skip it return R_EVENT_CONTINUE; } else if (!(event->code & R_SIGNALED)) { - /* Signal event */ + // Signal event event->code |= R_SIGNALED; event_pc = 0.0; } switch (event->code & R_EVENT_MASK) { - case R_PAL_EVENT: - switch (event->op) { - case EVENT_BLACKTOPAL: - back_buf = SYSGFX_GetBackBuffer(); - SYSGFX_BlackToPal(back_buf, (PALENTRY *)event->data, event_pc); break; case EVENT_PALTOBLACK: - back_buf = SYSGFX_GetBackBuffer(); - SYSGFX_PalToBlack(back_buf, (PALENTRY *)event->data, event_pc); break; - default: break; - } /* end switch() */ - + } break; - case R_TRANSITION_EVENT: - switch (event->op) { - case EVENT_DISSOLVE: - RENDER_GetBufferInfo(&buf_info); SCENE_GetBGInfo(&bg_info); - - TRANSITION_Dissolve(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_p, 0, event_pc); - + TRANSITION_Dissolve(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_p, 0, event_pc); break; - default: break; } - break; - case R_CONSOLE_EVENT: - switch (event->op) { - case EVENT_ACTIVATE: - CON_DropConsole(event_pc); break; - case EVENT_DEACTIVATE: - CON_RaiseConsole(event_pc); break; - default: break; } - break; - default: break; - } /* end switch( event->event_code ) */ + } if (event_done) { return R_EVENT_DELETE; @@ -268,9 +207,7 @@ int HandleContinuous(R_EVENT * event) return R_EVENT_CONTINUE; } -static int HandleOneShot(R_EVENT * event) -{ - +static int HandleOneShot(R_EVENT *event) { R_SURFACE *back_buf; static SCENE_BGINFO bginfo; @@ -279,46 +216,32 @@ static int HandleOneShot(R_EVENT * event) return R_EVENT_CONTINUE; } - /* Event has been signaled */ + // Event has been signaled switch (event->code & R_EVENT_MASK) { - case R_TEXT_EVENT: - switch (event->op) { - case EVENT_DISPLAY: - TEXT_SetDisplay((R_TEXTLIST_ENTRY *)event->data, 1); break; - case EVENT_REMOVE: { R_SCENE_INFO scene_info; - SCENE_GetInfo(&scene_info); - - TEXT_DeleteEntry(scene_info.text_list, - (R_TEXTLIST_ENTRY *)event->data); + TEXT_DeleteEntry(scene_info.text_list, (R_TEXTLIST_ENTRY *)event->data); } break; - default: break; } break; - case R_VOICE_EVENT: - _vm->_sndRes->playVoice(event->param); break; - case R_MUSIC_EVENT: - _vm->_music->play(event->param, event->param2); break; - case R_BG_EVENT: { R_BUFFER_INFO rbuf_info; @@ -334,115 +257,75 @@ static int HandleOneShot(R_EVENT * event) bg_pt.x = bginfo.bg_x; bg_pt.y = bginfo.bg_y; - GFX_BufToBuffer(rbuf_info.r_bg_buf, - rbuf_info.r_bg_buf_w, - rbuf_info.r_bg_buf_h, - bginfo.bg_buf, - bginfo.bg_w, bginfo.bg_h, NULL, &bg_pt); - + GFX_BufToBuffer(rbuf_info.r_bg_buf, rbuf_info.r_bg_buf_w, rbuf_info.r_bg_buf_h, + bginfo.bg_buf, bginfo.bg_w, bginfo.bg_h, NULL, &bg_pt); if (event->param == SET_PALETTE) { - PALENTRY *pal_p; - SCENE_GetBGPal(&pal_p); SYSGFX_SetPalette(back_buf, pal_p); } } } break; - case R_ANIM_EVENT: - switch (event->op) { - case EVENT_FRAME: - ANIM_Play(event->param, event->time); break; - default: break; } - break; - case R_SCENE_EVENT: - switch (event->op) { - case EVENT_END: - SCENE_Next(); - return R_EVENT_BREAK; break; - default: break; } - break; - case R_PALANIM_EVENT: - switch (event->op) { - case EVENT_CYCLESTART: - PALANIM_CycleStart(); break; - case EVENT_CYCLESTEP: - PALANIM_CycleStep(event->time); break; - default: break; } break; - case R_INTERFACE_EVENT: - switch (event->op) { - case EVENT_ACTIVATE: - INTERFACE_Activate(); break; - default: break; } - break; - default: break; - - } /* end switch( event->code ) */ + } return R_EVENT_DELETE; } -static int HandleInterval(R_EVENT * event) -{ +static int HandleInterval(R_EVENT *event) { YS_IGNORE_PARAM(event); - return R_EVENT_DELETE; } -R_EVENT *EVENT_Queue(R_EVENT * event) -/*--------------------------------------------------------------------------*\ - * Schedules an event in the event list; returns a pointer to the scheduled - * event suitable for chaining if desired. -\*--------------------------------------------------------------------------*/ -{ +// Schedules an event in the event list; returns a pointer to the scheduled +// event suitable for chaining if desired. +R_EVENT *EVENT_Queue(R_EVENT *event) { YS_DL_NODE *new_node; R_EVENT *queued_event; event->chain = NULL; - new_node = ys_dll_add_tail(EventList, event, sizeof *event); if (new_node == NULL) { @@ -456,55 +339,43 @@ R_EVENT *EVENT_Queue(R_EVENT * event) return queued_event; } -R_EVENT *EVENT_Chain(R_EVENT * head_event, R_EVENT * add_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) -\*--------------------------------------------------------------------------*/ -{ +// 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 *EVENT_Chain(R_EVENT *head_event, R_EVENT *add_event) { R_EVENT *walk_event; R_EVENT *new_event; - /* Allocate space for new event */ + // Allocate space for new event new_event = (R_EVENT *)malloc(sizeof *new_event); if (new_event == NULL) { return NULL; } - /* Copy event data to new event */ + // Copy event data to new event *new_event = *add_event; - /* Walk to end of chain */ - for (walk_event = head_event; - walk_event->chain != NULL; walk_event = walk_event->chain) { - + // Walk to end of chain + for (walk_event = head_event; walk_event->chain != NULL; walk_event = walk_event->chain) { continue; } - /* Place new event */ + // Place new event walk_event->chain = new_event; new_event->chain = NULL; - InitializeEvent(new_event); return new_event; } -static int InitializeEvent(R_EVENT * event) -{ - +static int InitializeEvent(R_EVENT *event) { switch (event->type) { - case R_ONESHOT_EVENT: break; - case R_CONTINUOUS_EVENT: event->time += event->duration; break; - case R_INTERVAL_EVENT: break; - default: return R_FAILURE; break; @@ -513,37 +384,25 @@ static int InitializeEvent(R_EVENT * event) return R_SUCCESS; } -int EVENT_ClearList(void) -/*--------------------------------------------------------------------------*\ - * Removes all events from the list except NODESTROY (engine) events -\*--------------------------------------------------------------------------*/ -{ +int EVENT_ClearList() { YS_DL_NODE *walk_node; YS_DL_NODE *next_node; - R_EVENT *chain_walk; R_EVENT *next_chain; - R_EVENT *event_p; - /* Walk down event list */ - for (walk_node = ys_dll_head(EventList); - walk_node != NULL; walk_node = next_node) { - + // 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); - /* Only remove events not marked R_NODESTROY (engine events) */ + // Only remove events not marked R_NODESTROY (engine events) if (!(event_p->code & R_NODESTROY)) { - - /* Remove any events chained off this one */ - for (chain_walk = event_p->chain; - chain_walk != NULL; chain_walk = next_chain) { - + // 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; free(chain_walk); } - ys_dll_delete(walk_node); } } @@ -551,34 +410,24 @@ int EVENT_ClearList(void) return R_SUCCESS; } -int EVENT_FreeList(void) -/*--------------------------------------------------------------------------*\ - * Removes all events from the list (even R_NODESTROY) -\*--------------------------------------------------------------------------*/ -{ +// Removes all events from the list (even R_NODESTROY) +int EVENT_FreeList() { YS_DL_NODE *walk_node; YS_DL_NODE *next_node; - R_EVENT *chain_walk; R_EVENT *next_chain; - R_EVENT *event_p; - /* Walk down event list */ - for (walk_node = ys_dll_head(EventList); - walk_node != NULL; walk_node = next_node) { - + // 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); - - /* Remove any events chained off current node */ - for (chain_walk = event_p->chain; - chain_walk != NULL; chain_walk = next_chain) { - + // 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; free(chain_walk); } - /* Delete current node */ + // Delete current node next_node = ys_dll_next(walk_node); ys_dll_delete(walk_node); } @@ -586,27 +435,19 @@ int EVENT_FreeList(void) return R_SUCCESS; } -static int ProcessEventTime(long msec) -/*--------------------------------------------------------------------------*\ - * Walks down the event list, updating event times by 'msec'. -\*--------------------------------------------------------------------------*/ -{ +// Walks down the event list, updating event times by 'msec'. +static int ProcessEventTime(long msec) { YS_DL_NODE *walk_node; R_EVENT *event_p; - uint16 event_count = 0; - for (walk_node = ys_dll_head(EventList); - walk_node != NULL; walk_node = ys_dll_next(walk_node)) { - + 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->time -= msec; - event_count++; if (event_count > R_EVENT_WARNINGCOUNT) { - R_printf(R_STDERR, - "WARNING: Event list exceeds %u.\n", R_EVENT_WARNINGCOUNT); + R_printf(R_STDERR, "WARNING: Event list exceeds %u.\n", R_EVENT_WARNINGCOUNT); } } diff --git a/saga/events.h b/saga/events.h index 75c670db2f..c2ae1a1d84 100644 --- a/saga/events.h +++ b/saga/events.h @@ -20,14 +20,8 @@ * $Header$ * */ -/* - Description: - - Event management module header file - - Notes: -*/ +// Event management module header file #ifndef SAGA_EVENT_H #define SAGA_EVENT_H @@ -35,13 +29,10 @@ namespace Saga { #define R_EVENT_DBGLVL R_DEBUG_NONE - #define R_EVENT_WARNINGCOUNT 1000 - #define R_EVENT_MASK 0x00FF enum R_EVENT_STATUSCODE { - R_EVENT_INVALIDCODE = 0, R_EVENT_DELETE, R_EVENT_CONTINUE, @@ -49,15 +40,11 @@ enum R_EVENT_STATUSCODE { }; static int HandleContinuous(R_EVENT * event); - static int HandleOneShot(R_EVENT * event); - static int HandleInterval(R_EVENT * event); - static int ProcessEventTime(long msec); - static int InitializeEvent(R_EVENT * event); } // End of namespace Saga -#endif /* R_EVENT_H */ +#endif diff --git a/saga/events_mod.h b/saga/events_mod.h index 2c7fb134a2..14327ce3e1 100644 --- a/saga/events_mod.h +++ b/saga/events_mod.h @@ -20,14 +20,8 @@ * $Header$ * */ -/* - Description: - - Event module public header - - Notes: -*/ +// Event module public header #ifndef SAGA_EVENTS_MOD_H #define SAGA_EVENTS_MOD_H @@ -35,20 +29,17 @@ namespace Saga { enum R_EVENT_TYPES { - R_ONESHOT_EVENT, R_CONTINUOUS_EVENT, R_INTERVAL_EVENT }; enum R_EVENT_FLAGS { - R_SIGNALED = 0x8000, R_NODESTROY = 0x4000 }; enum R_EVENT_CODES { - R_BG_EVENT = 1, R_ANIM_EVENT, R_MUSIC_EVENT, @@ -65,80 +56,63 @@ enum R_EVENT_CODES { }; enum R_EVENT_OPS { - - /* INSTANTANEOUS events - * \*------------------------------------------------------------- */ - /* BG events */ + // INSTANTANEOUS events + // BG events EVENT_DISPLAY = 1, - /* ANIM events */ + // ANIM events EVENT_FRAME = 1, - /* MUISC & SOUND events */ + // MUISC & SOUND events EVENT_PLAY = 1, EVENT_STOP = 2, - /* SCENE events */ + // SCENE events EVENT_END = 2, - /* TEXT events */ + // TEXT events EVENT_HIDE = 2, EVENT_REMOVE = 3, - /* PALANIM events */ + // PALANIM events EVENT_CYCLESTART = 1, EVENT_CYCLESTEP = 2, - /* INTERFACE events */ + // INTERFACE events EVENT_ACTIVATE = 1, EVENT_DEACTIVATE, - /* ACTOR events */ + // ACTOR events EVENT_MOVE = 1, - /* CONTINUOUS events - * \*------------------------------------------------------------- */ - /* PALETTE events */ + // CONTINUOUS events + // PALETTE events EVENT_PALTOBLACK = 1, EVENT_BLACKTOPAL = 2, - /* TRANSITION events */ + // TRANSITION events EVENT_DISSOLVE = 1 }; enum R_EVENT_PARAMS { - NO_SET_PALETTE, SET_PALETTE }; struct R_EVENT { - unsigned int type; - unsigned int code; /* Event operation category & flags */ - int op; /* Event operation */ - - long param; /* Optional event parameter */ + unsigned int code; // Event operation category & flags + int op; // Event operation + long param; // Optional event parameter long param2; - - void *data; /* Optional event data */ - - long time; /* Elapsed time until event */ - long duration; /* Duration of event */ + void *data; // Optional event data + long time; // Elapsed time until event + long duration; // Duration of event long d_reserved; - R_EVENT *chain; /* Event chain - * (For consecutive events) */ - + R_EVENT *chain; // Event chain (For consecutive events) R_EVENT() { memset(this, 0, sizeof(*this)); } - }; -int EVENT_Init(void); - -int EVENT_Shutdown(void); - +int EVENT_Init(); +int EVENT_Shutdown(); int EVENT_HandleEvents(long msec); - -int EVENT_ClearList(void); - -int EVENT_FreeList(void); - -R_EVENT *EVENT_Queue(R_EVENT * event); - -R_EVENT *EVENT_Chain(R_EVENT * head_event, R_EVENT * add_event); +int EVENT_ClearList(); +int EVENT_FreeList(); +R_EVENT *EVENT_Queue(R_EVENT *event); +R_EVENT *EVENT_Chain(R_EVENT *eead_event, R_EVENT *add_event); } // End of namespace Saga |