WIP code for replacing the FreeSCI view decoding code with the new one (no changes to the logic, yet)
svn-id: r44717
This commit is contained in:
parent
7601f1b14f
commit
6d135e904f
14 changed files with 93 additions and 29 deletions
|
@ -32,7 +32,9 @@
|
|||
#include "sci/sci.h"
|
||||
#include "sci/gfx/gfx_resource.h"
|
||||
#include "sci/gfx/gfx_tools.h"
|
||||
#include "sci/gui/gui_palette.h"
|
||||
#include "sci/gui/gui_screen.h"
|
||||
#include "sci/gui/gui_view.h"
|
||||
#include "sci/gfx/gfx_driver.h"
|
||||
#include "sci/gfx/gfx_resmgr.h"
|
||||
#include "sci/gfx/gfx_state_internal.h"
|
||||
|
@ -50,8 +52,8 @@ struct param_struct {
|
|||
GfxDriver *driver;
|
||||
};
|
||||
|
||||
GfxResManager::GfxResManager(gfx_options_t *options, GfxDriver *driver, ResourceManager *resMan) :
|
||||
_options(options), _driver(driver), _resMan(resMan),
|
||||
GfxResManager::GfxResManager(gfx_options_t *options, GfxDriver *driver, ResourceManager *resMan, SciGuiScreen *screen, SciGuiPalette *palette) :
|
||||
_options(options), _driver(driver), _resMan(resMan), _screen(screen), _palette(palette),
|
||||
_lockCounter(0), _tagLockCounter(0), _staticPalette(0) {
|
||||
gfxr_init_static_palette();
|
||||
|
||||
|
@ -495,6 +497,58 @@ gfxr_pic_t *GfxResManager::addToPic(int old_nr, int new_nr, int flags, int old_d
|
|||
}
|
||||
|
||||
gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) {
|
||||
|
||||
// Wrapper code for the new view decoder - still WIP
|
||||
#if 0
|
||||
|
||||
IntResMap &resMap = _resourceMaps[GFX_RESOURCE_TYPE_VIEW];
|
||||
gfx_resource_t *res = NULL;
|
||||
gfxr_view_t *result = (gfxr_view_t *)malloc(sizeof(gfxr_view_t));
|
||||
|
||||
result->ID = nr;
|
||||
result->flags = 0;
|
||||
|
||||
SciGuiView *view = new SciGuiView(_resMan, _screen, _palette, nr);
|
||||
|
||||
result->loops_nr = view->getLoopCount();
|
||||
result->palette = NULL;
|
||||
result->loops = (gfxr_loop_t*)malloc(sizeof(gfxr_loop_t) * ((result->loops_nr) ? result->loops_nr : 1)); /* Alloc 1 if no loop */
|
||||
|
||||
if (*loop >= result->loops_nr)
|
||||
*loop = result->loops_nr - 1;
|
||||
|
||||
for (int i = 0; i < result->loops_nr; i++) {
|
||||
result->loops[i].cels_nr = view->getLoopInfo(i)->celCount;
|
||||
result->loops[i].cels = (gfx_pixmap_t**)calloc(result->loops[i].cels_nr, sizeof(gfx_pixmap_t *));
|
||||
|
||||
if (*cel >= result->loops[i].cels_nr)
|
||||
*cel = result->loops[i].cels_nr - 1;
|
||||
|
||||
for (int j = 0; j < result->loops[i].cels_nr; j++) {
|
||||
sciViewCelInfo *celInfo = view->getCelInfo(i, j);
|
||||
result->loops[i].cels[j] = gfx_pixmap_alloc_index_data(gfx_new_pixmap(celInfo->width, celInfo->height, nr, i, j));
|
||||
gfx_pixmap_t *curCel = result->loops[i].cels[j];
|
||||
curCel->alpha_map = 0; // TODO
|
||||
curCel->color_key = celInfo->clearKey;
|
||||
curCel->index_data = view->getBitmap(i, j);
|
||||
curCel->data = curCel->index_data;
|
||||
curCel->flags = 0;
|
||||
curCel->width = celInfo->width;
|
||||
curCel->height = celInfo->height;
|
||||
curCel->index_width = celInfo->width;
|
||||
curCel->index_height = celInfo->height;
|
||||
curCel->palette = 0; // TODO
|
||||
curCel->palette_revision = 0;
|
||||
curCel->xoffset = celInfo->displaceX;
|
||||
curCel->yoffset = celInfo->displaceY;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
#else
|
||||
|
||||
// Existing code
|
||||
IntResMap &resMap = _resourceMaps[GFX_RESOURCE_TYPE_VIEW];
|
||||
gfx_resource_t *res = NULL;
|
||||
int hash = palette;
|
||||
|
@ -585,6 +639,8 @@ gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) {
|
|||
}
|
||||
|
||||
return view;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
gfx_bitmap_font_t *GfxResManager::getFont(int num, bool scaled) {
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
// or something like that.
|
||||
|
||||
#include "sci/gfx/gfx_resource.h"
|
||||
#include "sci/gui/gui_palette.h"
|
||||
#include "sci/resource.h"
|
||||
|
||||
#include "common/hashmap.h"
|
||||
|
@ -90,7 +91,7 @@ typedef Common::HashMap<int, gfx_resource_t *> IntResMap;
|
|||
/** Graphics resource manager */
|
||||
class GfxResManager {
|
||||
public:
|
||||
GfxResManager(gfx_options_t *options, GfxDriver *driver, ResourceManager *resMan);
|
||||
GfxResManager(gfx_options_t *options, GfxDriver *driver, ResourceManager *resMan, SciGuiScreen *screen, SciGuiPalette *palette);
|
||||
~GfxResManager();
|
||||
|
||||
/**
|
||||
|
@ -303,6 +304,8 @@ private:
|
|||
|
||||
IntResMap _resourceMaps[GFX_RESOURCE_TYPES_NR];
|
||||
ResourceManager *_resMan;
|
||||
SciGuiScreen *_screen;
|
||||
SciGuiPalette *_palette;
|
||||
};
|
||||
|
||||
} // End of namespace Sci
|
||||
|
|
|
@ -386,7 +386,7 @@ static void init_aux_pixmap(gfx_pixmap_t **pixmap) {
|
|||
|
||||
void gfxop_init(GfxState *state,
|
||||
gfx_options_t *options, ResourceManager *resMan,
|
||||
SciGuiScreen *screen, int scaleFactor) {
|
||||
SciGuiScreen *screen, SciGuiPalette *palette, int scaleFactor) {
|
||||
state->options = options;
|
||||
state->visible_map = GFX_MASK_VISUAL;
|
||||
state->fullscreen_override = NULL; // No magical override
|
||||
|
@ -401,7 +401,7 @@ void gfxop_init(GfxState *state,
|
|||
|
||||
state->driver = new GfxDriver(screen, scaleFactor);
|
||||
|
||||
state->gfxResMan = new GfxResManager(state->options, state->driver, resMan);
|
||||
state->gfxResMan = new GfxResManager(state->options, state->driver, resMan, screen, palette);
|
||||
|
||||
gfxop_set_clip_zone(state, gfx_rect(0, 0, 320, 200));
|
||||
state->pointerZone = Common::Rect(0, 0, 320, 200);
|
||||
|
|
|
@ -143,7 +143,7 @@ struct GfxState {
|
|||
*/
|
||||
void gfxop_init(GfxState *state,
|
||||
gfx_options_t *options, ResourceManager *resMan,
|
||||
SciGuiScreen *screen, int scaleFactor = 1);
|
||||
SciGuiScreen *screen, SciGuiPalette *palette, int scaleFactor = 1);
|
||||
|
||||
/**
|
||||
* Deinitializes a currently active driver.
|
||||
|
|
|
@ -41,11 +41,9 @@
|
|||
|
||||
namespace Sci {
|
||||
|
||||
SciGui::SciGui(OSystem *system, EngineState *state, SciGuiScreen *screen)
|
||||
: _system(system), _s(state), _screen(screen) {
|
||||
_picNotValid = 0;
|
||||
SciGui::SciGui(OSystem *system, EngineState *state, SciGuiScreen *screen, SciGuiPalette *palette)
|
||||
: _system(system), _s(state), _screen(screen), _palette(palette) {
|
||||
|
||||
_palette = new SciGuiPalette(_s, this, _screen);
|
||||
_gfx = new SciGuiGfx(_s, _screen, _palette);
|
||||
_windowMgr = new SciGuiWindowMgr(_s, _gfx);
|
||||
}
|
||||
|
@ -266,7 +264,7 @@ void SciGui::drawPicture(GuiResourceId pictureId, uint16 style, uint16 flags, in
|
|||
_screen->copyToScreen();
|
||||
|
||||
_gfx->SetPort(oldPort);
|
||||
_picNotValid = true;
|
||||
_screen->_picNotValid = true;
|
||||
}
|
||||
|
||||
void SciGui::drawCel(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, uint16 leftPos, uint16 topPos, int16 priority, uint16 paletteNo) {
|
||||
|
@ -379,13 +377,13 @@ int16 SciGui::onControl(byte screenMask, Common::Rect rect) {
|
|||
}
|
||||
|
||||
void SciGui::animate(reg_t listReference, bool cycle, int argc, reg_t *argv) {
|
||||
bool old_picNotValid = _picNotValid;
|
||||
bool old_picNotValid = _screen->_picNotValid;
|
||||
|
||||
if (listReference.isNull()) {
|
||||
_gfx->AnimateDisposeLastCast();
|
||||
if (_picNotValid) {
|
||||
if (_screen->_picNotValid) {
|
||||
//(this->*ShowPic)(_showMap, _showStyle);
|
||||
_picNotValid = 0;
|
||||
_screen->_picNotValid = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -409,9 +407,9 @@ void SciGui::animate(reg_t listReference, bool cycle, int argc, reg_t *argv) {
|
|||
|
||||
_gfx->AnimateDrawCels();
|
||||
|
||||
if (_picNotValid) {
|
||||
if (_screen->_picNotValid) {
|
||||
//(this->*ShowPic)(_showMap, _showStyle);
|
||||
_picNotValid = 0;
|
||||
_screen->_picNotValid = false;
|
||||
}
|
||||
|
||||
//_gfx->AnimateUpdateScreen();
|
||||
|
@ -449,7 +447,7 @@ void SciGui::addToPicList(reg_t listReference, int argc, reg_t *argv) {
|
|||
// }
|
||||
// animSort(arrObj, arrY, szList);
|
||||
|
||||
_picNotValid = 2;
|
||||
_screen->_picNotValid = 2; // FIXME: _picNotValid is a boolean!
|
||||
|
||||
delete sortedList;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class SciGuiresources;
|
|||
class SciGuiWindowMgr;
|
||||
class SciGui {
|
||||
public:
|
||||
SciGui(OSystem *system, EngineState *s, SciGuiScreen *screen);
|
||||
SciGui(OSystem *system, EngineState *s, SciGuiScreen *screen, SciGuiPalette *palette);
|
||||
SciGui();
|
||||
virtual ~SciGui();
|
||||
|
||||
|
@ -89,7 +89,7 @@ public:
|
|||
virtual void moveCursor(int16 x, int16 y, int16 scaleFactor = 1);
|
||||
void moveCursor(Common::Point p, int16 scaleFactor = 1) { moveCursor(p.x, p.y, scaleFactor); }
|
||||
|
||||
int _picNotValid; // possible values 0, 1 and 2
|
||||
SciGuiPalette *getPalette() { return _palette; }
|
||||
|
||||
private:
|
||||
OSystem *_system;
|
||||
|
|
|
@ -34,8 +34,8 @@
|
|||
|
||||
namespace Sci {
|
||||
|
||||
SciGuiPalette::SciGuiPalette(EngineState *state, SciGui *gui, SciGuiScreen *screen)
|
||||
: _s(state), _gui(gui), _screen(screen) {
|
||||
SciGuiPalette::SciGuiPalette(EngineState *state, SciGuiScreen *screen)
|
||||
: _s(state), _screen(screen) {
|
||||
init();
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ void SciGuiPalette::set(GuiPalette *sciPal, int16 flag) {
|
|||
if (flag == 2 || sciPal->timestamp != systime) {
|
||||
merge(sciPal, &_sysPalette, flag);
|
||||
sciPal->timestamp = _sysPalette.timestamp;
|
||||
if (_gui->_picNotValid == 0 && systime != _sysPalette.timestamp)
|
||||
if (_screen->_picNotValid == 0 && systime != _sysPalette.timestamp)
|
||||
setOnScreen();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace Sci {
|
|||
class SciGuiScreen;
|
||||
class SciGuiPalette {
|
||||
public:
|
||||
SciGuiPalette(EngineState *state, SciGui *gui, SciGuiScreen *screen);
|
||||
SciGuiPalette(EngineState *state, SciGuiScreen *screen);
|
||||
~SciGuiPalette();
|
||||
|
||||
void init();
|
||||
|
@ -56,7 +56,6 @@ public:
|
|||
|
||||
private:
|
||||
EngineState *_s;
|
||||
SciGui *_gui;
|
||||
SciGuiScreen *_screen;
|
||||
|
||||
uint16 _clrPowers[256];
|
||||
|
|
|
@ -55,6 +55,8 @@ SciGuiScreen::SciGuiScreen(OSystem *system, int16 width, int16 height, int16 sca
|
|||
_baseTable[i] = base; _baseDisplayTable[i] = base;
|
||||
base += _width;
|
||||
}
|
||||
|
||||
_picNotValid = false;
|
||||
}
|
||||
|
||||
SciGuiScreen::~SciGuiScreen() {
|
||||
|
|
|
@ -70,6 +70,8 @@ public:
|
|||
uint16 _displayHeight;
|
||||
uint _displayPixels;
|
||||
|
||||
int _picNotValid; // possible values 0, 1 and 2
|
||||
|
||||
private:
|
||||
void restoreBitsScreen(Common::Rect rect, byte *&memoryPtr, byte *screen);
|
||||
void saveBitsScreen(Common::Rect rect, byte *screen, byte *&memoryPtr);
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
void getCelRect(GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 x, int16 y, int16 z, Common::Rect *outRect);
|
||||
byte *getBitmap(GuiViewLoopNo loopNo, GuiViewCelNo celNo);
|
||||
void draw(Common::Rect rect, Common::Rect clipRect, Common::Rect clipRectTranslated, GuiViewLoopNo loopNo, GuiViewCelNo celNo, byte priority, uint16 paletteNo);
|
||||
uint16 getLoopCount() const { return _loopCount; }
|
||||
|
||||
private:
|
||||
void initData(GuiResourceId resourceId);
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
|
||||
namespace Sci {
|
||||
|
||||
SciGui32::SciGui32(OSystem *system, EngineState *state, SciGuiScreen *screen)
|
||||
SciGui32::SciGui32(OSystem *system, EngineState *state, SciGuiScreen *screen, SciGuiPalette *palette)
|
||||
: _system(system), s(state) {
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Sci {
|
|||
|
||||
class SciGui32 : public SciGui {
|
||||
public:
|
||||
SciGui32(OSystem *system, EngineState *s, SciGuiScreen *screen);
|
||||
SciGui32(OSystem *system, EngineState *s, SciGuiScreen *screen, SciGuiPalette *palette);
|
||||
~SciGui32();
|
||||
|
||||
// FIXME: Don't store EngineState
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
#include "sci/gfx/gfx_state_internal.h" // required for GfxContainer, GfxPort, GfxVisual
|
||||
#include "sci/gui32/gui32.h"
|
||||
#include "sci/gui/gui_palette.h"
|
||||
|
||||
#include "sci/gfx/gfx_resource.h"
|
||||
#include "sci/gfx/gfx_tools.h"
|
||||
|
@ -156,10 +157,11 @@ Common::Error SciEngine::run() {
|
|||
_gamestate->gfx_state = &gfx_state;
|
||||
|
||||
SciGuiScreen *screen = new SciGuiScreen(_system);
|
||||
SciGuiPalette *palette = new SciGuiPalette(_gamestate, screen);
|
||||
|
||||
// Gui change
|
||||
//_gamestate->gui = new SciGui(_system, _gamestate, screen); // new
|
||||
_gamestate->gui = new SciGui32(_system, _gamestate, screen); // old
|
||||
//_gamestate->gui = new SciGui(_system, _gamestate, screen, palette); // new
|
||||
_gamestate->gui = new SciGui32(_system, _gamestate, screen, palette); // old
|
||||
|
||||
// Assign default values to the config manager, in case settings are missing
|
||||
ConfMan.registerDefault("dither_mode", "0");
|
||||
|
@ -180,7 +182,7 @@ Common::Error SciEngine::run() {
|
|||
// Default config ends
|
||||
#endif
|
||||
|
||||
gfxop_init(&gfx_state, &gfx_options, _resMan, screen, 1);
|
||||
gfxop_init(&gfx_state, &gfx_options, _resMan, screen, palette, 1);
|
||||
|
||||
if (game_init_graphics(_gamestate)) { // Init interpreter graphics
|
||||
warning("Game initialization failed: Error in GFX subsystem. Aborting...");
|
||||
|
@ -202,6 +204,7 @@ Common::Error SciEngine::run() {
|
|||
script_free_engine(_gamestate); // Uninitialize game state
|
||||
script_free_breakpoints(_gamestate);
|
||||
|
||||
delete palette;
|
||||
delete screen;
|
||||
delete _gamestate;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue