mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-05 17:20:30 +00:00
ASYLUM: * rename resourcemanager to resman
* more reorganization * moved paletteresource to palette bundle because that's technically where it belongs * initial cursor support (VERY initial) git-svn-id: http://asylumengine.googlecode.com/svn/trunk@36 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
This commit is contained in:
parent
095d9886f2
commit
c950bfab5e
@ -81,6 +81,7 @@ Common::Error AsylumEngine::go() {
|
||||
// ScummVM window alive until ESC is pressed.
|
||||
// This will facilitate drawing tests ;)
|
||||
bool end = false;
|
||||
int updateCounter = 0;
|
||||
Common::EventManager *em = _system->getEventManager();
|
||||
while (!end) {
|
||||
Common::Event ev;
|
||||
@ -90,6 +91,14 @@ Common::Error AsylumEngine::go() {
|
||||
end = true;
|
||||
//if (ev.kbd.keycode == Common::KEYCODE_RETURN)
|
||||
}
|
||||
if (ev.type == Common::EVENT_MOUSEMOVE) {
|
||||
updateCounter++;
|
||||
if(updateCounter>6){
|
||||
_screen->updateScreen();
|
||||
updateCounter = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
_system->delayMillis(10);
|
||||
}
|
||||
@ -100,11 +109,19 @@ Common::Error AsylumEngine::go() {
|
||||
void AsylumEngine::showMainMenu() {
|
||||
// eyes animation index table
|
||||
//const uint32 eyesTable[8] = {3, 5, 1, 7, 4, 8, 2, 6};
|
||||
PaletteBundle *pal = _resMgr->getPalette(1, 17);
|
||||
GraphicResource *bg = _resMgr->getGraphic(1, 0)->getEntry(0);
|
||||
GraphicResource *cur = _resMgr->getGraphic(1, 2)->getEntry(0);
|
||||
|
||||
_system->setMouseCursor(cur->data, cur->width, cur->height, 1, 1, 0);
|
||||
_system->setCursorPalette(pal->palette, 0, 768);
|
||||
_system->showMouse(true);
|
||||
|
||||
_screen->setFrontBuffer(
|
||||
0, 0,
|
||||
SCREEN_WIDTH, SCREEN_DEPTH,
|
||||
_resMgr->getGraphic("res.001",0).getEntry(0).data);
|
||||
_screen->setPalette(_resMgr->getPalette("res.001", 17).data);
|
||||
bg->width, bg->height,
|
||||
bg->data);
|
||||
_screen->setPalette(pal->palette);
|
||||
_screen->updateScreen();
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "engines/engine.h"
|
||||
|
||||
#include "asylum/resourcemanager.h"
|
||||
#include "asylum/resman.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
|
@ -21,29 +21,86 @@
|
||||
#include "common/file.h"
|
||||
|
||||
#include "asylum/bundles/bundle.h"
|
||||
#include "asylum/offsets.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
Bundle::Bundle() {
|
||||
size = 0;
|
||||
numEntries = 0;
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
Bundle::Bundle(Common::String filename, uint32 index) {
|
||||
loadRaw(filename, index);
|
||||
Bundle::Bundle(uint8 fileNum) {
|
||||
Common::File* file = new Common::File;
|
||||
Common::String filename = parseFilename(fileNum);
|
||||
|
||||
id = fileNum;
|
||||
|
||||
// load the file
|
||||
if (!file || !file->open(filename)) {
|
||||
printf("Failed to load file %s", filename.c_str());
|
||||
}else{
|
||||
// set the filesize
|
||||
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++) {
|
||||
Bundle *bun = new Bundle;
|
||||
file->read(&bun->offset, 4);
|
||||
bun->initialized = false;
|
||||
entries.push_back(bun);
|
||||
}
|
||||
|
||||
// set the last entry's offset to the filesize
|
||||
entries[numEntries - 1]->offset = size - file->pos();
|
||||
|
||||
// calculate each entry's size based on the offset
|
||||
// information
|
||||
for (uint8 j = 0; j < numEntries; j++) {
|
||||
if (entries[j]->offset == 0) {
|
||||
entries[j]->size = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
entries[j]->size = getNextValidOffset(j+1) - entries[j]->offset;
|
||||
}
|
||||
|
||||
/* Skip population phase
|
||||
// populate the data
|
||||
for (uint8 k = 0; k < numEntries; k++) {
|
||||
if (entries[k].size > 0) {
|
||||
entries[k].data = (uint8*)malloc(entries[k].size);
|
||||
file->seek(entries[k].offset, SEEK_SET);
|
||||
file->read(entries[k].data, entries[k].size);
|
||||
}
|
||||
|
||||
// DEBUGGING
|
||||
// Dump bundles to file
|
||||
//char fn[20];
|
||||
//sprintf(fn, "RES000-0%02d.DAT", k);
|
||||
//entries[k].save(Common::String(fn));
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
file->close();
|
||||
file = NULL;
|
||||
}
|
||||
|
||||
int Bundle::loadRaw(Common::String filename, uint32 index) {
|
||||
void Bundle::loadRawRecord(Common::String filename, uint32 index, uint32 length) {
|
||||
|
||||
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];
|
||||
offset = index;
|
||||
size = length;
|
||||
|
||||
data = (uint8*)malloc(size);
|
||||
file->seek(offset, SEEK_SET);
|
||||
@ -53,8 +110,28 @@ int Bundle::loadRaw(Common::String filename, uint32 index) {
|
||||
file = NULL;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
return 0;
|
||||
void Bundle::setEntry(uint32 index, Bundle* value) {
|
||||
value->initialized = true;
|
||||
entries[index] = value;
|
||||
}
|
||||
|
||||
Common::String Bundle::parseFilename(uint8 fileNum) {
|
||||
char filename[20];
|
||||
sprintf(filename, RESMASK, fileNum);
|
||||
|
||||
return Common::String(filename);
|
||||
}
|
||||
|
||||
uint32 Bundle::getNextValidOffset(uint8 index) {
|
||||
for (uint8 i = index; i < numEntries; i++) {
|
||||
if (entries[i]->offset != 0) {
|
||||
return entries[i]->offset;
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
} // end of namespace Asylum
|
||||
|
@ -33,22 +33,33 @@
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
#define RESMASK "res.0%02d"
|
||||
|
||||
class Bundle {
|
||||
|
||||
public:
|
||||
Bundle();
|
||||
Bundle(Common::String filename, uint32 index);
|
||||
Bundle(uint8 fileNum);
|
||||
virtual ~Bundle() {}
|
||||
|
||||
Common::String id;
|
||||
uint32 size;
|
||||
uint32 numEntries;
|
||||
Common::Array<Resource> entries;
|
||||
uint8* getData() { return data; }
|
||||
Bundle* getEntry(uint32 index) { return entries[index]; }
|
||||
void setEntry(uint32 index, Bundle* value);
|
||||
|
||||
uint8 id;
|
||||
uint32 size;
|
||||
uint32 offset;
|
||||
uint32 numEntries;
|
||||
bool initialized;
|
||||
|
||||
|
||||
uint8* getData() { return data; }
|
||||
protected:
|
||||
int loadRaw(Common::String filename, uint32 index);
|
||||
Common::Array<Bundle*> entries;
|
||||
Common::String parseFilename(uint8 fileNum);
|
||||
void loadRawRecord(Common::String filename, uint32 index, uint32 length);
|
||||
uint32 getNextValidOffset(uint8 index);
|
||||
virtual void update(){}
|
||||
|
||||
uint8 *data;
|
||||
|
||||
private:
|
||||
|
@ -23,8 +23,8 @@
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
GraphicBundle::GraphicBundle(Common::String filename, uint32 index) {
|
||||
loadRaw(filename, index);
|
||||
GraphicBundle::GraphicBundle(uint8 fileNum, uint32 index, uint32 length) {
|
||||
loadRawRecord(parseFilename(fileNum), index, length);
|
||||
}
|
||||
|
||||
void GraphicBundle::update() {
|
||||
@ -65,12 +65,12 @@ void GraphicBundle::update() {
|
||||
gra->data = (uint8*)malloc(gra->size - 16);
|
||||
memcpy(gra->data, data + pos, gra->size - 16);
|
||||
|
||||
entries.push_back(*gra);
|
||||
entries.push_back(gra);
|
||||
}
|
||||
}
|
||||
|
||||
GraphicResource GraphicBundle::getEntry(uint32 index) {
|
||||
return (GraphicResource)entries[index];
|
||||
GraphicResource* GraphicBundle::getEntry(uint32 index) {
|
||||
return (GraphicResource*)entries[index];
|
||||
}
|
||||
|
||||
} // end of namespace Asylum
|
||||
|
@ -30,14 +30,14 @@ namespace Asylum {
|
||||
class GraphicBundle: public Bundle {
|
||||
public:
|
||||
GraphicBundle() {}
|
||||
GraphicBundle(Common::String filename, uint32 index);
|
||||
GraphicBundle(uint8 fileNum, uint32 index, uint32 length);
|
||||
~GraphicBundle() {}
|
||||
|
||||
Common::Array<GraphicResource> entries;
|
||||
GraphicResource getEntry(uint32 index);
|
||||
GraphicResource* getEntry(uint32 index);
|
||||
|
||||
protected:
|
||||
void update();
|
||||
Common::Array<GraphicResource*> entries;
|
||||
|
||||
private:
|
||||
uint32 _tagValue;
|
||||
|
34
engines/asylum/bundles/palettebundle.cpp
Normal file
34
engines/asylum/bundles/palettebundle.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* PaletteBundle.cpp
|
||||
*
|
||||
* Created on: 9-Jun-2009
|
||||
* Author: alex
|
||||
*/
|
||||
|
||||
#include "asylum/bundles/palettebundle.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
PaletteBundle::PaletteBundle(uint8 fileNum, uint32 index, uint32 length) {
|
||||
loadRawRecord(parseFilename(fileNum), index, length);
|
||||
}
|
||||
|
||||
void PaletteBundle::update() {
|
||||
|
||||
}
|
||||
|
||||
uint8* PaletteBundle::getPalette(uint8 brightness) {
|
||||
// palettes always start from offset 32
|
||||
memcpy(palette, data+32, sizeof(uint8)*256*3);
|
||||
|
||||
for (int i = 0; i < 256; i++) {
|
||||
*p++ = *palette++ * brightness;
|
||||
*p++ = *palette++ * brightness;
|
||||
*p++ = *palette++ * brightness;
|
||||
*p++ = 0;
|
||||
}
|
||||
|
||||
return palette;
|
||||
}
|
||||
|
||||
} // end of namespace Asylum
|
31
engines/asylum/bundles/palettebundle.h
Normal file
31
engines/asylum/bundles/palettebundle.h
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* PaletteBundle.h
|
||||
*
|
||||
* Created on: 9-Jun-2009
|
||||
* Author: alex
|
||||
*/
|
||||
|
||||
#ifndef PALETTEBUNDLE_H_
|
||||
#define PALETTEBUNDLE_H_
|
||||
|
||||
#include "asylum/bundles/bundle.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
class PaletteBundle: public Bundle {
|
||||
public:
|
||||
PaletteBundle() {}
|
||||
PaletteBundle(uint8 fileNum, uint32 index, uint32 length);
|
||||
|
||||
~PaletteBundle() {}
|
||||
|
||||
uint8* getPalette(uint8 brightness);
|
||||
|
||||
protected:
|
||||
uint8 palette[256*3];
|
||||
void update();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* PALETTEBUNDLE_H_ */
|
@ -1,16 +1,15 @@
|
||||
MODULE := engines/asylum
|
||||
|
||||
MODULE_OBJS := \
|
||||
bundles/bundle.o \
|
||||
bundles/graphicbundle.o \
|
||||
resources/resource.o \
|
||||
resources/graphic.o \
|
||||
resources/palette.o \
|
||||
asylum.o \
|
||||
detection.o \
|
||||
resourcemanager.o \
|
||||
screen.o
|
||||
|
||||
resman.o \
|
||||
screen.o \
|
||||
bundles/bundle.o \
|
||||
bundles/graphicbundle.o \
|
||||
bundles/palettebundle.o \
|
||||
resources/resource.o \
|
||||
resources/graphic.o
|
||||
|
||||
# This module can be built as a plugin
|
||||
ifeq ($(ENABLE_ASYLUM), DYNAMIC_PLUGIN)
|
||||
|
66
engines/asylum/resman.cpp
Normal file
66
engines/asylum/resman.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
/* 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/resman.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
GraphicBundle* ResourceManager::getGraphic(uint8 fileNum, uint32 offset) {
|
||||
Bundle *bun = getBundle(fileNum);
|
||||
Bundle *ent = bun->getEntry(offset);
|
||||
|
||||
if(!ent->initialized){
|
||||
GraphicBundle *gra = new GraphicBundle(fileNum, ent->offset, ent->size);
|
||||
bun->setEntry(offset, gra);
|
||||
}
|
||||
|
||||
return (GraphicBundle*)bun->getEntry(offset);
|
||||
}
|
||||
|
||||
PaletteBundle* ResourceManager::getPalette(uint8 fileNum, uint32 offset) {
|
||||
Bundle *bun = getBundle(fileNum);
|
||||
Bundle *ent = bun->getEntry(offset);
|
||||
if(!ent->initialized){
|
||||
PaletteBundle *pal = new PaletteBundle(fileNum, ent->offset, ent->size);
|
||||
bun->setEntry(offset, pal);
|
||||
}
|
||||
|
||||
return (PaletteBundle*)bun->getEntry(offset);
|
||||
}
|
||||
|
||||
Bundle* ResourceManager::getBundle(uint8 fileNum) {
|
||||
// first check if the bundle exists in the cache
|
||||
Bundle* bun = NULL;
|
||||
|
||||
for (uint32 i = 0; i < _bundleCache.size(); i++) {
|
||||
if (_bundleCache[i].id == fileNum ){
|
||||
*bun = _bundleCache[i];
|
||||
}
|
||||
}
|
||||
|
||||
if(!bun) {
|
||||
bun = new Bundle(fileNum);
|
||||
}
|
||||
|
||||
return bun;
|
||||
}
|
||||
|
||||
} // end of namespace Asylum
|
52
engines/asylum/resman.h
Normal file
52
engines/asylum/resman.h
Normal file
@ -0,0 +1,52 @@
|
||||
/* 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_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/bundles/palettebundle.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
class ResourceManager {
|
||||
public:
|
||||
ResourceManager() {};
|
||||
~ResourceManager() {};
|
||||
|
||||
GraphicBundle* getGraphic(uint8 fileNum, uint32 offset);
|
||||
PaletteBundle* getPalette(uint8 fileNum, uint32 offset);
|
||||
|
||||
private:
|
||||
Common::Array<Bundle> _bundleCache;
|
||||
|
||||
Bundle* getBundle(uint8 fileNum);
|
||||
|
||||
}; // end of class ResourceManager
|
||||
|
||||
|
||||
} // end of namespace Asylum
|
||||
|
||||
#endif
|
@ -24,8 +24,9 @@
|
||||
namespace Asylum {
|
||||
|
||||
Resource::Resource() {
|
||||
size = 0;
|
||||
offset = 0;
|
||||
size = 0;
|
||||
offset = 0;
|
||||
initialized = false;
|
||||
}
|
||||
|
||||
int Resource::save(Common::String filename) {
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
uint32 size;
|
||||
uint32 offset;
|
||||
uint8* data;
|
||||
bool initialized;
|
||||
|
||||
}; // end of class Resource
|
||||
|
||||
|
@ -31,7 +31,7 @@ class OSystem;
|
||||
#define SCREEN_DEPTH 480
|
||||
|
||||
#define PAL_SIZE 256
|
||||
#define BRIGHTNESS 7
|
||||
#define BRIGHTNESS 6
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user