ASYLUM: overhaul of the resource management system
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@31 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
This commit is contained in:
parent
349eca1cb9
commit
a42bf545fc
24 changed files with 593 additions and 667 deletions
|
@ -27,8 +27,8 @@
|
|||
#include "asylum/asylum.h"
|
||||
#include "asylum/screen.h"
|
||||
#include "asylum/menu.h"
|
||||
#include "asylum/resource.h"
|
||||
#include "asylum/graphics.h"
|
||||
|
||||
#include "asylum/bundles/graphicbundle.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
|
@ -43,8 +43,8 @@ AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
|
|||
|
||||
AsylumEngine::~AsylumEngine() {
|
||||
//Common::clearAllDebugChannels();
|
||||
delete _menu;
|
||||
delete _screen;
|
||||
delete _resMgr;
|
||||
}
|
||||
|
||||
Common::Error AsylumEngine::run() {
|
||||
|
@ -58,8 +58,9 @@ Common::Error AsylumEngine::run() {
|
|||
// Will do the same as subroutine at address 0041A500
|
||||
Common::Error AsylumEngine::init() {
|
||||
// initialize engine objects
|
||||
_screen = new Screen(_system);
|
||||
_menu = new Menu(_screen);
|
||||
|
||||
_screen = new Screen(_system);
|
||||
_resMgr = new ResourceManager;
|
||||
|
||||
// initializing game
|
||||
// TODO: save dialogue key codes into sntrm_k.txt (need to figure out why they use such thing)
|
||||
|
@ -67,7 +68,7 @@ Common::Error AsylumEngine::init() {
|
|||
// TODO: load startup configurations (address 0041A970)
|
||||
// TODO: setup cinematics (address 0041A880) (probably we won't need it)
|
||||
// TODO: init unknown game stuffs (address 0040F430)
|
||||
|
||||
|
||||
// TODO: load smaker intro movie (0)->(mov000.smk)
|
||||
// TODO: if savegame exists on folder, than start NewGame()
|
||||
|
||||
|
@ -75,20 +76,10 @@ Common::Error AsylumEngine::init() {
|
|||
}
|
||||
|
||||
Common::Error AsylumEngine::go() {
|
||||
Resource* res = new Resource;
|
||||
|
||||
res->load(1);
|
||||
res->dump();
|
||||
showMainMenu();
|
||||
|
||||
//GraphicResource *gres = new GraphicResource( res->getResource(1) );
|
||||
//gres->dump();
|
||||
|
||||
delete res;
|
||||
//delete gres;
|
||||
|
||||
_menu->init();
|
||||
|
||||
// DEBUG
|
||||
// DEBUG
|
||||
// Control loop test. Basically just keep the
|
||||
// ScummVM window alive until ESC is pressed.
|
||||
// This will facilitate drawing tests ;)
|
||||
|
@ -103,11 +94,21 @@ Common::Error AsylumEngine::go() {
|
|||
//if (ev.kbd.keycode == Common::KEYCODE_RETURN)
|
||||
}
|
||||
}
|
||||
_menu->run();
|
||||
_system->delayMillis(10);
|
||||
}
|
||||
|
||||
return Common::kNoError;
|
||||
}
|
||||
|
||||
void AsylumEngine::showMainMenu() {
|
||||
// eyes animation index table
|
||||
//const uint32 eyesTable[8] = {3, 5, 1, 7, 4, 8, 2, 6};
|
||||
_screen->setFrontBuffer(
|
||||
0, 0,
|
||||
SCREEN_WIDTH, SCREEN_DEPTH,
|
||||
_resMgr->getGraphic("res.001",0).getEntry(0).data);
|
||||
_screen->setPalette(_resMgr->getPalette("res.001", 17).data);
|
||||
_screen->updateScreen();
|
||||
}
|
||||
|
||||
} // namespace Asylum
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "engines/engine.h"
|
||||
|
||||
#include "asylum/resourcemanager.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
|
@ -41,12 +42,16 @@ public:
|
|||
Common::Error go();
|
||||
virtual Common::Error run();
|
||||
virtual bool hasFeature(EngineFeature f) const;
|
||||
|
||||
private:
|
||||
Common::Language _language;
|
||||
Common::Language _language;
|
||||
Common::RandomSource _rnd;
|
||||
|
||||
Screen *_screen;
|
||||
Menu *_menu;
|
||||
ResourceManager *_resMgr;
|
||||
Screen *_screen;
|
||||
|
||||
void showMainMenu();
|
||||
|
||||
};
|
||||
|
||||
} // namespace Asylum
|
||||
|
|
47
engines/asylum/bundles/bundle.cpp
Normal file
47
engines/asylum/bundles/bundle.cpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* bundle.cpp
|
||||
*
|
||||
* Created on: 7-Jun-2009
|
||||
* Author: alex
|
||||
*/
|
||||
|
||||
#include "common/file.h"
|
||||
|
||||
#include "asylum/bundles/bundle.h"
|
||||
#include "asylum/offsets.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
Bundle::Bundle() {
|
||||
size = 0;
|
||||
numEntries = 0;
|
||||
}
|
||||
|
||||
Bundle::Bundle(Common::String filename, uint32 index) {
|
||||
loadRaw(filename, index);
|
||||
}
|
||||
|
||||
int Bundle::loadRaw(Common::String filename, uint32 index) {
|
||||
Common::File *file = new Common::File;
|
||||
|
||||
if (!file || !file->open(filename)) {
|
||||
printf("Failed to load file %s", filename.c_str());
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32 offset = res001[index][0];
|
||||
size = res001[index][1];
|
||||
|
||||
data = (uint8*)malloc(size);
|
||||
file->seek(offset, SEEK_SET);
|
||||
file->read(data, size);
|
||||
|
||||
file->close();
|
||||
file = NULL;
|
||||
|
||||
update();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // end of namespace Asylum
|
47
engines/asylum/bundles/bundle.h
Normal file
47
engines/asylum/bundles/bundle.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* bundle.h
|
||||
*
|
||||
* Created on: 7-Jun-2009
|
||||
* Author: alex
|
||||
*/
|
||||
|
||||
#ifndef ASYLUM_BUNDLE_H_
|
||||
#define ASYLUM_BUNDLE_H_
|
||||
|
||||
#include "common/endian.h"
|
||||
#include "common/file.h"
|
||||
#include "common/stream.h"
|
||||
|
||||
#include "common/str.h"
|
||||
#include "common/array.h"
|
||||
|
||||
#include "asylum/resources/resource.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
class Bundle {
|
||||
|
||||
public:
|
||||
Bundle();
|
||||
Bundle(Common::String filename, uint32 index);
|
||||
virtual ~Bundle() {}
|
||||
|
||||
Common::String id;
|
||||
uint32 size;
|
||||
uint32 numEntries;
|
||||
Common::Array<Resource> entries;
|
||||
|
||||
uint8* getData() { return data; }
|
||||
protected:
|
||||
int loadRaw(Common::String filename, uint32 index);
|
||||
virtual void update(){}
|
||||
uint8 *data;
|
||||
|
||||
private:
|
||||
|
||||
}; // end of class Bundle
|
||||
|
||||
|
||||
} // end of namespace Asylum
|
||||
|
||||
#endif
|
62
engines/asylum/bundles/graphicbundle.cpp
Normal file
62
engines/asylum/bundles/graphicbundle.cpp
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* graphicbundle.cpp
|
||||
*
|
||||
* Created on: 7-Jun-2009
|
||||
* Author: alex
|
||||
*/
|
||||
|
||||
#include "asylum/bundles/graphicbundle.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
GraphicBundle::GraphicBundle(Common::String filename, uint32 index) {
|
||||
loadRaw(filename, index);
|
||||
}
|
||||
|
||||
void GraphicBundle::update() {
|
||||
uint32 pos = 0;
|
||||
|
||||
_tagValue = READ_UINT32(data + pos); pos += 4;
|
||||
_flag = READ_UINT32(data + pos); pos += 4;
|
||||
_contentOffset = READ_UINT32(data + pos); pos += 4;
|
||||
_unknown1 = READ_UINT32(data + pos); pos += 4;
|
||||
_unknown2 = READ_UINT32(data + pos); pos += 4;
|
||||
_unknown3 = READ_UINT32(data + pos); pos += 4;
|
||||
numEntries = READ_UINT16(data + pos); pos += 2;
|
||||
_maxWidth = READ_UINT16(data + pos); pos += 2;
|
||||
|
||||
Common::Array<uint32> offsets;
|
||||
|
||||
// read the individual asset offsets
|
||||
for (uint32 i = 0; i < numEntries; i++) {
|
||||
offsets.push_back(READ_UINT32(data + pos)); pos += 4;
|
||||
}
|
||||
|
||||
// read each asset
|
||||
for (uint32 i = 0; i < numEntries; i++) {
|
||||
GraphicResource *gra = new GraphicResource;
|
||||
|
||||
pos = offsets[i] + _contentOffset;
|
||||
|
||||
gra->size = READ_UINT32(data + pos); pos += 4;
|
||||
gra->flag = READ_UINT32(data + pos); pos += 4;
|
||||
gra->x = READ_UINT16(data + pos); pos += 2;
|
||||
gra->y = READ_UINT16(data + pos); pos += 2;
|
||||
gra->height = READ_UINT16(data + pos); pos += 2;
|
||||
gra->width = READ_UINT16(data + pos); pos += 2;
|
||||
|
||||
// allocate space for data and fill the array from
|
||||
// the end of the header block (read in above) to
|
||||
// the length specified by gra->size
|
||||
gra->data = (uint8*)malloc(gra->size - 16);
|
||||
memcpy(gra->data, data + pos, gra->size - 16);
|
||||
|
||||
entries.push_back(*gra);
|
||||
}
|
||||
}
|
||||
|
||||
GraphicResource GraphicBundle::getEntry(uint32 index) {
|
||||
return (GraphicResource)entries[index];
|
||||
}
|
||||
|
||||
} // end of namespace Asylum
|
40
engines/asylum/bundles/graphicbundle.h
Normal file
40
engines/asylum/bundles/graphicbundle.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* graphicbundle.h
|
||||
*
|
||||
* Created on: 7-Jun-2009
|
||||
* Author: alex
|
||||
*/
|
||||
|
||||
#ifndef ASYLUM_GRAPHICBUNDLE_H_
|
||||
#define ASYLUM_GRAPHICBUNDLE_H_
|
||||
|
||||
#include "asylum/bundles/bundle.h"
|
||||
#include "asylum/resources/graphic.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
class GraphicBundle: public Bundle {
|
||||
public:
|
||||
GraphicBundle() {}
|
||||
GraphicBundle(Common::String filename, uint32 index);
|
||||
~GraphicBundle() {}
|
||||
|
||||
Common::Array<GraphicResource> entries;
|
||||
GraphicResource getEntry(uint32 index);
|
||||
|
||||
protected:
|
||||
void update();
|
||||
|
||||
private:
|
||||
uint32 _tagValue;
|
||||
uint32 _flag;
|
||||
uint32 _contentOffset;
|
||||
uint32 _unknown1;
|
||||
uint32 _unknown2;
|
||||
uint32 _unknown3;
|
||||
uint16 _maxWidth;
|
||||
};
|
||||
|
||||
} // end of namespace Asylum
|
||||
|
||||
#endif
|
|
@ -1,109 +0,0 @@
|
|||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "asylum/graphics.h"
|
||||
|
||||
#include "common/endian.h"
|
||||
#include "common/file.h"
|
||||
#include "common/stream.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
GraphicResource::GraphicResource(ResourceItem item) {
|
||||
int pos = 0;
|
||||
|
||||
_tagValue = READ_UINT32(item.data + pos); pos += 4;
|
||||
_flag = READ_UINT32(item.data + pos); pos += 4;
|
||||
_contentOffset = READ_UINT32(item.data + pos); pos += 4;
|
||||
_unknown1 = READ_UINT32(item.data + pos); pos += 4;
|
||||
_unknown2 = READ_UINT32(item.data + pos); pos += 4;
|
||||
_unknown3 = READ_UINT32(item.data + pos); pos += 4;
|
||||
_numEntries = READ_UINT16(item.data + pos); pos += 2;
|
||||
_maxWidthSize = READ_UINT16(item.data + pos); pos += 2;
|
||||
|
||||
Common::Array<uint32> offsets;
|
||||
|
||||
// read the individual asset offsets
|
||||
for (int i = 0; i < _numEntries; i++) {
|
||||
offsets.push_back(READ_UINT32(item.data + pos)); pos += 4;
|
||||
}
|
||||
|
||||
// read each asset
|
||||
for (int i = 0; i < _numEntries; i++) {
|
||||
GraphicAsset* gra = new GraphicAsset;
|
||||
|
||||
pos = offsets[i] + _contentOffset;
|
||||
|
||||
gra->size = READ_UINT32(item.data + pos); pos += 4;
|
||||
gra->flag = READ_UINT32(item.data + pos); pos += 4;
|
||||
gra->x = READ_UINT16(item.data + pos); pos += 2;
|
||||
gra->y = READ_UINT16(item.data + pos); pos += 2;
|
||||
gra->height = READ_UINT16(item.data + pos); pos += 2;
|
||||
gra->width = READ_UINT16(item.data + pos); pos += 2;
|
||||
|
||||
// allocate space for data and fill the array from
|
||||
// the end of the header block (read in above) to
|
||||
// the length specified by gra->size
|
||||
gra->data = (uint8*)malloc(gra->size - 16);
|
||||
memcpy(gra->data, item.data + pos, gra->size - 16);
|
||||
|
||||
_items.push_back(*gra);
|
||||
|
||||
gra->dump();
|
||||
}
|
||||
}
|
||||
|
||||
GraphicResource::~GraphicResource() {
|
||||
}
|
||||
|
||||
GraphicAsset GraphicResource::getGraphicAsset(uint8 index){
|
||||
// TODO bounds check the array accessor
|
||||
return _items[index];
|
||||
}
|
||||
|
||||
void GraphicResource::dump() {
|
||||
printf( "Tag %d, Flag %d, ConOffset %d, U1 %d, U2 %d, U3 %d, Entries %d, MaxWidthSize %d\n", _tagValue, _flag, _contentOffset, _unknown1, _unknown2, _unknown3, _numEntries, _maxWidthSize );
|
||||
}
|
||||
|
||||
//////////////////
|
||||
// GraphicAsset //
|
||||
//////////////////
|
||||
|
||||
GraphicAsset::GraphicAsset() {
|
||||
}
|
||||
|
||||
GraphicAsset::~GraphicAsset() {
|
||||
}
|
||||
|
||||
void GraphicAsset::dump() {
|
||||
printf( "Size: %d, Flag %d, Width: %d, Height: %d, x: %d, y: %d\n", size, flag, width, height, x, y );
|
||||
}
|
||||
|
||||
int GraphicAsset::save(Common::String filename) {
|
||||
FILE *fd;
|
||||
fd = fopen(filename.c_str(), "wb+");
|
||||
fwrite(data, size, 1, fd);
|
||||
fclose(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // end of namespace Asylum
|
|
@ -1,78 +0,0 @@
|
|||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef ASYLUM_GRAPHICS_H
|
||||
#define ASYLUM_GRAPHICS_H
|
||||
|
||||
#include "common/str.h"
|
||||
#include "common/array.h"
|
||||
|
||||
#include "asylum/resource.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
class GraphicAsset;
|
||||
|
||||
class GraphicResource {
|
||||
public:
|
||||
GraphicResource(ResourceItem item);
|
||||
~GraphicResource();
|
||||
|
||||
GraphicAsset getGraphicAsset(uint8 index);
|
||||
|
||||
void dump();
|
||||
|
||||
private:
|
||||
Common::String _filename;
|
||||
uint32 _tagValue;
|
||||
uint32 _flag;
|
||||
uint32 _contentOffset;
|
||||
uint32 _unknown1;
|
||||
uint32 _unknown2;
|
||||
uint32 _unknown3;
|
||||
uint16 _numEntries;
|
||||
uint16 _maxWidthSize;
|
||||
|
||||
Common::Array<GraphicAsset> _items;
|
||||
|
||||
}; // end of class GraphicResource
|
||||
|
||||
class GraphicAsset {
|
||||
public:
|
||||
GraphicAsset();
|
||||
~GraphicAsset();
|
||||
|
||||
uint32 size;
|
||||
uint32 flag;
|
||||
uint16 x;
|
||||
uint16 y;
|
||||
uint16 width;
|
||||
uint16 height;
|
||||
uint8 *data;
|
||||
|
||||
void dump();
|
||||
int save(Common::String filename);
|
||||
|
||||
}; // end of class GraphicAsset
|
||||
|
||||
} // end of namespace Asylum
|
||||
|
||||
#endif
|
|
@ -1,66 +0,0 @@
|
|||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "asylum/menu.h"
|
||||
#include "asylum/resource.h"
|
||||
#include "asylum/graphics.h"
|
||||
#include "asylum/palette.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
// eyes animation index table
|
||||
const uint32 Menu::eyesTable[8] = {3, 5, 1, 7, 4, 8, 2, 6};
|
||||
|
||||
Menu::Menu(Screen *screen){
|
||||
_screen = screen;
|
||||
}
|
||||
|
||||
Menu::~Menu() {
|
||||
delete _res1;
|
||||
}
|
||||
|
||||
void Menu::init(){
|
||||
printf("Menu: init()\n");
|
||||
|
||||
_res1 = new Resource(1);
|
||||
|
||||
// TODO: from address 0041A500 (init background music, setup menu environment like palette, font, gamma level, etc.)
|
||||
|
||||
Palette *tmpPal = new Palette(_res1->getResource(MENU_PAL_ENTRY));
|
||||
memcpy(_palette, tmpPal->_buffer, sizeof(uint8)*256*3);
|
||||
|
||||
// TESTING...
|
||||
GraphicResource *gres = new GraphicResource(_res1->getResource(0));
|
||||
_screen->setFrontBuffer(0, 0, SCREEN_WIDTH, SCREEN_DEPTH, gres->getGraphicAsset(0).data);
|
||||
}
|
||||
|
||||
void Menu::run(){
|
||||
//printf("Menu: running...\n");
|
||||
|
||||
_screen->setPalette(_palette);
|
||||
|
||||
// TODO: get background image
|
||||
// blit it into back buffer and front buffer
|
||||
|
||||
_screen->updateScreen();
|
||||
}
|
||||
|
||||
} // namespace Asylum
|
|
@ -1,65 +0,0 @@
|
|||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef ASYLUM_MENU_H
|
||||
#define ASYLUM_MENU_H
|
||||
|
||||
#include "asylum/screen.h"
|
||||
#include "asylum/resource.h"
|
||||
|
||||
#define MENU_PAL_ENTRY 17
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
/** Game main menu routines */
|
||||
class Menu {
|
||||
public:
|
||||
Menu(Screen *screen);
|
||||
~Menu();
|
||||
|
||||
/** Initialize menu (music, palette, gamma level,etc.) */
|
||||
void init();
|
||||
|
||||
/** run menu (blit bkg image, eye orietation, icons display) */
|
||||
void run();
|
||||
|
||||
private:
|
||||
Screen *_screen;
|
||||
|
||||
static const uint32 eyesTable[8];
|
||||
|
||||
/** Background image buffer */
|
||||
//uint8 _bkgImageBuf[SCREEN_WIDTH*SCREEN_DEPTH];
|
||||
|
||||
/** Mouse icon resource image buffer */
|
||||
uint8 *_mouseIconBuf;
|
||||
|
||||
/** Menu palette */
|
||||
uint8 _palette[PAL_SIZE*3];
|
||||
|
||||
// FIXME: this resource shouldn't be here. Must be deleted when a single
|
||||
// entry could be extracted from resource withou reading entire file.
|
||||
Resource *_res1;
|
||||
};
|
||||
|
||||
} // namespace Asylum
|
||||
|
||||
#endif
|
|
@ -1,13 +1,17 @@
|
|||
MODULE := engines/asylum
|
||||
|
||||
MODULE_OBJS := \
|
||||
detection.o \
|
||||
graphics.o \
|
||||
resource.o \
|
||||
bundles/bundle.o \
|
||||
bundles/graphicbundle.o \
|
||||
resources/resource.o \
|
||||
resources/graphic.o \
|
||||
resources/palette.o \
|
||||
asylum.o \
|
||||
detection.o \
|
||||
resourcemanager.o \
|
||||
screen.o \
|
||||
menu.o \
|
||||
palette.o
|
||||
menu.o
|
||||
|
||||
|
||||
# This module can be built as a plugin
|
||||
ifeq ($(ENABLE_ASYLUM), DYNAMIC_PLUGIN)
|
||||
|
|
77
engines/asylum/offsets.h
Normal file
77
engines/asylum/offsets.h
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* data.h
|
||||
*
|
||||
* Created on: 7-Jun-2009
|
||||
* Author: alex
|
||||
*/
|
||||
|
||||
#ifndef ASYLUM_OFFSETS_H_
|
||||
#define ASYLUM_OFFSETS_H_
|
||||
|
||||
#include "common/str.h"
|
||||
|
||||
uint32 res001[61][2] = {
|
||||
{252, 614468},
|
||||
{614720, 18308},
|
||||
{633028, 15634},
|
||||
{648662, 11867},
|
||||
{660529, 39928},
|
||||
{700457, 39928},
|
||||
{740385, 40648},
|
||||
{781033, 40648},
|
||||
{821681, 39208},
|
||||
{860889, 39208},
|
||||
{900097, 41578},
|
||||
{941675, 41578},
|
||||
{983253, 42328},
|
||||
{1025581, 42328},
|
||||
{1067909, 40828},
|
||||
{1108737, 27228},
|
||||
{1135965, 26520},
|
||||
{1162485, 800},
|
||||
{1163285, 65536},
|
||||
{1228821, 65536},
|
||||
{1294357, 65536},
|
||||
{1359893, 65536},
|
||||
{1425429, 26520},
|
||||
{1451949, 307248},
|
||||
{1759197, 1253448},
|
||||
{3012645, 26520},
|
||||
{3039165, 800},
|
||||
{3039965, 65536},
|
||||
{3105501, 65536},
|
||||
{3171037, 65536},
|
||||
{3236573, 65536},
|
||||
{3302109, 800},
|
||||
{3302909, 26520},
|
||||
{3329429, 307248},
|
||||
{3636677, 65536},
|
||||
{3702213, 65536},
|
||||
{3767749, 65536},
|
||||
{3833285, 65536},
|
||||
{3898821, 2052780},
|
||||
{5951601, 3364936},
|
||||
{9316537, 5690462},
|
||||
{15006999, 104640},
|
||||
{15111639, 913024},
|
||||
{16024663, 146208},
|
||||
{16170871, 53716},
|
||||
{16224587, 54802},
|
||||
{16279389, 54078},
|
||||
{16333467, 63706},
|
||||
{16397173, 85816},
|
||||
{16482989, 52548},
|
||||
{16535537, 71466},
|
||||
{16607003, 78560},
|
||||
{16685563, 52530},
|
||||
{16738093, 92242},
|
||||
{16830335, 68284},
|
||||
{16898619, 71200},
|
||||
{16969819, 2110986},
|
||||
{19080805, 20045},
|
||||
{19100850, 24724},
|
||||
{19125574, 1352},
|
||||
{19126926, 248}
|
||||
};
|
||||
|
||||
#endif /* DATA_H_ */
|
|
@ -1,35 +0,0 @@
|
|||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "common/endian.h"
|
||||
|
||||
#include "asylum/palette.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
Palette::Palette(ResourceItem item){
|
||||
memcpy(_buffer, item.data+32, sizeof(uint8)*256*3); // palettes always start from offset 32
|
||||
}
|
||||
|
||||
Palette::~Palette() {
|
||||
}
|
||||
|
||||
} // namespace Asylum
|
|
@ -1,42 +0,0 @@
|
|||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef ASYLUM_PALETTE_H
|
||||
#define ASYLUM_PALETTE_H
|
||||
|
||||
#include "common/str.h"
|
||||
#include "common/array.h"
|
||||
|
||||
#include "asylum/resource.h"
|
||||
#include "asylum/screen.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
class Palette {
|
||||
public:
|
||||
Palette(ResourceItem item);
|
||||
~Palette();
|
||||
uint8 _buffer[PAL_SIZE*3];
|
||||
};
|
||||
|
||||
} // namespace Asylum
|
||||
|
||||
#endif
|
|
@ -1,160 +0,0 @@
|
|||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "common/file.h"
|
||||
|
||||
#include "asylum/resource.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
//////////////
|
||||
// Resource //
|
||||
//////////////
|
||||
|
||||
Resource::Resource(){
|
||||
}
|
||||
|
||||
Resource::Resource(uint32 resource){
|
||||
load(resource);
|
||||
}
|
||||
|
||||
Resource::~Resource() {
|
||||
for (uint8 i = 0; i < _numEntries; i++) {
|
||||
free(_items[i].data);
|
||||
}
|
||||
}
|
||||
|
||||
int Resource::load(uint32 resource) {
|
||||
char file[20];
|
||||
sprintf(file, RES_FILE_PREFIX, resource);
|
||||
return load(Common::String(file));
|
||||
}
|
||||
|
||||
int Resource::load(Common::String filename) {
|
||||
_filename = filename;
|
||||
|
||||
Common::File* file = new Common::File;
|
||||
|
||||
// load the file
|
||||
if (!file || !file->open(filename)) {
|
||||
printf("Failed to load file %s", _filename.c_str());
|
||||
return -1;
|
||||
}
|
||||
|
||||
_size = file->size();
|
||||
|
||||
// read the entry count
|
||||
file->read( &_numEntries, 4 );
|
||||
|
||||
// create the resource item array and
|
||||
// set the item offset for each entry
|
||||
for (uint8 i = 0; i < _numEntries; i++) {
|
||||
ResourceItem* item = new ResourceItem;
|
||||
file->read(&item->offset, 4);
|
||||
_items.push_back(*item);
|
||||
}
|
||||
|
||||
// set the last entry's offset to the filesize
|
||||
_items[_numEntries - 1].offset = _size - file->pos();
|
||||
|
||||
// calculate each entry's size based on the offset
|
||||
// information
|
||||
for (uint8 j = 0; j < _numEntries; j++) {
|
||||
if (_items[j].offset == 0) {
|
||||
_items[j].size = 0;
|
||||
continue;
|
||||
}
|
||||
_items[j].size = getNextValidOffset( j+1 ) - _items[j].offset;
|
||||
|
||||
// DEBUG
|
||||
/*
|
||||
printf( "[%d] ", j );
|
||||
_items[j].dump();
|
||||
*/
|
||||
}
|
||||
|
||||
// populate the data
|
||||
for (uint8 k = 0; k < _numEntries; k++) {
|
||||
if (_items[k].size > 0) {
|
||||
_items[k].data = (uint8*)malloc(_items[k].size);
|
||||
file->seek(_items[k].offset, SEEK_SET);
|
||||
file->read(_items[k].data, _items[k].size);
|
||||
|
||||
// DEBUG
|
||||
// Print the data file's header
|
||||
// printf( "[%d] %c%c%c%c\n", k, _items[k].data[0], _items[k].data[1],_items[k].data[2],_items[k].data[3] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
file->close();
|
||||
file = NULL;
|
||||
|
||||
_loaded = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 Resource::getNextValidOffset(uint8 startPos) {
|
||||
for (uint8 i = startPos; i < _numEntries; i++) {
|
||||
if (_items[i].offset != 0) {
|
||||
return _items[i].offset;
|
||||
}
|
||||
}
|
||||
|
||||
return _size;
|
||||
}
|
||||
|
||||
ResourceItem Resource::getResource(uint32 pos) {
|
||||
// TODO bounds check the array accessor
|
||||
return _items[pos];
|
||||
}
|
||||
|
||||
void Resource::dump()
|
||||
{
|
||||
printf("File %s: Pack Size: %d, Entries: %d\n", _filename.c_str(), _size, _numEntries);
|
||||
}
|
||||
|
||||
//////////////////
|
||||
// ResourceItem //
|
||||
//////////////////
|
||||
|
||||
ResourceItem::ResourceItem() {
|
||||
}
|
||||
|
||||
ResourceItem::~ResourceItem(){
|
||||
}
|
||||
|
||||
void ResourceItem::dump() {
|
||||
printf("Size: %d, Offset: %d\n", size, offset);
|
||||
}
|
||||
|
||||
int ResourceItem::save( Common::String filename )
|
||||
{
|
||||
FILE *fd;
|
||||
fd = fopen(filename.c_str(), "wb+");
|
||||
fwrite(data, size, 1, fd);
|
||||
fclose(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // end of namespace Asylum
|
|
@ -1,85 +0,0 @@
|
|||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef ASYLUM_RESOURCE_H
|
||||
#define ASYLUM_RESOURCE_H
|
||||
|
||||
#include "common/str.h"
|
||||
#include "common/array.h"
|
||||
|
||||
#define RES_FILE_PREFIX "res.0%02d"
|
||||
#define RESVOICE_FILE_PREFIX "res.%d04"
|
||||
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
class ResourceItem;
|
||||
|
||||
class Resource {
|
||||
public:
|
||||
Resource();
|
||||
Resource(uint32 resource);
|
||||
~Resource();
|
||||
|
||||
int load(uint32 resource);
|
||||
int load(Common::String filename);
|
||||
void dump();
|
||||
|
||||
uint32 getSize() {
|
||||
return _size;
|
||||
}
|
||||
uint32 getNumEntries() {
|
||||
return _numEntries;
|
||||
}
|
||||
ResourceItem getResource(uint32 pos);
|
||||
|
||||
// TODO: add new getResource methods which by resource index and position
|
||||
// return ResourceItem without reading the entire resource file
|
||||
|
||||
private:
|
||||
uint32 getNextValidOffset(uint8 startPos);
|
||||
|
||||
Common::String _filename;
|
||||
bool _loaded;
|
||||
uint32 _size;
|
||||
uint32 _numEntries;
|
||||
Common::Array<ResourceItem> _items;
|
||||
|
||||
}; // end of class Resource
|
||||
|
||||
class ResourceItem {
|
||||
public:
|
||||
ResourceItem();
|
||||
~ResourceItem();
|
||||
|
||||
void dump();
|
||||
int save(Common::String filename);
|
||||
|
||||
uint32 offset;
|
||||
uint32 size;
|
||||
uint8 *data;
|
||||
|
||||
}; // end of class ResourceItem
|
||||
|
||||
|
||||
} // end of namespace Asylum
|
||||
|
||||
#endif
|
101
engines/asylum/resourcemanager.cpp
Normal file
101
engines/asylum/resourcemanager.cpp
Normal file
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* resourcemanager.cpp
|
||||
*
|
||||
* Created on: 7-Jun-2009
|
||||
* Author: alex
|
||||
*/
|
||||
|
||||
#include "asylum/resourcemanager.h"
|
||||
#include "asylum/resources/palette.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
ResourceManager::ResourceManager() {
|
||||
|
||||
}
|
||||
|
||||
ResourceManager::~ResourceManager() {
|
||||
|
||||
}
|
||||
|
||||
int ResourceManager::addBundle(Common::String filename) {
|
||||
Common::File* file = new Common::File;
|
||||
Bundle* bun = new Bundle;
|
||||
|
||||
bun->id = filename;
|
||||
|
||||
// load the file
|
||||
if (!file || !file->open(filename)) {
|
||||
printf("Failed to load file %s", filename.c_str());
|
||||
return -1;
|
||||
}
|
||||
|
||||
bun->size = file->size();
|
||||
|
||||
// read the entry count
|
||||
file->read( &bun->numEntries, 4 );
|
||||
|
||||
// create the resource item array and
|
||||
// set the item offset for each entry
|
||||
for (uint8 i = 0; i < bun->numEntries; i++) {
|
||||
Resource *res = new Resource;
|
||||
file->read(&res->offset, 4);
|
||||
bun->entries.push_back(*res);
|
||||
}
|
||||
|
||||
// set the last entry's offset to the filesize
|
||||
bun->entries[bun->numEntries - 1].offset = bun->size - file->pos();
|
||||
|
||||
// calculate each entry's size based on the offset
|
||||
// information
|
||||
for (uint8 j = 0; j < bun->numEntries; j++) {
|
||||
if (bun->entries[j].offset == 0) {
|
||||
bun->entries[j].size = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
bun->entries[j].size = getNextValidOffset(bun, j+1) - bun->entries[j].offset;
|
||||
}
|
||||
|
||||
// populate the data
|
||||
for (uint8 k = 0; k < bun->numEntries; k++) {
|
||||
if (bun->entries[k].size > 0) {
|
||||
bun->entries[k].data = (uint8*)malloc(bun->entries[k].size);
|
||||
file->seek(bun->entries[k].offset, SEEK_SET);
|
||||
file->read(bun->entries[k].data, bun->entries[k].size);
|
||||
}
|
||||
}
|
||||
|
||||
file->close();
|
||||
file = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GraphicBundle ResourceManager::getGraphic(Common::String file, uint32 offset) {
|
||||
GraphicBundle *bun = new GraphicBundle(file, offset);
|
||||
|
||||
return *bun;
|
||||
}
|
||||
|
||||
PaletteResource ResourceManager::getPalette(Common::String file, uint32 offset) {
|
||||
Bundle *bun = new Bundle(file, offset);
|
||||
|
||||
PaletteResource *pal = new PaletteResource(bun->getData());
|
||||
|
||||
delete bun;
|
||||
|
||||
return *pal;
|
||||
}
|
||||
|
||||
uint32 ResourceManager::getNextValidOffset(Bundle *bun, uint8 pos) {
|
||||
for (uint8 i = pos; i < bun->numEntries; i++) {
|
||||
if (bun->entries[i].offset != 0) {
|
||||
return bun->entries[i].offset;
|
||||
}
|
||||
}
|
||||
|
||||
return bun->size;
|
||||
}
|
||||
|
||||
} // end of namespace Asylum
|
37
engines/asylum/resourcemanager.h
Normal file
37
engines/asylum/resourcemanager.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* resourcemanager.h
|
||||
*
|
||||
* Created on: 7-Jun-2009
|
||||
* Author: alex
|
||||
*/
|
||||
|
||||
#ifndef ASYLUM_RESOURCEMANAGER_H_
|
||||
#define ASYLUM_RESOURCEMANAGER_H_
|
||||
|
||||
#include "common/str.h"
|
||||
#include "common/array.h"
|
||||
|
||||
#include "asylum/bundles/bundle.h"
|
||||
#include "asylum/bundles/graphicbundle.h"
|
||||
#include "asylum/resources/palette.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
class ResourceManager {
|
||||
public:
|
||||
ResourceManager();
|
||||
~ResourceManager();
|
||||
|
||||
int addBundle(Common::String filename);
|
||||
GraphicBundle getGraphic(Common::String file, uint32 offset);
|
||||
PaletteResource getPalette(Common::String file, uint32 offset);
|
||||
|
||||
private:
|
||||
uint32 getNextValidOffset(Bundle *bun, uint8 pos);
|
||||
|
||||
}; // end of class ResourceManager
|
||||
|
||||
|
||||
} // end of namespace Asylum
|
||||
|
||||
#endif
|
12
engines/asylum/resources/graphic.cpp
Normal file
12
engines/asylum/resources/graphic.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* graphicresource.cpp
|
||||
*
|
||||
* Created on: 8-Jun-2009
|
||||
* Author: alex
|
||||
*/
|
||||
|
||||
#include "asylum/resources/graphic.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
} // end of namespace Asylum
|
31
engines/asylum/resources/graphic.h
Normal file
31
engines/asylum/resources/graphic.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* graphicresource.h
|
||||
*
|
||||
* Created on: 8-Jun-2009
|
||||
* Author: alex
|
||||
*/
|
||||
|
||||
#ifndef ASYLUM_GRAPHICRESOURCE_H_
|
||||
#define ASYLUM_GRAPHICRESOURCE_H_
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
class GraphicResource: public Resource {
|
||||
public:
|
||||
GraphicResource() {}
|
||||
~GraphicResource() {}
|
||||
|
||||
uint32 size;
|
||||
uint32 flag;
|
||||
uint16 x;
|
||||
uint16 y;
|
||||
uint16 width;
|
||||
uint16 height;
|
||||
|
||||
};
|
||||
|
||||
} // end of namespace Asylum
|
||||
|
||||
#endif /* GRAPHICRESOURCE_H_ */
|
16
engines/asylum/resources/palette.cpp
Normal file
16
engines/asylum/resources/palette.cpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* paletteresource.cpp
|
||||
*
|
||||
* Created on: 8-Jun-2009
|
||||
* Author: alex
|
||||
*/
|
||||
|
||||
#include "asylum/resources/palette.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
PaletteResource::PaletteResource(uint8* raw) {
|
||||
memcpy(data, raw+32, sizeof(uint8)*256*3); // palettes always start from offset 32
|
||||
}
|
||||
|
||||
} // end of namespace Asylum
|
29
engines/asylum/resources/palette.h
Normal file
29
engines/asylum/resources/palette.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* paletteresource.h
|
||||
*
|
||||
* Created on: 8-Jun-2009
|
||||
* Author: alex
|
||||
*/
|
||||
|
||||
#ifndef ASYLUM_PALETTERESOURCE_H_
|
||||
#define ASYLUM_PALETTERESOURCE_H_
|
||||
|
||||
#include "asylum/bundles/bundle.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
class PaletteResource: public Resource {
|
||||
public:
|
||||
PaletteResource() {}
|
||||
PaletteResource(uint8* raw);
|
||||
~PaletteResource() {}
|
||||
|
||||
// Override base data variable since
|
||||
// the final size is known
|
||||
uint8 data[256*3];
|
||||
|
||||
}; // end of class PaletteResource
|
||||
|
||||
} // end of namespace Asylum
|
||||
|
||||
#endif /* PALETTERESOURCE_H_ */
|
26
engines/asylum/resources/resource.cpp
Normal file
26
engines/asylum/resources/resource.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* resource.cpp
|
||||
*
|
||||
* Created on: 7-Jun-2009
|
||||
* Author: alex
|
||||
*/
|
||||
|
||||
#include "asylum/resources/resource.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
Resource::Resource() {
|
||||
size = 0;
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
int Resource::save(Common::String filename) {
|
||||
FILE *fd;
|
||||
fd = fopen(filename.c_str(), "wb+");
|
||||
fwrite(data, size, 1, fd);
|
||||
fclose(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // end of namespace Asylum
|
31
engines/asylum/resources/resource.h
Normal file
31
engines/asylum/resources/resource.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* resource.h
|
||||
*
|
||||
* Created on: 7-Jun-2009
|
||||
* Author: alex
|
||||
*/
|
||||
|
||||
#ifndef ASYLUM_RESOURCE_H_
|
||||
#define ASYLUM_RESOURCE_H_
|
||||
|
||||
#include "common/str.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
class Resource {
|
||||
public:
|
||||
Resource();
|
||||
virtual ~Resource(){}
|
||||
|
||||
int save(Common::String filename);
|
||||
|
||||
Common::String type;
|
||||
uint32 size;
|
||||
uint32 offset;
|
||||
uint8* data;
|
||||
|
||||
}; // end of class Resource
|
||||
|
||||
} // end of namespace Asylum
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue