diff options
author | Eugene Sandulenko | 2004-08-04 20:28:57 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2004-08-04 20:28:57 +0000 |
commit | 51b5acfc9c30cf656d6ac380cc6cce7a1a9938ff (patch) | |
tree | 36f4ff2e5df7a51460701fda7f3597a3da307d99 | |
parent | 11078570dcd3a5be520cdc84223674411a08f088 (diff) | |
download | scummvm-rg350-51b5acfc9c30cf656d6ac380cc6cce7a1a9938ff.tar.gz scummvm-rg350-51b5acfc9c30cf656d6ac380cc6cce7a1a9938ff.tar.bz2 scummvm-rg350-51b5acfc9c30cf656d6ac380cc6cce7a1a9938ff.zip |
Move SCENE_* to class.
svn-id: r14463
-rw-r--r-- | saga/events.cpp | 14 | ||||
-rw-r--r-- | saga/ihnm_introproc.cpp | 12 | ||||
-rw-r--r-- | saga/ihnm_introproc.h | 6 | ||||
-rw-r--r-- | saga/input.cpp | 4 | ||||
-rw-r--r-- | saga/ite_introproc.cpp | 95 | ||||
-rw-r--r-- | saga/ite_introproc.h | 2 | ||||
-rw-r--r-- | saga/render.cpp | 8 | ||||
-rw-r--r-- | saga/saga.cpp | 11 | ||||
-rw-r--r-- | saga/saga.h | 2 | ||||
-rw-r--r-- | saga/scene.cpp | 638 | ||||
-rw-r--r-- | saga/scene.h | 147 | ||||
-rw-r--r-- | saga/scene_mod.h | 81 | ||||
-rw-r--r-- | saga/sdebug.cpp | 4 | ||||
-rw-r--r-- | saga/sprite.cpp | 8 |
14 files changed, 516 insertions, 516 deletions
diff --git a/saga/events.cpp b/saga/events.cpp index 47957fd2aa..ffa3f132a8 100644 --- a/saga/events.cpp +++ b/saga/events.cpp @@ -31,7 +31,7 @@ #include "saga/animation.h" #include "saga/console_mod.h" -#include "saga/scene_mod.h" +#include "saga/scene.h" #include "saga/interface_mod.h" #include "saga/text.h" #include "saga/palanim_mod.h" @@ -174,7 +174,7 @@ int HandleContinuous(R_EVENT *event) { switch (event->op) { case EVENT_DISSOLVE: _vm->_render->getBufferInfo(&buf_info); - SCENE_GetBGInfo(&bg_info); + _vm->_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); break; @@ -226,7 +226,7 @@ static int HandleOneShot(R_EVENT *event) { case EVENT_REMOVE: { R_SCENE_INFO scene_info; - SCENE_GetInfo(&scene_info); + _vm->_scene->getInfo(&scene_info); _vm->textDeleteEntry(scene_info.text_list, (R_TEXTLIST_ENTRY *)event->data); } break; @@ -246,12 +246,12 @@ static int HandleOneShot(R_EVENT *event) { R_BUFFER_INFO rbuf_info; R_POINT bg_pt; - if (SCENE_GetMode() == R_SCENE_MODE_NORMAL) { + if (_vm->_scene->getMode() == R_SCENE_MODE_NORMAL) { back_buf = _vm->_gfx->getBackBuffer(); _vm->_render->getBufferInfo(&rbuf_info); - SCENE_GetBGInfo(&bginfo); + _vm->_scene->getBGInfo(&bginfo); bg_pt.x = bginfo.bg_x; bg_pt.y = bginfo.bg_y; @@ -260,7 +260,7 @@ static int HandleOneShot(R_EVENT *event) { bginfo.bg_buf, bginfo.bg_w, bginfo.bg_h, NULL, &bg_pt); if (event->param == SET_PALETTE) { PALENTRY *pal_p; - SCENE_GetBGPal(&pal_p); + _vm->_scene->getBGPal(&pal_p); _vm->_gfx->setPalette(back_buf, pal_p); } } @@ -278,7 +278,7 @@ static int HandleOneShot(R_EVENT *event) { case R_SCENE_EVENT: switch (event->op) { case EVENT_END: - SCENE_Next(); + _vm->_scene->nextScene(); return R_EVENT_BREAK; break; default: diff --git a/saga/ihnm_introproc.cpp b/saga/ihnm_introproc.cpp index a630de0b02..025084e574 100644 --- a/saga/ihnm_introproc.cpp +++ b/saga/ihnm_introproc.cpp @@ -31,7 +31,6 @@ #include "saga/cvar_mod.h" #include "saga/events_mod.h" #include "saga/rscfile_mod.h" -#include "saga/scene_mod.h" #include "saga/palanim_mod.h" #include "saga/scene.h" @@ -39,6 +38,11 @@ namespace Saga { +int IHNM_IntroMovieProc1(int param, R_SCENE_INFO *scene_info); +int IHNM_IntroMovieProc2(int param, R_SCENE_INFO *scene_info); +int IHNM_IntroMovieProc3(int param, R_SCENE_INFO *scene_info); +int IHNM_HateProc(int param, R_SCENE_INFO *scene_info); + R_SCENE_RESLIST IHNM_IntroMovie1RL[] = { {30, SAGA_BG_IMAGE, 0, 0} , {31, SAGA_ANIM_1, 0, 0} @@ -97,7 +101,7 @@ int IHNM_StartProc() { n_introscenes = ARRAYSIZE(IHNM_IntroList); for (i = 0; i < n_introscenes; i++) { - SCENE_Queue(&IHNM_IntroList[i]); + _vm->_scene->queueScene(&IHNM_IntroList[i]); } return R_SUCCESS; @@ -159,7 +163,7 @@ int IHNM_IntroMovieProc2(int param, R_SCENE_INFO *scene_info) { q_event = EVENT_Chain(q_event, &event); // Fade in from black to the scene background palette - SCENE_GetBGPal(&pal); + _vm->_scene->getBGPal(&pal); event.type = R_CONTINUOUS_EVENT; event.code = R_PAL_EVENT; @@ -219,7 +223,7 @@ int IHNM_IntroMovieProc3(int param, R_SCENE_INFO *scene_info) { q_event = EVENT_Chain(q_event, &event); // Fade in from black to the scene background palette - SCENE_GetBGPal(&pal); + _vm->_scene->getBGPal(&pal); event.type = R_CONTINUOUS_EVENT; event.code = R_PAL_EVENT; diff --git a/saga/ihnm_introproc.h b/saga/ihnm_introproc.h index 64a997a2f6..55962b8f06 100644 --- a/saga/ihnm_introproc.h +++ b/saga/ihnm_introproc.h @@ -23,8 +23,8 @@ // Intro sequence scene procedures header file -#ifndef SAGA_ITE_INTRO_H_ -#define SAGA_ITE_INTRO_H_ +#ifndef SAGA_IHNM_INTRO_H_ +#define SAGA_IHNM_INTRO_H_ namespace Saga { @@ -33,6 +33,8 @@ namespace Saga { #define R_IHNM_DGLOGO_TIME 8000 #define R_IHNM_TITLE_TIME 16000 +int IHNM_StartProc(); + } // End of namespace Saga #endif diff --git a/saga/input.cpp b/saga/input.cpp index fb79972478..0bcb114e8b 100644 --- a/saga/input.cpp +++ b/saga/input.cpp @@ -27,7 +27,7 @@ #include "saga/console_mod.h" #include "saga/interface_mod.h" #include "saga/render.h" -#include "saga/scene_mod.h" +#include "saga/scene.h" #include "saga/script_mod.h" namespace Saga { @@ -106,7 +106,7 @@ int SYSINPUT_ProcessInput() { break; case 27: // Esc // Skip to next scene skip target - SCENE_Skip(); + _vm->_scene->skipScene(); break; default: break; diff --git a/saga/ite_introproc.cpp b/saga/ite_introproc.cpp index 22b1351106..fe383a0c4b 100644 --- a/saga/ite_introproc.cpp +++ b/saga/ite_introproc.cpp @@ -34,7 +34,6 @@ #include "saga/font.h" #include "saga/game_mod.h" #include "saga/rscfile_mod.h" -#include "saga/scene_mod.h" #include "saga/sndres.h" #include "saga/text.h" #include "saga/palanim_mod.h" @@ -45,6 +44,17 @@ namespace Saga { +int ITE_IntroAnimProc(int param, R_SCENE_INFO *scene_info); +int ITE_IntroCave1Proc(int param, R_SCENE_INFO *scene_info); +int ITE_IntroCave2Proc(int param, R_SCENE_INFO *scene_info); +int ITE_IntroCave3Proc(int param, R_SCENE_INFO *scene_info); +int ITE_IntroCave4Proc(int param, R_SCENE_INFO *scene_info); +int ITE_IntroValleyProc(int param, R_SCENE_INFO *scene_info); +int ITE_IntroTreeHouseProc(int param, R_SCENE_INFO *scene_info); +int ITE_IntroFairePathProc(int param, R_SCENE_INFO *scene_info); +int ITE_IntroFaireTentProc(int param, R_SCENE_INFO *scene_info); +int initialScene(int param, R_SCENE_INFO *scene_info); + static R_INTRO_DIALOGUE IntroDiag[] = { { CAVE_VOICE_0, "intro1a", @@ -135,7 +145,7 @@ int ITE_StartProc() { n_introscenes = ARRAYSIZE(ITE_IntroList); for (i = 0; i < n_introscenes; i++) { - SCENE_Queue(&ITE_IntroList[i]); + _vm->_scene->queueScene(&ITE_IntroList[i]); } GAME_GetSceneInfo(&gs_desc); @@ -145,7 +155,7 @@ int ITE_StartProc() { first_scene.scene_skiptarget = 1; first_scene.scene_proc = initialScene; - SCENE_Queue(&first_scene); + _vm->_scene->queueScene(&first_scene); return R_SUCCESS; } @@ -258,7 +268,7 @@ int ITE_IntroCave1Proc(int param, R_SCENE_INFO *scene_info) { q_event = EVENT_Chain(q_event, &event); // Fade in from black to the scene background palette - SCENE_GetBGPal(&pal); + _vm->_scene->getBGPal(&pal); event.type = R_CONTINUOUS_EVENT; event.code = R_PAL_EVENT; event.op = EVENT_BLACKTOPAL; @@ -987,4 +997,81 @@ int ITE_IntroFaireTentProc(int param, R_SCENE_INFO *scene_info) { return 0; } +int initialScene(int param, R_SCENE_INFO *scene_info) { + R_EVENT event; + R_EVENT *q_event; + int delay_time = 0; + static PALENTRY current_pal[R_PAL_ENTRIES]; + PALENTRY *pal; + + switch (param) { + case SCENE_BEGIN: + _vm->_music->stop(); + _vm->_sound->stopVoice(); + + // Fade palette to black from intro scene + _vm->_gfx->getCurrentPal(current_pal); + + event.type = R_CONTINUOUS_EVENT; + event.code = R_PAL_EVENT; + event.op = EVENT_PALTOBLACK; + event.time = 0; + event.duration = PALETTE_FADE_DURATION; + event.data = current_pal; + + delay_time += PALETTE_FADE_DURATION; + + q_event = EVENT_Queue(&event); + + // Activate user interface + event.type = R_ONESHOT_EVENT; + event.code = R_INTERFACE_EVENT; + event.op = EVENT_ACTIVATE; + event.time = 0; + + q_event = EVENT_Chain(q_event, &event); + + // Set first scene background w/o changing palette + event.type = R_ONESHOT_EVENT; + event.code = R_BG_EVENT; + event.op = EVENT_DISPLAY; + event.param = NO_SET_PALETTE; + event.time = 0; + + q_event = EVENT_Chain(q_event, &event); + + // Fade in to first scene background palette + _vm->_scene->getBGPal(&pal); + + event.type = R_CONTINUOUS_EVENT; + event.code = R_PAL_EVENT; + event.op = EVENT_BLACKTOPAL; + event.time = delay_time; + event.duration = PALETTE_FADE_DURATION; + event.data = pal; + + q_event = EVENT_Chain(q_event, &event); + + event.code = R_PALANIM_EVENT; + event.op = EVENT_CYCLESTART; + event.time = 0; + + q_event = EVENT_Chain(q_event, &event); + + _vm->_anim->setFlag(0, ANIM_LOOP); + _vm->_anim->play(0, delay_time); + + debug(0, "Scene started"); + break; + case SCENE_END: + break; + default: + warning("Scene::initialScene(): Illegal scene procedure parameter"); + break; + } + + return 0; +} + + } // End of namespace Saga diff --git a/saga/ite_introproc.h b/saga/ite_introproc.h index be259a633a..d919d91ced 100644 --- a/saga/ite_introproc.h +++ b/saga/ite_introproc.h @@ -75,6 +75,8 @@ struct INTRO_CREDIT { int font_id; }; +int ITE_StartProc(); + } // End of namespace Saga #endif /* SAGA_ITE_INTRO_H_ */ diff --git a/saga/render.cpp b/saga/render.cpp index 182698de59..2a5c88d4d5 100644 --- a/saga/render.cpp +++ b/saga/render.cpp @@ -31,7 +31,7 @@ #include "saga/font.h" #include "saga/game_mod.h" #include "saga/interface_mod.h" -#include "saga/scene_mod.h" +#include "saga/scene.h" #include "saga/text.h" #include "saga/actionmap.h" @@ -126,13 +126,13 @@ int Render::drawScene() { // Get mouse coordinates mouse_pt = SYSINPUT_GetMousePos(); - SCENE_GetBGInfo(&bg_info); + _vm->_scene->getBGInfo(&bg_info); GAME_GetDisplayInfo(&disp_info); bg_pt.x = 0; bg_pt.y = 0; // Display scene background - SCENE_Draw(backbuf_surface); + _vm->_scene->draw(backbuf_surface); // Display scene maps, if applicable if (getFlags() & RF_OBJECTMAP_TEST) { @@ -144,7 +144,7 @@ int Render::drawScene() { _vm->_actor->drawList(); // Draw queued text strings - SCENE_GetInfo(&scene_info); + _vm->_scene->getInfo(&scene_info); _vm->textDrawList(scene_info.text_list, backbuf_surface); diff --git a/saga/saga.cpp b/saga/saga.cpp index a8f196e215..5d5c019c19 100644 --- a/saga/saga.cpp +++ b/saga/saga.cpp @@ -48,7 +48,7 @@ #include "saga/isomap.h" #include "saga/script.h" #include "saga/script_mod.h" -#include "saga/scene_mod.h" +#include "saga/scene.h" #include "saga/sdata.h" #include "saga/sndres.h" #include "saga/sprite.h" @@ -109,7 +109,6 @@ void SagaEngine::go() { CON_Register(); // Register console cvars first GAME_Register(); - SCENE_Register(); _soundEnabled = 1; _musicEnabled = 1; @@ -148,8 +147,9 @@ void SagaEngine::go() { _sdata = new SData(); INTERFACE_Init(); // requires script module _actor = new Actor(this); + _scene = new Scene(this); - if (SCENE_Init() != R_SUCCESS) { + if (!_scene->initialized()) { warning("Couldn't initialize scene module"); return; } @@ -194,6 +194,7 @@ void SagaEngine::go() { debug(0, "Sound disabled."); } + _scene->reg(); _actor->reg(); _script->reg(); _render->reg(); @@ -205,7 +206,7 @@ void SagaEngine::go() { // Begin Main Engine Loop - SCENE_Start(); + _scene->startScene(); uint32 currentTicks; for (;;) { @@ -235,7 +236,7 @@ void SagaEngine::go() { } void SagaEngine::shutdown() { - SCENE_Shutdown(); + delete _scene; delete _actor; delete _script; delete _sprite; diff --git a/saga/saga.h b/saga/saga.h index ab26f0a1c5..4f163f0d07 100644 --- a/saga/saga.h +++ b/saga/saga.h @@ -54,6 +54,7 @@ class Script; class Actor; class Font; class Sprite; +class Scene; using Common::MemoryReadStream; @@ -110,6 +111,7 @@ public: Actor *_actor; Font *_font; Sprite *_sprite; + Scene *_scene; private: int decodeBGImageRLE(const byte *inbuf, size_t inbuf_len, byte *outbuf, size_t outbuf_len); diff --git a/saga/scene.cpp b/saga/scene.cpp index 4f52096e19..3cf7d9675e 100644 --- a/saga/scene.cpp +++ b/saga/scene.cpp @@ -43,22 +43,27 @@ #include "saga/sound.h" #include "saga/music.h" -#include "saga/scene_mod.h" #include "saga/scene.h" +#include "saga/ite_introproc.h" +#include "saga/ihnm_introproc.h" namespace Saga { -static R_SCENE_MODULE SceneModule; +static void CF_scenechange(int argc, char *argv[], void *refCon); +static void CF_sceneinfo(int argc, char *argv[], void *refCon); -int SCENE_Register() { - CVAR_Register_I(&SceneModule.scene_number, "scene", NULL, R_CVAR_READONLY, 0, 0); - CVAR_RegisterFunc(CF_scenechange, "scene_change", "<Scene number>", R_CVAR_NONE, 1, 1, NULL); - CVAR_RegisterFunc(CF_sceneinfo, "scene_info", NULL, R_CVAR_NONE, 0, 0, NULL); +int defaultScene(int param, R_SCENE_INFO *scene_info); + + +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); return R_SUCCESS; } -int SCENE_Init() { +Scene::Scene(SagaEngine *vm) : _vm(vm), _initialized(false) { R_GAME_SCENEDESC gs_desc; byte *scene_lut_p; size_t scene_lut_len; @@ -69,102 +74,113 @@ int SCENE_Init() { GAME_GetSceneInfo(&gs_desc); // Load scene module resource context - result = GAME_GetFileContext(&SceneModule.scene_ctxt, R_GAME_RESOURCEFILE, 0); + result = GAME_GetFileContext(&_sceneContext, R_GAME_RESOURCEFILE, 0); if (result != R_SUCCESS) { - warning("Couldn't load scene resource context"); - return R_FAILURE; + warning("Scene::Scene(): Couldn't load scene resource context"); + return; } // Initialize scene queue - SceneModule.scene_queue = ys_dll_create(); - if (SceneModule.scene_queue == NULL) { - return R_FAILURE; + _sceneQueue = ys_dll_create(); + if (_sceneQueue == NULL) { + return; } // Load scene lookup table - debug(0, "SCENE_Init(): Loading scene LUT from resource %u.", gs_desc.scene_lut_rn); - result = RSC_LoadResource(SceneModule.scene_ctxt, gs_desc.scene_lut_rn, &scene_lut_p, &scene_lut_len); + 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) { - warning("Error: couldn't load scene LUT"); - return R_FAILURE; + warning("Scene::Scene(): Error: couldn't load scene LUT"); + return; } - SceneModule.scene_count = scene_lut_len / 2; - SceneModule.scene_max = SceneModule.scene_count - 1; - SceneModule.scene_lut = (int *)malloc(SceneModule.scene_max * sizeof *SceneModule.scene_lut); - if (SceneModule.scene_lut == NULL) { - warning("SCENE_Init(): Memory allocation failed"); - return R_MEM; + _sceneCount = scene_lut_len / 2; + _sceneMax = _sceneCount - 1; + _sceneLUT = (int *)malloc(_sceneMax * sizeof *_sceneLUT); + if (_sceneLUT == NULL) { + warning("Scene::Scene(): Memory allocation failed"); + return; } MemoryReadStream readS(scene_lut_p, scene_lut_len); - for (i = 0; i < SceneModule.scene_max; i++) { - SceneModule.scene_lut[i] = readS.readUint16LE(); + for (i = 0; i < _sceneMax; i++) { + _sceneLUT[i] = readS.readUint16LE(); } free(scene_lut_p); if (gs_desc.first_scene != 0) { - SceneModule.first_scene = gs_desc.first_scene; + _firstScene = gs_desc.first_scene; } - debug(0, "SCENE_Init(): First scene set to %d.", SceneModule.first_scene); + debug(0, "First scene set to %d.", _firstScene); - debug(0, "SCENE_Init(): LUT has %d entries.", SceneModule.scene_max); + debug(0, "LUT has %d entries.", _sceneMax); // Create scene module text list - SceneModule.text_list = _vm->textCreateList(); + _textList = _vm->textCreateList(); - if (SceneModule.text_list == NULL) { - warning("Error: Couldn't create scene text list"); - return R_FAILURE; + if (_textList == NULL) { + warning("Scene::Scene(): Error: Couldn't create scene text list"); + return; } - SceneModule.init = 1; - - return R_SUCCESS; + _sceneLoaded = false; + _sceneMode = 0; + _sceneNumber = 0; + _sceneResNum = 0; + _inGame = false; + _loadDesc = false; + memset(&_desc, 0, sizeof(_desc)); + _resListEntries = 0; + _resList = NULL; + _animEntries = 0; + _animList = NULL; + _sceneProc = NULL; + memset(&_bg, 0, sizeof(_bg)); + memset(&_bgMask, 0, sizeof(_bgMask)); + + _initialized = true; } -int SCENE_Shutdown() { - if (SceneModule.init) { - SCENE_End(); - free(SceneModule.scene_lut); +Scene::~Scene() { + if (_initialized) { + endScene(); + free(_sceneLUT); } - - return R_SUCCESS; } -int SCENE_Queue(R_SCENE_QUEUE *scene_queue) { - assert(SceneModule.init); +int Scene::queueScene(R_SCENE_QUEUE *scene_queue) { + assert(_initialized); assert(scene_queue != NULL); - ys_dll_add_tail(SceneModule.scene_queue, scene_queue, sizeof *scene_queue); + ys_dll_add_tail(_sceneQueue, scene_queue, sizeof *scene_queue); return R_SUCCESS; } -int SCENE_ClearQueue() { - assert(SceneModule.init); +int Scene::clearSceneQueue() { + assert(_initialized); - ys_dll_delete_all(SceneModule.scene_queue); + ys_dll_delete_all(_sceneQueue); return R_SUCCESS; } -int SCENE_Start() { +int Scene::startScene() { YS_DL_NODE *node; R_SCENE_QUEUE *scene_qdat; - assert(SceneModule.init); + assert(_initialized); - if (SceneModule.scene_loaded) { - warning("Error: Can't start game...scene already loaded"); + if (_sceneLoaded) { + warning("Scene::start(): Error: Can't start game...scene already loaded"); return R_FAILURE; } - if (SceneModule.in_game) { - warning("Error: Can't start game...game already started"); + if (_inGame) { + warning("Scene::start(): Error: Can't start game...game already started"); return R_FAILURE; } @@ -176,12 +192,12 @@ int SCENE_Start() { IHNM_StartProc(); break; default: - warning("Error: Can't start game... gametype not supported"); + warning("Scene::start(): Error: Can't start game... gametype not supported"); break; } // Load the head node in scene queue - node = ys_dll_head(SceneModule.scene_queue); + node = ys_dll_head(_sceneQueue); if (node == NULL) { return R_SUCCESS; } @@ -189,31 +205,31 @@ int SCENE_Start() { scene_qdat = (R_SCENE_QUEUE *)ys_dll_get_data(node); assert(scene_qdat != NULL); - SCENE_Load(scene_qdat->scene_n, scene_qdat->load_flag, scene_qdat->scene_proc, scene_qdat->scene_desc); + loadScene(scene_qdat->scene_n, scene_qdat->load_flag, scene_qdat->scene_proc, scene_qdat->scene_desc); return R_SUCCESS; } -int SCENE_Next() { +int Scene::nextScene() { YS_DL_NODE *node; R_SCENE_QUEUE *scene_qdat; - assert(SceneModule.init); + assert(_initialized); - if (!SceneModule.scene_loaded) { - warning("Error: Can't advance scene...no scene loaded"); + if (!_sceneLoaded) { + warning("Scene::next(): Error: Can't advance scene...no scene loaded"); return R_FAILURE; } - if (SceneModule.in_game) { - warning("Error: Can't advance scene...game already started"); + if (_inGame) { + warning("Scene::next(): Error: Can't advance scene...game already started"); return R_FAILURE; } - SCENE_End(); + endScene(); // Delete the current head node in scene queue - node = ys_dll_head(SceneModule.scene_queue); + node = ys_dll_head(_sceneQueue); if (node == NULL) { return R_SUCCESS; } @@ -221,7 +237,7 @@ int SCENE_Next() { ys_dll_delete(node); // Load the head node in scene queue - node = ys_dll_head(SceneModule.scene_queue); + node = ys_dll_head(_sceneQueue); if (node == NULL) { return R_SUCCESS; } @@ -229,12 +245,12 @@ int SCENE_Next() { scene_qdat = (R_SCENE_QUEUE *)ys_dll_get_data(node); assert(scene_qdat != NULL); - SCENE_Load(scene_qdat->scene_n, scene_qdat->load_flag, scene_qdat->scene_proc, scene_qdat->scene_desc); + loadScene(scene_qdat->scene_n, scene_qdat->load_flag, scene_qdat->scene_proc, scene_qdat->scene_desc); return R_SUCCESS; } -int SCENE_Skip() { +int Scene::skipScene() { YS_DL_NODE *node; YS_DL_NODE *prev_node; YS_DL_NODE *skip_node = NULL; @@ -242,22 +258,22 @@ int SCENE_Skip() { R_SCENE_QUEUE *scene_qdat = NULL; R_SCENE_QUEUE *skip_qdat = NULL; - assert(SceneModule.init); + assert(_initialized); - if (!SceneModule.scene_loaded) { - warning("Error: Can't skip scene...no scene loaded"); + if (!_sceneLoaded) { + warning("Scene::skip(): Error: Can't skip scene...no scene loaded"); return R_FAILURE; } - if (SceneModule.in_game) { - warning("Error: Can't skip scene...game already started"); + if (_inGame) { + warning("Scene::skip(): Error: Can't skip scene...game already started"); return R_FAILURE; } // Walk down scene queue and try to find a skip target - node = ys_dll_head(SceneModule.scene_queue); + node = ys_dll_head(_sceneQueue); if (node == NULL) { - warning("Error: Can't skip scene...no scenes in queue"); + warning("Scene::skip(): Error: Can't skip scene...no scenes in queue"); return R_FAILURE; } @@ -278,75 +294,75 @@ int SCENE_Skip() { prev_node = ys_dll_prev(node); ys_dll_delete(node); } - SCENE_End(); - SCENE_Load(skip_qdat->scene_n, skip_qdat->load_flag, skip_qdat->scene_proc, skip_qdat->scene_desc); + endScene(); + loadScene(skip_qdat->scene_n, skip_qdat->load_flag, skip_qdat->scene_proc, skip_qdat->scene_desc); } // Search for a scene to skip to return R_SUCCESS; } -int SCENE_Change(int scene_num) { - assert(SceneModule.init); +int Scene::changeScene(int scene_num) { + assert(_initialized); - if (!SceneModule.scene_loaded) { - warning("Error: Can't change scene. No scene currently loaded. Game in invalid state"); + if (!_sceneLoaded) { + warning("Scene::changeScene(): Error: Can't change scene. No scene currently loaded. Game in invalid state"); return R_FAILURE; } - if ((scene_num < 0) || (scene_num > SceneModule.scene_max)) { - warning("Error: Can't change scene. Invalid scene number"); + if ((scene_num < 0) || (scene_num > _sceneMax)) { + warning("Scene::changeScene(): Error: Can't change scene. Invalid scene number"); return R_FAILURE; } - if (SceneModule.scene_lut[scene_num] == 0) { - warning("Error: Can't change scene; invalid scene descriptor resource number (0)"); + if (_sceneLUT[scene_num] == 0) { + warning("Scene::changeScene(): Error: Can't change scene; invalid scene descriptor resource number (0)"); return R_FAILURE; } - SCENE_End(); - SCENE_Load(scene_num, BY_SCENE, defaultScene, NULL); + endScene(); + loadScene(scene_num, BY_SCENE, defaultScene, NULL); return R_SUCCESS; } -int SCENE_GetMode() { - assert(SceneModule.init); +int Scene::getMode() { + assert(_initialized); - return SceneModule.scene_mode; + return _sceneMode; } -int SCENE_GetZInfo(SCENE_ZINFO *zinfo) { - assert(SceneModule.init); +int Scene::getZInfo(SCENE_ZINFO *zinfo) { + assert(_initialized); - zinfo->begin_slope = SceneModule.desc.begin_slope; - zinfo->end_slope = SceneModule.desc.end_slope; + zinfo->begin_slope = _desc.begin_slope; + zinfo->end_slope = _desc.end_slope; return R_SUCCESS; } -int SCENE_GetBGInfo(SCENE_BGINFO *bginfo) { +int Scene::getBGInfo(SCENE_BGINFO *bginfo) { R_GAME_DISPLAYINFO di; int x, y; - assert(SceneModule.init); + assert(_initialized); - bginfo->bg_buf = SceneModule.bg.buf; - bginfo->bg_buflen = SceneModule.bg.buf_len; - bginfo->bg_w = SceneModule.bg.w; - bginfo->bg_h = SceneModule.bg.h; - bginfo->bg_p = SceneModule.bg.p; + bginfo->bg_buf = _bg.buf; + bginfo->bg_buflen = _bg.buf_len; + bginfo->bg_w = _bg.w; + bginfo->bg_h = _bg.h; + bginfo->bg_p = _bg.p; GAME_GetDisplayInfo(&di); x = 0; y = 0; - if (SceneModule.bg.w < di.logical_w) { - x = (di.logical_w - SceneModule.bg.w) / 2; + if (_bg.w < di.logical_w) { + x = (di.logical_w - _bg.w) / 2; } - if (SceneModule.bg.h < di.scene_h) { - y = (di.scene_h - SceneModule.bg.h) / 2; + if (_bg.h < di.scene_h) { + y = (di.scene_h - _bg.h) / 2; } bginfo->bg_x = x; @@ -355,97 +371,97 @@ int SCENE_GetBGInfo(SCENE_BGINFO *bginfo) { return R_SUCCESS; } -int SCENE_GetBGPal(PALENTRY **pal) { - assert(SceneModule.init); - *pal = SceneModule.bg.pal; +int Scene::getBGPal(PALENTRY **pal) { + assert(_initialized); + *pal = _bg.pal; return R_SUCCESS; } -int SCENE_GetBGMaskInfo(int *w, int *h, byte **buf, size_t *buf_len) { - assert(SceneModule.init); +int Scene::getBGMaskInfo(int *w, int *h, byte **buf, size_t *buf_len) { + assert(_initialized); - if (!SceneModule.bg_mask.loaded) { + if (!_bgMask.loaded) { return R_FAILURE; } - *w = SceneModule.bg_mask.w; - *h = SceneModule.bg_mask.h; - *buf = SceneModule.bg_mask.buf; - *buf_len = SceneModule.bg_mask.buf_len; + *w = _bgMask.w; + *h = _bgMask.h; + *buf = _bgMask.buf; + *buf_len = _bgMask.buf_len; return R_SUCCESS; } -int SCENE_IsBGMaskPresent() { - assert(SceneModule.init); +int Scene::isBGMaskPresent() { + assert(_initialized); - return SceneModule.bg_mask.loaded; + return _bgMask.loaded; } -int SCENE_GetInfo(R_SCENE_INFO *si) { - assert(SceneModule.init); +int Scene::getInfo(R_SCENE_INFO *si) { + assert(_initialized); assert(si != NULL); - si->text_list = SceneModule.text_list; + si->text_list = _textList; return R_SUCCESS; } -int SCENE_Load(int scene_num, int load_flag, R_SCENE_PROC scene_proc, R_SCENE_DESC *scene_desc_param) { +int Scene::loadScene(int scene_num, int load_flag, R_SCENE_PROC scene_proc, R_SCENE_DESC *scene_desc_param) { R_SCENE_INFO scene_info; uint32 res_number = 0; int result; int i; - assert(SceneModule.init); + assert(_initialized); - if (SceneModule.scene_loaded == 1) { - warning("Error, a scene is already loaded"); + if (_sceneLoaded) { + warning("Scene::loadScene(): Error, a scene is already loaded"); return R_FAILURE; } - SceneModule.anim_list = ys_dll_create(); - SceneModule.scene_mode = 0; - SceneModule.load_desc = 1; + _animList = ys_dll_create(); + _sceneMode = 0; + _loadDesc = true; switch (load_flag) { case BY_RESOURCE: res_number = scene_num; break; case BY_SCENE: - assert((scene_num > 0) && (scene_num < SceneModule.scene_max)); - res_number = SceneModule.scene_lut[scene_num]; - SceneModule.scene_number = scene_num; + assert((scene_num > 0) && (scene_num < _sceneMax)); + res_number = _sceneLUT[scene_num]; + _sceneNumber = scene_num; break; case BY_DESC: assert(scene_desc_param != NULL); assert(scene_desc_param->res_list != NULL); - SceneModule.load_desc = 0; - SceneModule.desc = *scene_desc_param; - SceneModule.reslist = scene_desc_param->res_list; - SceneModule.reslist_entries = scene_desc_param->res_list_ct; + _loadDesc = false; + _desc = *scene_desc_param; + _resList = scene_desc_param->res_list; + _resListEntries = scene_desc_param->res_list_ct; break; default: - warning("Error: Invalid scene load flag"); + warning("Scene::loadScene(): Error: Invalid scene load flag"); return R_FAILURE; break; } // Load scene descriptor and resource list resources - if (SceneModule.load_desc) { + if (_loadDesc) { - SceneModule.scene_rn = res_number; - assert(SceneModule.scene_rn != 0); + _sceneResNum = res_number; + assert(_sceneResNum != 0); debug(0, "Loading scene resource %u:", res_number); - if (LoadSceneDescriptor(res_number) != R_SUCCESS) { - warning("Error reading scene descriptor"); + if (loadSceneDescriptor(res_number) != R_SUCCESS) { + warning("Scene::loadScene(): Error reading scene descriptor"); return R_FAILURE; } - if (LoadSceneResourceList(SceneModule.desc.res_list_rn) != R_SUCCESS) { - warning("Error reading scene resource list"); + if (loadSceneResourceList(_desc.res_list_rn) != R_SUCCESS) { + warning("Scene::loadScene(): Error reading scene resource list"); return R_FAILURE; } } else { @@ -453,98 +469,98 @@ int SCENE_Load(int scene_num, int load_flag, R_SCENE_PROC scene_proc, R_SCENE_DE } // Load resources from scene resource list - for (i = 0; i < SceneModule.reslist_entries; i++) { - result = RSC_LoadResource(SceneModule.scene_ctxt, SceneModule.reslist[i].res_number, - &SceneModule.reslist[i].res_data, &SceneModule.reslist[i].res_data_len); + 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) { - warning("Error: Allocation failure loading scene resource list"); + warning("Scene::loadScene(): Error: Allocation failure loading scene resource list"); return R_FAILURE; } } // Process resources from scene resource list - if (ProcessSceneResources() != R_SUCCESS) { - warning("Error loading scene resources"); + if (processSceneResources() != R_SUCCESS) { + warning("Scene::loadScene(): Error loading scene resources"); return R_FAILURE; } // Load scene script data - if (SceneModule.desc.script_num > 0) { - if (_vm->_script->loadScript(SceneModule.desc.script_num) != R_SUCCESS) { - warning("Error loading scene script"); + if (_desc.script_num > 0) { + if (_vm->_script->loadScript(_desc.script_num) != R_SUCCESS) { + warning("Scene::loadScene(): Error loading scene script"); return R_FAILURE; } } - SceneModule.scene_loaded = 1; + _sceneLoaded = true; if (scene_proc == NULL) { - SceneModule.scene_proc = defaultScene; + _sceneProc = defaultScene; } else { - SceneModule.scene_proc = scene_proc; + _sceneProc = scene_proc; } - SCENE_GetInfo(&scene_info); + getInfo(&scene_info); - SceneModule.scene_proc(SCENE_BEGIN, &scene_info); + _sceneProc(SCENE_BEGIN, &scene_info); return R_SUCCESS; } -int LoadSceneDescriptor(uint32 res_number) { +int Scene::loadSceneDescriptor(uint32 res_number) { byte *scene_desc_data; size_t scene_desc_len; int result; - result = RSC_LoadResource(SceneModule.scene_ctxt, res_number, &scene_desc_data, &scene_desc_len); + result = RSC_LoadResource(_sceneContext, res_number, &scene_desc_data, &scene_desc_len); if (result != R_SUCCESS) { - warning("Error: couldn't load scene descriptor"); + warning("Scene::loadSceneDescriptor(): Error: couldn't load scene descriptor"); return R_FAILURE; } if (scene_desc_len != SAGA_SCENE_DESC_LEN) { - warning("Error: scene descriptor length invalid"); + warning("Scene::loadSceneDescriptor(): Error: scene descriptor length invalid"); return R_FAILURE; } MemoryReadStream readS(scene_desc_data, scene_desc_len); - SceneModule.desc.unknown0 = readS.readUint16LE(); - SceneModule.desc.res_list_rn = readS.readUint16LE(); - SceneModule.desc.end_slope = readS.readUint16LE(); - SceneModule.desc.begin_slope = readS.readUint16LE(); - SceneModule.desc.script_num = readS.readUint16LE(); - SceneModule.desc.scene_scriptnum = readS.readUint16LE(); - SceneModule.desc.start_scriptnum = readS.readUint16LE(); - SceneModule.desc.music_rn = readS.readSint16LE(); + _desc.unknown0 = readS.readUint16LE(); + _desc.res_list_rn = readS.readUint16LE(); + _desc.end_slope = readS.readUint16LE(); + _desc.begin_slope = readS.readUint16LE(); + _desc.script_num = readS.readUint16LE(); + _desc.scene_scriptnum = readS.readUint16LE(); + _desc.start_scriptnum = readS.readUint16LE(); + _desc.music_rn = readS.readSint16LE(); RSC_FreeResource(scene_desc_data); return R_SUCCESS; } -int LoadSceneResourceList(uint32 reslist_rn) { +int Scene::loadSceneResourceList(uint32 reslist_rn) { byte *resource_list; size_t resource_list_len; int result; int i; // Load the scene resource table - result = RSC_LoadResource(SceneModule.scene_ctxt, reslist_rn, &resource_list, &resource_list_len); + result = RSC_LoadResource(_sceneContext, reslist_rn, &resource_list, &resource_list_len); if (result != R_SUCCESS) { - warning("Error: couldn't load scene resource list"); + warning("Scene::loadSceneResourceList(): Error: couldn't load scene resource list"); return R_FAILURE; } MemoryReadStream readS(resource_list, resource_list_len); // Allocate memory for scene resource list - SceneModule.reslist_entries = resource_list_len / SAGA_RESLIST_ENTRY_LEN; - debug(0, "Scene resource list contains %d entries.", SceneModule.reslist_entries); - SceneModule.reslist = (R_SCENE_RESLIST *)calloc(SceneModule.reslist_entries, sizeof *SceneModule.reslist); + _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); - if (SceneModule.reslist == NULL) { - warning("Error: Memory allocation failed"); + if (_resList == NULL) { + warning("Scene::loadSceneResourceList(): Error: Memory allocation failed"); return R_MEM; } @@ -552,9 +568,9 @@ int LoadSceneResourceList(uint32 reslist_rn) { // resource table debug(0, "Loading scene resource list..."); - for (i = 0; i < SceneModule.reslist_entries; i++) { - SceneModule.reslist[i].res_number = readS.readUint16LE(); - SceneModule.reslist[i].res_type = readS.readUint16LE(); + for (i = 0; i < _resListEntries; i++) { + _resList[i].res_number = readS.readUint16LE(); + _resList[i].res_type = readS.readUint16LE(); } RSC_FreeResource(resource_list); @@ -562,116 +578,116 @@ int LoadSceneResourceList(uint32 reslist_rn) { return R_SUCCESS; } -int ProcessSceneResources() { +int Scene::processSceneResources() { const byte *res_data; size_t res_data_len; const byte *pal_p; int i; // Process the scene resource list - for (i = 0; i < SceneModule.reslist_entries; i++) { - res_data = SceneModule.reslist[i].res_data; - res_data_len = SceneModule.reslist[i].res_data_len; - switch (SceneModule.reslist[i].res_type) { + for (i = 0; i < _resListEntries; i++) { + res_data = _resList[i].res_data; + res_data_len = _resList[i].res_data_len; + switch (_resList[i].res_type) { case SAGA_BG_IMAGE: // Scene background resource - if (SceneModule.bg.loaded) { - warning("ProcessSceneResources: Multiple background resources encountered"); + if (_bg.loaded) { + warning("Scene::processSceneResources(): Multiple background resources encountered"); return R_FAILURE; } debug(0, "Loading background resource."); - SceneModule.bg.res_buf = SceneModule.reslist[i].res_data; - SceneModule.bg.res_len = SceneModule.reslist[i].res_data_len; - SceneModule.bg.loaded = 1; - - if (_vm->decodeBGImage(SceneModule.bg.res_buf, - SceneModule.bg.res_len, - &SceneModule.bg.buf, - &SceneModule.bg.buf_len, - &SceneModule.bg.w, - &SceneModule.bg.h) != R_SUCCESS) { - warning("ProcessSceneResources: Error loading background resource: %u", SceneModule.reslist[i].res_number); + _bg.res_buf = _resList[i].res_data; + _bg.res_len = _resList[i].res_data_len; + _bg.loaded = 1; + + if (_vm->decodeBGImage(_bg.res_buf, + _bg.res_len, + &_bg.buf, + &_bg.buf_len, + &_bg.w, + &_bg.h) != R_SUCCESS) { + warning("Scene::ProcessSceneResources(): Error loading background resource: %u", _resList[i].res_number); return R_FAILURE; } - pal_p = _vm->getImagePal(SceneModule.bg.res_buf, SceneModule.bg.res_len); - memcpy(SceneModule.bg.pal, pal_p, sizeof SceneModule.bg.pal); - SceneModule.scene_mode = R_SCENE_MODE_NORMAL; + pal_p = _vm->getImagePal(_bg.res_buf, _bg.res_len); + memcpy(_bg.pal, pal_p, sizeof _bg.pal); + _sceneMode = R_SCENE_MODE_NORMAL; break; case SAGA_BG_MASK: // Scene background mask resource - if (SceneModule.bg_mask.loaded) { - warning("ProcessSceneResources: Duplicate background mask resource encountered"); + if (_bgMask.loaded) { + warning("Scene::ProcessSceneResources(): Duplicate background mask resource encountered"); } debug(0, "Loading BACKGROUND MASK resource."); - SceneModule.bg_mask.res_buf = SceneModule.reslist[i].res_data; - SceneModule.bg_mask.res_len = SceneModule.reslist[i].res_data_len; - SceneModule.bg_mask.loaded = 1; - _vm->decodeBGImage(SceneModule.bg_mask.res_buf, SceneModule.bg_mask.res_len, &SceneModule.bg_mask.buf, - &SceneModule.bg_mask.buf_len, &SceneModule.bg_mask.w, &SceneModule.bg_mask.h); + _bgMask.res_buf = _resList[i].res_data; + _bgMask.res_len = _resList[i].res_data_len; + _bgMask.loaded = 1; + _vm->decodeBGImage(_bgMask.res_buf, _bgMask.res_len, &_bgMask.buf, + &_bgMask.buf_len, &_bgMask.w, &_bgMask.h); break; case SAGA_OBJECT_NAME_LIST: debug(0, "Loading object name list resource..."); - _vm->_objectMap->loadNames(SceneModule.reslist[i].res_data, SceneModule.reslist[i].res_data_len); + _vm->_objectMap->loadNames(_resList[i].res_data, _resList[i].res_data_len); break; case SAGA_OBJECT_MAP: debug(0, "Loading object map resource..."); if (_vm->_objectMap->load(res_data, res_data_len) != R_SUCCESS) { - warning("Error loading object map resource"); + warning("Scene::ProcessSceneResources(): Error loading object map resource"); return R_FAILURE; } break; case SAGA_ACTION_MAP: debug(0, "Loading exit map resource..."); if (_vm->_actionMap->loadMap(res_data, res_data_len) != R_SUCCESS) { - warning("ProcessSceneResources: Error loading exit map resource"); + warning("Scene::ProcessSceneResources(): Error loading exit map resource"); return R_FAILURE; } break; case SAGA_ISO_TILESET: - if (SceneModule.scene_mode == R_SCENE_MODE_NORMAL) { - warning("ProcessSceneResources: Isometric tileset incompatible with normal scene mode"); + if (_sceneMode == R_SCENE_MODE_NORMAL) { + warning("Scene::ProcessSceneResources(): Isometric tileset incompatible with normal scene mode"); return R_FAILURE; } debug(0, "Loading isometric tileset resource."); if (_vm->_isoMap->loadTileset(res_data, res_data_len) != R_SUCCESS) { - warning("ProcessSceneResources: Error loading isometric tileset resource"); + warning("Scene::ProcessSceneResources(): Error loading isometric tileset resource"); return R_FAILURE; } - SceneModule.scene_mode = R_SCENE_MODE_ISO; + _sceneMode = R_SCENE_MODE_ISO; break; case SAGA_ISO_METAMAP: - if (SceneModule.scene_mode == R_SCENE_MODE_NORMAL) { - warning("ProcessSceneResources: Isometric metamap incompatible with normal scene mode"); + if (_sceneMode == R_SCENE_MODE_NORMAL) { + warning("Scene::ProcessSceneResources(): Isometric metamap incompatible with normal scene mode"); return R_FAILURE; } debug(0, "Loading isometric metamap resource."); if (_vm->_isoMap->loadMetamap(res_data, res_data_len) != R_SUCCESS) { - warning("ProcessSceneResources: Error loading isometric metamap resource"); + warning("Scene::ProcessSceneResources(): Error loading isometric metamap resource"); return R_FAILURE; } - SceneModule.scene_mode = R_SCENE_MODE_ISO; + _sceneMode = R_SCENE_MODE_ISO; break; case SAGA_ISO_METATILESET: - if (SceneModule.scene_mode == R_SCENE_MODE_NORMAL) { - warning("ProcessSceneResources: Isometric metatileset incompatible with normal scene mode"); + if (_sceneMode == R_SCENE_MODE_NORMAL) { + warning("Scene::ProcessSceneResources(): Isometric metatileset incompatible with normal scene mode"); return R_FAILURE; } debug(0, "Loading isometric metatileset resource."); if (_vm->_isoMap->loadMetaTileset(res_data, res_data_len) != R_SUCCESS) { - warning("ProcessSceneResources: Error loading isometric tileset resource"); + warning("Scene::ProcessSceneResources(): Error loading isometric tileset resource"); return R_FAILURE; } - SceneModule.scene_mode = R_SCENE_MODE_ISO; + _sceneMode = R_SCENE_MODE_ISO; break; case SAGA_ANIM_1: case SAGA_ANIM_2: @@ -688,40 +704,40 @@ int ProcessSceneResources() { new_animinfo = (SCENE_ANIMINFO *)malloc(sizeof *new_animinfo); if (new_animinfo == NULL) { - warning("ProcessSceneResources: Memory allocation error"); + warning("Scene::ProcessSceneResources(): Memory allocation error"); return R_MEM; } - if (_vm->_anim->load(SceneModule.reslist[i].res_data, - SceneModule.reslist[i].res_data_len, &new_anim_id) != R_SUCCESS) { - warning("ProcessSceneResources: Error loading animation resource"); + if (_vm->_anim->load(_resList[i].res_data, + _resList[i].res_data_len, &new_anim_id) != R_SUCCESS) { + warning("Scene::ProcessSceneResources(): Error loading animation resource"); return R_FAILURE; } new_animinfo->anim_handle = new_anim_id; - new_animinfo->anim_res_number = SceneModule.reslist[i].res_number; - ys_dll_add_tail(SceneModule.anim_list, new_animinfo, sizeof *new_animinfo); - SceneModule.anim_entries++; + new_animinfo->anim_res_number = _resList[i].res_number; + ys_dll_add_tail(_animList, new_animinfo, sizeof *new_animinfo); + _animEntries++; } break; case SAGA_PAL_ANIM: debug(0, "Loading palette animation resource."); - PALANIM_Load(SceneModule.reslist[i].res_data, SceneModule.reslist[i].res_data_len); + PALANIM_Load(_resList[i].res_data, _resList[i].res_data_len); break; default: - warning("ProcessSceneResources: Encountered unknown resource type: %d", SceneModule.reslist[i].res_type); + warning("Scene::ProcessSceneResources(): Encountered unknown resource type: %d", _resList[i].res_type); break; } } return R_SUCCESS; } -int SCENE_Draw(R_SURFACE *dst_s) { +int Scene::draw(R_SURFACE *dst_s) { R_GAME_DISPLAYINFO disp_info; R_BUFFER_INFO buf_info; R_POINT bg_pt; - assert(SceneModule.init); + assert(_initialized); _vm->_render->getBufferInfo(&buf_info); GAME_GetDisplayInfo(&disp_info); @@ -729,11 +745,11 @@ int SCENE_Draw(R_SURFACE *dst_s) { bg_pt.x = 0; bg_pt.y = 0; - switch (SceneModule.scene_mode) { + switch (_sceneMode) { case R_SCENE_MODE_NORMAL: _vm->_gfx->bufToSurface(dst_s, buf_info.r_bg_buf, disp_info.logical_w, - MAX(disp_info.scene_h, SceneModule.bg.h), NULL, &bg_pt); + MAX(disp_info.scene_h, _bg.h), NULL, &bg_pt); break; case R_SCENE_MODE_ISO: _vm->_isoMap->draw(dst_s); @@ -747,42 +763,42 @@ int SCENE_Draw(R_SURFACE *dst_s) { return R_SUCCESS; } -int SCENE_End() { +int Scene::endScene() { R_SCENE_INFO scene_info; - assert(SceneModule.init); + assert(_initialized); - if (SceneModule.scene_loaded != 1) { - warning("SCENE_End(): No scene to end"); + if (!_sceneLoaded) { + warning("Scene::endScene(): No scene to end"); return -1; } - debug(0, "SCENE_End(): Ending scene..."); + debug(0, "Ending scene..."); - SCENE_GetInfo(&scene_info); + getInfo(&scene_info); - SceneModule.scene_proc(SCENE_END, &scene_info); + _sceneProc(SCENE_END, &scene_info); - if (SceneModule.desc.script_num > 0) { + if (_desc.script_num > 0) { _vm->_script->freeScript(); } // Free scene background - if (SceneModule.bg.loaded) { - free(SceneModule.bg.buf); - SceneModule.bg.loaded = 0; + if (_bg.loaded) { + free(_bg.buf); + _bg.loaded = 0; } // Free scene background mask - if (SceneModule.bg_mask.loaded) { - free(SceneModule.bg_mask.buf); - SceneModule.bg_mask.loaded = 0; + if (_bgMask.loaded) { + free(_bgMask.buf); + _bgMask.loaded = 0; } // Free scene resource list - if (SceneModule.load_desc) { + if (_loadDesc) { - free(SceneModule.reslist); + free(_resList); } // Free animation info list @@ -792,19 +808,19 @@ int SCENE_End() { _vm->_objectMap->freeMem(); _vm->_actionMap->freeMap(); - ys_dll_destroy(SceneModule.anim_list); + ys_dll_destroy(_animList); - SceneModule.anim_entries = 0; + _animEntries = 0; EVENT_ClearList(); - _vm->textClearList(SceneModule.text_list); + _vm->textClearList(_textList); - SceneModule.scene_loaded = 0; + _sceneLoaded = false; return R_SUCCESS; } -void CF_scenechange(int argc, char *argv[], void *refCon) { +void Scene::sceneChangeCmd(int argc, char *argv[]) { int scene_num = 0; if ((argc == 0) || (argc > 1)) { @@ -813,110 +829,42 @@ void CF_scenechange(int argc, char *argv[], void *refCon) { scene_num = atoi(argv[0]); - if ((scene_num < 1) || (scene_num > SceneModule.scene_max)) { + if ((scene_num < 1) || (scene_num > _sceneMax)) { CON_Print("Invalid scene number."); return; } - SCENE_ClearQueue(); + clearSceneQueue(); - if (SCENE_Change(scene_num) == R_SUCCESS) { + if (changeScene(scene_num) == R_SUCCESS) { CON_Print("Scene changed."); } else { CON_Print("Couldn't change scene!"); } } -void CF_sceneinfo(int argc, char *argv[], void *refCon) { +static void CF_scenechange(int argc, char *argv[], void *refCon) { + ((Scene *)refCon)->sceneChangeCmd(argc, argv); +} + +void Scene::sceneInfoCmd(int argc, char *argv[]) { const char *fmt = "%-20s %d"; - CON_Print(fmt, "Scene number:", SceneModule.scene_number); - CON_Print(fmt, "Descriptor R#:", SceneModule.scene_rn); + CON_Print(fmt, "Scene number:", _sceneNumber); + CON_Print(fmt, "Descriptor R#:", _sceneResNum); CON_Print("-------------------------"); - CON_Print(fmt, "Unknown:", SceneModule.desc.unknown0); - CON_Print(fmt, "Resource list R#:", SceneModule.desc.res_list_rn); - CON_Print(fmt, "End slope:", SceneModule.desc.end_slope); - CON_Print(fmt, "Begin slope:", SceneModule.desc.begin_slope); - CON_Print(fmt, "Script resource:", SceneModule.desc.script_num); - CON_Print(fmt, "Scene script:", SceneModule.desc.scene_scriptnum); - CON_Print(fmt, "Start script:", SceneModule.desc.start_scriptnum); - CON_Print(fmt, "Music R#", SceneModule.desc.music_rn); + CON_Print(fmt, "Unknown:", _desc.unknown0); + CON_Print(fmt, "Resource list R#:", _desc.res_list_rn); + CON_Print(fmt, "End slope:", _desc.end_slope); + CON_Print(fmt, "Begin slope:", _desc.begin_slope); + CON_Print(fmt, "Script resource:", _desc.script_num); + CON_Print(fmt, "Scene script:", _desc.scene_scriptnum); + CON_Print(fmt, "Start script:", _desc.start_scriptnum); + CON_Print(fmt, "Music R#", _desc.music_rn); } -int initialScene(int param, R_SCENE_INFO *scene_info) { - R_EVENT event; - R_EVENT *q_event; - int delay_time = 0; - static PALENTRY current_pal[R_PAL_ENTRIES]; - PALENTRY *pal; - - switch (param) { - case SCENE_BEGIN: - _vm->_music->stop(); - _vm->_sound->stopVoice(); - - // Fade palette to black from intro scene - _vm->_gfx->getCurrentPal(current_pal); - - event.type = R_CONTINUOUS_EVENT; - event.code = R_PAL_EVENT; - event.op = EVENT_PALTOBLACK; - event.time = 0; - event.duration = PALETTE_FADE_DURATION; - event.data = current_pal; - - delay_time += PALETTE_FADE_DURATION; - - q_event = EVENT_Queue(&event); - - // Activate user interface - event.type = R_ONESHOT_EVENT; - event.code = R_INTERFACE_EVENT; - event.op = EVENT_ACTIVATE; - event.time = 0; - - q_event = EVENT_Chain(q_event, &event); - - // Set first scene background w/o changing palette - event.type = R_ONESHOT_EVENT; - event.code = R_BG_EVENT; - event.op = EVENT_DISPLAY; - event.param = NO_SET_PALETTE; - event.time = 0; - - q_event = EVENT_Chain(q_event, &event); - - // Fade in to first scene background palette - SCENE_GetBGPal(&pal); - - event.type = R_CONTINUOUS_EVENT; - event.code = R_PAL_EVENT; - event.op = EVENT_BLACKTOPAL; - event.time = delay_time; - event.duration = PALETTE_FADE_DURATION; - event.data = pal; - - q_event = EVENT_Chain(q_event, &event); - - event.code = R_PALANIM_EVENT; - event.op = EVENT_CYCLESTART; - event.time = 0; - - q_event = EVENT_Chain(q_event, &event); - - _vm->_anim->setFlag(0, ANIM_LOOP); - _vm->_anim->play(0, delay_time); - - debug(0, "InitialSceneproc(): Scene started"); - break; - case SCENE_END: - break; - default: - warning("Illegal scene procedure parameter"); - break; - } - - return 0; +static void CF_sceneinfo(int argc, char *argv[], void *refCon) { + ((Scene *)refCon)->sceneInfoCmd(argc, argv); } int defaultScene(int param, R_SCENE_INFO *scene_info) { @@ -952,7 +900,7 @@ int defaultScene(int param, R_SCENE_INFO *scene_info) { case SCENE_END: break; default: - warning("Illegal scene procedure parameter"); + warning("Scene::defaultScene(): Illegal scene procedure parameter"); break; } diff --git a/saga/scene.h b/saga/scene.h index 2a168bfecc..acf7515fca 100644 --- a/saga/scene.h +++ b/saga/scene.h @@ -26,8 +26,40 @@ #ifndef SAGA_SCENE_H #define SAGA_SCENE_H +#include "saga/text.h" + namespace Saga { +enum R_SCENE_MODES { + R_SCENE_MODE_INVALID, + R_SCENE_MODE_NORMAL, + R_SCENE_MODE_ISO +}; + +struct SCENE_ZINFO { + int begin_slope; + int end_slope; + +}; + +struct SCENE_BGINFO { + int bg_x; + int bg_y; + int bg_w; + int bg_h; + int bg_p; + byte *bg_buf; + size_t bg_buflen; +}; + +struct R_SCENE_INFO { + SCENE_ZINFO z_info; + SCENE_BGINFO bg_info; + R_TEXTLIST *text_list; +}; + +typedef int (R_SCENE_PROC) (int, R_SCENE_INFO *); + #define PALETTE_FADE_DURATION 1000 enum SCENE_LOAD_FLAGS { @@ -111,64 +143,67 @@ struct R_SCENE_QUEUE { int scene_skiptarget; }; -struct R_SCENE_MODULE { - int init; - R_RSCFILE_CONTEXT *scene_ctxt; - int *scene_lut; - int scene_count; - int scene_max; - YS_DL_LIST *scene_queue; - int first_scene; - int scene_loaded; - int scene_mode; - int scene_number; - int scene_rn; - int in_game; - int load_desc; - R_SCENE_DESC desc; - int reslist_loaded; - int reslist_entries; - R_SCENE_RESLIST *reslist; - int anim_entries; - YS_DL_LIST *anim_list; - R_SCENE_PROC *scene_proc; - R_TEXTLIST *text_list; - SCENE_IMAGE bg; - SCENE_IMAGE bg_mask; +class Scene { + public: + Scene(SagaEngine *vm); + ~Scene(); + int reg(); + + int startScene(); + int nextScene(); + int skipScene(); + int endScene(); + int queueScene(R_SCENE_QUEUE *scene_queue); + int draw(R_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 clearSceneQueue(void); + int changeScene(int scene_num); + + bool initialized() { return _initialized; } + + void sceneInfoCmd(int argc, char *argv[]); + void sceneChangeCmd(int argc, char *argv[]); + + private: + int loadScene(int scene, int load_flag, R_SCENE_PROC scene_proc, R_SCENE_DESC *); + int loadSceneDescriptor(uint32 res_number); + int loadSceneResourceList(uint32 res_number); + int processSceneResources(); + + private: + SagaEngine *_vm; + bool _initialized; + + R_RSCFILE_CONTEXT *_sceneContext; + int *_sceneLUT; + int _sceneCount; + int _sceneMax; + YS_DL_LIST *_sceneQueue; + int _firstScene; + bool _sceneLoaded; + int _sceneMode; + int _sceneNumber; + int _sceneResNum; + bool _inGame; + bool _loadDesc; + R_SCENE_DESC _desc; + int _resListEntries; + R_SCENE_RESLIST *_resList; + int _animEntries; + YS_DL_LIST *_animList; + R_SCENE_PROC *_sceneProc; + R_TEXTLIST *_textList; + SCENE_IMAGE _bg; + SCENE_IMAGE _bgMask; }; -int SCENE_Queue(R_SCENE_QUEUE * scene_queue); -int SCENE_ClearQueue(void); - -int SCENE_Load(int scene, int load_flag, R_SCENE_PROC scene_proc, R_SCENE_DESC *); -int LoadSceneDescriptor(uint32 res_number); -int LoadSceneResourceList(uint32 res_number); -int ProcessSceneResources(); -void CF_scenechange(int argc, char *argv[], void *refCon); -void CF_sceneinfo(int argc, char *argv[], void *refCon); - -int IHNM_StartProc(); - -int initialScene(int param, R_SCENE_INFO *scene_info); -int defaultScene(int param, R_SCENE_INFO *scene_info); - -int ITE_StartProc(); -int ITE_IntroAnimProc(int param, R_SCENE_INFO *scene_info); -int ITE_IntroCave1Proc(int param, R_SCENE_INFO *scene_info); -int ITE_IntroCave2Proc(int param, R_SCENE_INFO *scene_info); -int ITE_IntroCave3Proc(int param, R_SCENE_INFO *scene_info); -int ITE_IntroCave4Proc(int param, R_SCENE_INFO *scene_info); -int ITE_IntroValleyProc(int param, R_SCENE_INFO *scene_info); -int ITE_IntroTreeHouseProc(int param, R_SCENE_INFO *scene_info); -int ITE_IntroFairePathProc(int param, R_SCENE_INFO *scene_info); -int ITE_IntroFaireTentProc(int param, R_SCENE_INFO *scene_info); - -int IHNM_StartProc(); -int IHNM_IntroMovieProc1(int param, R_SCENE_INFO *scene_info); -int IHNM_IntroMovieProc2(int param, R_SCENE_INFO *scene_info); -int IHNM_IntroMovieProc3(int param, R_SCENE_INFO *scene_info); -int IHNM_HateProc(int param, R_SCENE_INFO *scene_info); - } // End of namespace Saga #endif diff --git a/saga/scene_mod.h b/saga/scene_mod.h deleted file mode 100644 index 0f4e46a62c..0000000000 --- a/saga/scene_mod.h +++ /dev/null @@ -1,81 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2004 The ScummVM project - * - * The ReInherit Engine is (C)2000-2003 by Daniel Balsom. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Header$ - * - */ - -// Scene management module public header file - -#ifndef SAGA_SCENE_MOD_H__ -#define SAGA_SCENE_MOD_H__ - -#include "saga/text.h" - -namespace Saga { - -enum R_SCENE_MODES { - R_SCENE_MODE_INVALID, - R_SCENE_MODE_NORMAL, - R_SCENE_MODE_ISO -}; - -struct SCENE_ZINFO { - int begin_slope; - int end_slope; - -}; - -struct SCENE_BGINFO { - int bg_x; - int bg_y; - int bg_w; - int bg_h; - int bg_p; - byte *bg_buf; - size_t bg_buflen; -}; - -struct R_SCENE_INFO { - SCENE_ZINFO z_info; - SCENE_BGINFO bg_info; - R_TEXTLIST *text_list; -}; - -typedef int (R_SCENE_PROC) (int, R_SCENE_INFO *); - -int SCENE_Register(); -int SCENE_Init(); -int SCENE_Shutdown(); -int SCENE_Start(); -int SCENE_Next(); -int SCENE_Skip(); -int SCENE_End(); -int SCENE_Draw(R_SURFACE *); -int SCENE_GetMode(); -int SCENE_GetBGMaskInfo(int *w, int *h, byte **buf, size_t *buf_len); -int SCENE_IsBGMaskPresent(void); -int SCENE_GetBGInfo(SCENE_BGINFO *bginfo); -int SCENE_GetZInfo(SCENE_ZINFO *zinfo); -int SCENE_GetBGPal(PALENTRY **pal); -int SCENE_GetInfo(R_SCENE_INFO *si); - -} // End of namespace Saga - -#endif diff --git a/saga/sdebug.cpp b/saga/sdebug.cpp index 1995dafbbf..374d9a4d96 100644 --- a/saga/sdebug.cpp +++ b/saga/sdebug.cpp @@ -27,7 +27,7 @@ #include "saga/gfx.h" #include "saga/console_mod.h" #include "saga/text.h" -#include "saga/scene_mod.h" +#include "saga/scene.h" #include "saga/font.h" #include "saga/script.h" @@ -48,7 +48,7 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { int i; R_SCENE_INFO si; - SCENE_GetInfo(&si); + _vm->_scene->getInfo(&si); disp_buf[0] = 0; diff --git a/saga/sprite.cpp b/saga/sprite.cpp index 38ad99c458..0db7a62a21 100644 --- a/saga/sprite.cpp +++ b/saga/sprite.cpp @@ -26,7 +26,7 @@ #include "saga/game_mod.h" #include "saga/gfx.h" -#include "saga/scene_mod.h" +#include "saga/scene.h" #include "saga/rscfile_mod.h" #include "saga/text.h" @@ -288,7 +288,7 @@ int Sprite::drawOccluded(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_nu return R_FAILURE; } - if (!SCENE_IsBGMaskPresent()) { + if (!_vm->_scene->isBGMaskPresent()) { return draw(ds, sprite_list, sprite_num, spr_x, spr_y); } @@ -317,7 +317,7 @@ int Sprite::drawOccluded(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_nu sprite_data_p = sprite_p + readS.pos(); // Create actor Z occlusion LUT - SCENE_GetZInfo(&zinfo); + _vm->_scene->getZInfo(&zinfo); e_slope = zinfo.end_slope; @@ -327,7 +327,7 @@ int Sprite::drawOccluded(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_nu actor_z = spr_y; - SCENE_GetBGMaskInfo(&mask_w, &mask_h, &mask_buf, &mask_buf_len); + _vm->_scene->getBGMaskInfo(&mask_w, &mask_h, &mask_buf, &mask_buf_len); spr_src_rect.left = 0; spr_src_rect.top = 0; |