diff options
Diffstat (limited to 'saga')
-rw-r--r-- | saga/isomap.cpp | 84 | ||||
-rw-r--r-- | saga/isomap.h | 56 | ||||
-rw-r--r-- | saga/isomap_mod.h | 39 | ||||
-rw-r--r-- | saga/saga.cpp | 7 | ||||
-rw-r--r-- | saga/saga.h | 2 | ||||
-rw-r--r-- | saga/scene.cpp | 10 |
6 files changed, 84 insertions, 114 deletions
diff --git a/saga/isomap.cpp b/saga/isomap.cpp index c3c7af94c8..d5f29acb3e 100644 --- a/saga/isomap.cpp +++ b/saga/isomap.cpp @@ -27,26 +27,22 @@ #include "game_mod.h" #include "gfx.h" -#include "isomap_mod.h" #include "isomap.h" namespace Saga { -static R_ISOMAP_MODULE IsoModule; - -int ISOMAP_Init() { - IsoModule.init = 1; - - return R_SUCCESS; +IsoMap::IsoMap(Gfx *gfx) { + _gfx = gfx; + _init = 1; } -int ISOMAP_LoadTileset(const byte *tileres_p, size_t tileres_len) { +int IsoMap::loadTileset(const byte *tileres_p, size_t tileres_len) { R_ISOTILE_ENTRY first_entry; R_ISOTILE_ENTRY *tile_tbl; uint16 i; - assert((IsoModule.init) && (!IsoModule.tiles_loaded)); + assert((_init) && (!_tiles_loaded)); assert((tileres_p != NULL) && (tileres_len > 0)); MemoryReadStream readS(tileres_p, tileres_len); @@ -54,16 +50,16 @@ int ISOMAP_LoadTileset(const byte *tileres_p, size_t tileres_len) { readS.readUint16LE(); // skip first_entry.tile_offset = readS.readUint16LE(); - IsoModule.tile_ct = first_entry.tile_offset / SAGA_ISOTILE_ENTRY_LEN; + _tile_ct = first_entry.tile_offset / SAGA_ISOTILE_ENTRY_LEN; readS.seek(0); - tile_tbl = (R_ISOTILE_ENTRY *)malloc(IsoModule.tile_ct * sizeof *tile_tbl); + tile_tbl = (R_ISOTILE_ENTRY *)malloc(_tile_ct * sizeof *tile_tbl); if (tile_tbl == NULL) { return R_MEM; } - for (i = 0; i < IsoModule.tile_ct; i++) { + for (i = 0; i < _tile_ct; i++) { tile_tbl[i].tile_h = readS.readByte(); tile_tbl[i].unknown01 = readS.readByte(); tile_tbl[i].tile_offset = readS.readUint16LE(); @@ -71,21 +67,21 @@ int ISOMAP_LoadTileset(const byte *tileres_p, size_t tileres_len) { tile_tbl[i].unknown06 = readS.readSint16LE(); } - IsoModule.tiles_loaded = 1; - IsoModule.tile_tbl = tile_tbl; - IsoModule.tileres_p = tileres_p; - IsoModule.tileres_len = tileres_len; + _tiles_loaded = 1; + _tile_tbl = tile_tbl; + _tileres_p = tileres_p; + _tileres_len = tileres_len; return R_SUCCESS; } -int ISOMAP_LoadMetaTileset(const byte *mtileres_p, size_t mtileres_len) { +int IsoMap::loadMetaTileset(const byte *mtileres_p, size_t mtileres_len) { R_ISO_METATILE_ENTRY *mtile_tbl; uint16 mtile_ct; uint16 ct; int i; - assert(IsoModule.init); + assert(_init); assert((mtileres_p != NULL) && (mtileres_len > 0)); MemoryReadStream readS(mtileres_p, mtileres_len); @@ -107,44 +103,44 @@ int ISOMAP_LoadMetaTileset(const byte *mtileres_p, size_t mtileres_len) { } } - IsoModule.mtile_ct = mtile_ct; - IsoModule.mtile_tbl = mtile_tbl; - IsoModule.mtileres_p = mtileres_p; - IsoModule.mtileres_len = mtileres_len; + _mtile_ct = mtile_ct; + _mtile_tbl = mtile_tbl; + _mtileres_p = mtileres_p; + _mtileres_len = mtileres_len; - IsoModule.mtiles_loaded = 1; + _mtiles_loaded = 1; return R_SUCCESS; } -int ISOMAP_LoadMetamap(const byte *mm_res_p, size_t mm_res_len) { +int IsoMap::loadMetamap(const byte *mm_res_p, size_t mm_res_len) { int i; MemoryReadStream readS(mm_res_p, mm_res_len); - IsoModule.metamap_n = readS.readSint16LE(); + _metamap_n = readS.readSint16LE(); for (i = 0; i < SAGA_METAMAP_SIZE; i++) { - IsoModule.metamap_tbl[i] = readS.readUint16LE(); + _metamap_tbl[i] = readS.readUint16LE(); } - IsoModule.mm_res_p = mm_res_p; - IsoModule.mm_res_len = mm_res_len; - IsoModule.metamap_loaded = 1; + _mm_res_p = mm_res_p; + _mm_res_len = mm_res_len; + _metamap_loaded = 1; return R_SUCCESS; } -int ISOMAP_Draw(R_SURFACE *dst_s) { +int IsoMap::draw(R_SURFACE *dst_s) { R_GAME_DISPLAYINFO disp_info; GAME_GetDisplayInfo(&disp_info); R_RECT iso_rect(disp_info.logical_w - 1, disp_info.scene_h - 1); - _vm->_gfx->drawRect(dst_s, &iso_rect, 0); - ISOMAP_DrawMetamap(dst_s, -1000, -500); + _gfx->drawRect(dst_s, &iso_rect, 0); + drawMetamap(dst_s, -1000, -500); return R_SUCCESS; } -int ISOMAP_DrawMetamap(R_SURFACE *dst_s, int map_x, int map_y) { +int IsoMap::drawMetamap(R_SURFACE *dst_s, int map_x, int map_y) { int meta_base_x = map_x; int meta_base_y = map_y; int meta_xi; @@ -158,7 +154,7 @@ int ISOMAP_DrawMetamap(R_SURFACE *dst_s, int map_x, int map_y) { meta_y = meta_base_y; for (meta_xi = SAGA_METAMAP_W - 1; meta_xi >= 0; meta_xi--) { meta_idx = meta_xi + (meta_yi * 16); - ISOMAP_DrawMetaTile(dst_s, IsoModule.metamap_tbl[meta_idx], meta_x, meta_y); + drawMetaTile(dst_s, _metamap_tbl[meta_idx], meta_x, meta_y); meta_x += 128; meta_y += 64; } @@ -170,7 +166,7 @@ int ISOMAP_DrawMetamap(R_SURFACE *dst_s, int map_x, int map_y) { return R_SUCCESS; } -int ISOMAP_DrawMetaTile(R_SURFACE *dst_s, uint16 mtile_i, int mtile_x, int mtile_y) { +int IsoMap::drawMetaTile(R_SURFACE *dst_s, uint16 mtile_i, int mtile_x, int mtile_y) { int tile_xi; int tile_yi; int tile_x; @@ -179,13 +175,13 @@ int ISOMAP_DrawMetaTile(R_SURFACE *dst_s, uint16 mtile_i, int mtile_x, int mtile int tile_base_y; int tile_i; R_ISO_METATILE_ENTRY *mtile_p; - assert(IsoModule.init && IsoModule.mtiles_loaded); + assert(_init && _mtiles_loaded); - if (mtile_i >= IsoModule.mtile_ct) { + if (mtile_i >= _mtile_ct) { return R_FAILURE; } - mtile_p = &IsoModule.mtile_tbl[mtile_i]; + mtile_p = &_mtile_tbl[mtile_i]; tile_base_x = mtile_x; tile_base_y = mtile_y; @@ -195,7 +191,7 @@ int ISOMAP_DrawMetaTile(R_SURFACE *dst_s, uint16 mtile_i, int mtile_x, int mtile tile_x = tile_base_x; for (tile_xi = SAGA_METATILE_W - 1; tile_xi >= 0; tile_xi--) { tile_i = tile_xi + (tile_yi * SAGA_METATILE_W); - ISOMAP_DrawTile(dst_s, mtile_p->tile_tbl[tile_i], tile_x, tile_y); + drawTile(dst_s, mtile_p->tile_tbl[tile_i], tile_x, tile_y); tile_x += SAGA_ISOTILE_WIDTH / 2; tile_y += SAGA_ISOTILE_BASEHEIGHT / 2 + 1; } @@ -206,7 +202,7 @@ int ISOMAP_DrawMetaTile(R_SURFACE *dst_s, uint16 mtile_i, int mtile_x, int mtile return R_SUCCESS; } -int ISOMAP_DrawTile(R_SURFACE *dst_s, uint16 tile_i, int tile_x, int tile_y) { +int IsoMap::drawTile(R_SURFACE *dst_s, uint16 tile_i, int tile_x, int tile_y) { const byte *tile_p; const byte *read_p; byte *draw_p; @@ -219,9 +215,9 @@ int ISOMAP_DrawTile(R_SURFACE *dst_s, uint16 tile_i, int tile_x, int tile_y) { int fg_runct; int ct; - assert(IsoModule.init && IsoModule.tiles_loaded); + assert(_init && _tiles_loaded); - if (tile_i >= IsoModule.tile_ct) { + if (tile_i >= _tile_ct) { return R_FAILURE; } @@ -235,8 +231,8 @@ int ISOMAP_DrawTile(R_SURFACE *dst_s, uint16 tile_i, int tile_x, int tile_y) { return R_SUCCESS; } - tile_p = IsoModule.tileres_p + IsoModule.tile_tbl[tile_i].tile_offset; - tile_h = IsoModule.tile_tbl[tile_i].tile_h; + tile_p = _tileres_p + _tile_tbl[tile_i].tile_offset; + tile_h = _tile_tbl[tile_i].tile_h; read_p = tile_p; draw_p = dst_s->buf + tile_x + (tile_y * dst_s->buf_pitch); diff --git a/saga/isomap.h b/saga/isomap.h index e6ba590902..7ac95975d5 100644 --- a/saga/isomap.h +++ b/saga/isomap.h @@ -59,31 +59,41 @@ struct R_ISO_METATILE_ENTRY { #define SAGA_METATILE_ENTRY_LEN 136 -struct R_ISOMAP_MODULE { - int init; - int tiles_loaded; - const byte *tileres_p; - size_t tileres_len; - uint16 tile_ct; - R_ISOTILE_ENTRY *tile_tbl; - - int mtiles_loaded; - const byte *mtileres_p; - size_t mtileres_len; - uint16 mtile_ct; - R_ISO_METATILE_ENTRY *mtile_tbl; - - int metamap_loaded; - int metamap_n; - uint16 metamap_tbl[SAGA_METAMAP_SIZE]; - const byte *mm_res_p; - size_t mm_res_len; +class Gfx; + +class IsoMap { +public: + IsoMap(Gfx *gfx); + 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); +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 _init; + int _tiles_loaded; + const byte *_tileres_p; + size_t _tileres_len; + uint16 _tile_ct; + R_ISOTILE_ENTRY *_tile_tbl; + + int _mtiles_loaded; + const byte *_mtileres_p; + size_t _mtileres_len; + uint16 _mtile_ct; + R_ISO_METATILE_ENTRY *_mtile_tbl; + + int _metamap_loaded; + int _metamap_n; + uint16 _metamap_tbl[SAGA_METAMAP_SIZE]; + const byte *_mm_res_p; + size_t _mm_res_len; + + Gfx *_gfx; }; -int ISOMAP_DrawTile(R_SURFACE *dst_s, uint16 tile_i, int tile_x, int tile_y); -int ISOMAP_DrawMetaTile(R_SURFACE *dst_s, uint16 mtile_i, int mtile_x, int mtile_y); -int ISOMAP_DrawMetamap(R_SURFACE *dst_s, int map_x, int map_y); - } // End of namespace Saga #endif diff --git a/saga/isomap_mod.h b/saga/isomap_mod.h deleted file mode 100644 index 27d0c9cd72..0000000000 --- a/saga/isomap_mod.h +++ /dev/null @@ -1,39 +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$ - * - */ - -// Isometric level module - public module header - -#ifndef SAGA_ISOMAP_MOD_H_ -#define SAGA_ISOMAP_MOD_H_ - -namespace Saga { - -int ISOMAP_Init(void); -int ISOMAP_LoadTileset(const byte *, size_t); -int ISOMAP_LoadMetaTileset(const byte *, size_t); -int ISOMAP_LoadMetamap(const byte *mm_res_p, size_t mm_res_len); -int ISOMAP_Draw(R_SURFACE *dst_s); - -} // End of namespace Saga - -#endif diff --git a/saga/saga.cpp b/saga/saga.cpp index 425040c4b9..70795a3652 100644 --- a/saga/saga.cpp +++ b/saga/saga.cpp @@ -45,7 +45,7 @@ #include "game_mod.h" #include "game.h" #include "interface_mod.h" -#include "isomap_mod.h" +#include "isomap.h" #include "script.h" #include "script_mod.h" #include "scene_mod.h" @@ -154,9 +154,7 @@ void SagaEngine::go() { FONT_Init(); SPRITE_Init(); _anim = new Anim(this); - _actionMap = new ActionMap(this); OBJECTMAP_Init(); - ISOMAP_Init(); _script = new Script(); _sdata = new SData(); INTERFACE_Init(); // requires script module @@ -197,6 +195,9 @@ void SagaEngine::go() { return; } + _isomap = new IsoMap(_gfx); + _actionMap = new ActionMap(this); + // Initialize system specific sound _sound = new Sound(this, _mixer, MainData.sound_enabled); if (!MainData.sound_enabled) { diff --git a/saga/saga.h b/saga/saga.h index a683f3c55d..a4e31b725d 100644 --- a/saga/saga.h +++ b/saga/saga.h @@ -43,6 +43,7 @@ class Music; class Anim; class Render; class ActionMap; +class IsoMap; class Gfx; class SData; class Script; @@ -94,6 +95,7 @@ public: Anim *_anim; Render *_render; ActionMap *_actionMap; + IsoMap *_isomap; Gfx *_gfx; SData *_sdata; Script *_script; diff --git a/saga/scene.cpp b/saga/scene.cpp index 7ae33da15b..8148a8f23f 100644 --- a/saga/scene.cpp +++ b/saga/scene.cpp @@ -32,7 +32,7 @@ #include "cvar_mod.h" #include "events_mod.h" #include "actionmap.h" -#include "isomap_mod.h" +#include "isomap.h" #include "script_mod.h" #include "objectmap_mod.h" #include "palanim_mod.h" @@ -636,7 +636,7 @@ int ProcessSceneResources() { debug(0, "Loading isometric tileset resource."); - if (ISOMAP_LoadTileset(res_data, res_data_len) != R_SUCCESS) { + if (_vm->_isomap->loadTileset(res_data, res_data_len) != R_SUCCESS) { warning("ProcessSceneResources: Error loading isometric tileset resource"); return R_FAILURE; } @@ -651,7 +651,7 @@ int ProcessSceneResources() { debug(0, "Loading isometric metamap resource."); - if (ISOMAP_LoadMetamap(res_data, res_data_len) != R_SUCCESS) { + if (_vm->_isomap->loadMetamap(res_data, res_data_len) != R_SUCCESS) { warning("ProcessSceneResources: Error loading isometric metamap resource"); return R_FAILURE; } @@ -666,7 +666,7 @@ int ProcessSceneResources() { debug(0, "Loading isometric metatileset resource."); - if (ISOMAP_LoadMetaTileset(res_data, res_data_len) != R_SUCCESS) { + if (_vm->_isomap->loadMetaTileset(res_data, res_data_len) != R_SUCCESS) { warning("ProcessSceneResources: Error loading isometric tileset resource"); return R_FAILURE; } @@ -736,7 +736,7 @@ int SCENE_Draw(R_SURFACE *dst_s) { MAX(disp_info.scene_h, SceneModule.bg.h), NULL, &bg_pt); break; case R_SCENE_MODE_ISO: - ISOMAP_Draw(dst_s); + _vm->_isomap->draw(dst_s); break; default: // Unknown scene mode |