ASYLUM: First testes displaying Main Menu background image with still wrong palette.

git-svn-id: http://asylumengine.googlecode.com/svn/trunk@25 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
This commit is contained in:
Alexandre Fontoura 2009-06-06 23:23:04 +00:00 committed by Eugene Sandulenko
parent 9e7d8f1dc6
commit a179512aca
No known key found for this signature in database
GPG key ID: 014D387312D34F08
12 changed files with 131 additions and 18 deletions

View file

@ -43,6 +43,7 @@ AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
AsylumEngine::~AsylumEngine() { AsylumEngine::~AsylumEngine() {
//Common::clearAllDebugChannels(); //Common::clearAllDebugChannels();
delete _menu;
delete _screen; delete _screen;
} }
@ -79,11 +80,11 @@ Common::Error AsylumEngine::go() {
res->load(1); res->load(1);
res->dump(); res->dump();
GraphicResource *gres = new GraphicResource( res->getResource(1) ); //GraphicResource *gres = new GraphicResource( res->getResource(1) );
gres->dump(); //gres->dump();
delete res; delete res;
delete gres; //delete gres;
_menu->init(); _menu->init();

View file

@ -78,6 +78,11 @@ GraphicResource::GraphicResource(ResourceItem item) {
GraphicResource::~GraphicResource() { GraphicResource::~GraphicResource() {
} }
GraphicAsset GraphicResource::getGraphicAsset(uint8 index){
// TODO bounds check the array accessor
return _items[index];
}
void GraphicResource::dump() { 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 ); 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 );
} }

View file

@ -36,6 +36,8 @@ public:
GraphicResource(ResourceItem item); GraphicResource(ResourceItem item);
~GraphicResource(); ~GraphicResource();
GraphicAsset getGraphicAsset(uint8 index);
void dump(); void dump();
private: private:

View file

@ -21,7 +21,8 @@
#include "asylum/menu.h" #include "asylum/menu.h"
#include "asylum/resource.h" #include "asylum/resource.h"
#include "asylum/graphics.h"
#include "asylum/palette.h"
namespace Asylum { namespace Asylum {
@ -33,23 +34,29 @@ Menu::Menu(Screen *screen){
} }
Menu::~Menu() { Menu::~Menu() {
if(_bkgImageBuf){ delete _res1;
free(_bkgImageBuf);
}
if(_mouseIconBuf){
free(_mouseIconBuf);
}
} }
void Menu::init(){ void Menu::init(){
printf("Menu: init()\n"); printf("Menu: init()\n");
_res1 = new Resource(1);
// TODO: from address 0041A500 (init background music, setup menu environment like palette, font, gamma level, etc.) // 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);
// TESTING...
GraphicResource *gres = new GraphicResource(_res1->getResource(0));
_screen->setFrontBuffer(0, 0, SCREEN_WIDTH, SCREEN_DEPTH, gres->getGraphicAsset(0).data);
} }
void Menu::run(){ void Menu::run(){
//printf("Menu: running...\n"); //printf("Menu: running...\n");
_screen->setPalette(_palette);
// TODO: get background image // TODO: get background image
// blit it into back buffer and front buffer // blit it into back buffer and front buffer

View file

@ -23,6 +23,9 @@
#define ASYLUM_MENU_H #define ASYLUM_MENU_H
#include "asylum/screen.h" #include "asylum/screen.h"
#include "asylum/resource.h"
#define MENU_PAL_ENTRY 17
namespace Asylum { namespace Asylum {
@ -44,13 +47,17 @@ private:
static const uint32 eyesTable[8]; static const uint32 eyesTable[8];
/** Background image buffer */ /** Background image buffer */
uint8 _bkgImageBuf[SCREEN_WIDTH*SCREEN_DEPTH]; //uint8 _bkgImageBuf[SCREEN_WIDTH*SCREEN_DEPTH];
/** Mouse icon resource image buffer */ /** Mouse icon resource image buffer */
uint8 *_mouseIconBuf; uint8 *_mouseIconBuf;
/** Menu palette */ /** Menu palette */
uint8 _palette[PAL_SIZE * 4]; uint8 _palette[PAL_SIZE];
// 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 } // namespace Asylum

View file

@ -6,7 +6,8 @@ MODULE_OBJS := \
resource.o \ resource.o \
asylum.o \ asylum.o \
screen.o \ screen.o \
menu.o menu.o \
palette.o
# This module can be built as a plugin # This module can be built as a plugin
ifeq ($(ENABLE_ASYLUM), DYNAMIC_PLUGIN) ifeq ($(ENABLE_ASYLUM), DYNAMIC_PLUGIN)

View file

@ -0,0 +1,44 @@
/* 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){
int pos = 32; // palettes always start from offset 32
for (int i = 0; i < PAL_SIZE; i++) {
_buffer[i] = item.data[pos];
_buffer[i+1] = item.data[pos+1];
_buffer[i+3] = item.data[pos+2];
pos+=3;
}
}
Palette::~Palette() {
/*if(_buffer){
free(_buffer);
}*/
}
} // namespace Asylum

42
engines/asylum/palette.h Normal file
View file

@ -0,0 +1,42 @@
/* 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];
};
} // namespace Asylum
#endif

View file

@ -29,8 +29,11 @@ namespace Asylum {
// Resource // // Resource //
////////////// //////////////
Resource::Resource() Resource::Resource(){
{ }
Resource::Resource(uint32 resource){
load(resource);
} }
Resource::~Resource() { Resource::~Resource() {

View file

@ -36,6 +36,7 @@ class ResourceItem;
class Resource { class Resource {
public: public:
Resource(); Resource();
Resource(uint32 resource);
~Resource(); ~Resource();
int load(uint32 resource); int load(uint32 resource);

View file

@ -47,11 +47,11 @@ Screen::~Screen(){
} }
void Screen::setFrontBuffer(int32 x, int32 y, int32 width, int32 height, uint8 *buffer){ void Screen::setFrontBuffer(int32 x, int32 y, int32 width, int32 height, uint8 *buffer){
copyBuffer(x, y, width, height, _frontBuf, buffer); copyBuffer(x, y, width, height, buffer, _frontBuf);
} }
void Screen::setBackBuffer(int32 x, int32 y, int32 width, int32 height, uint8 *buffer){ void Screen::setBackBuffer(int32 x, int32 y, int32 width, int32 height, uint8 *buffer){
copyBuffer(x, y, width, height, _backBuf, buffer); copyBuffer(x, y, width, height, buffer, _backBuf);
} }
void Screen::copyBuffer(int32 x, int32 y, int32 width, int32 height, uint8 *src, uint8 *dst){ void Screen::copyBuffer(int32 x, int32 y, int32 width, int32 height, uint8 *src, uint8 *dst){

View file

@ -28,7 +28,7 @@
class OSystem; class OSystem;
#define SCREEN_WIDTH 640 #define SCREEN_WIDTH 640
#define SCREEN_DEPTH 400 #define SCREEN_DEPTH 480
#define PAL_SIZE 256 #define PAL_SIZE 256