mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-04 01:46:42 +00:00
VOYEUR: Implemented more doHeadTitle startup code, and startFade
This commit is contained in:
parent
2a2e1a08cf
commit
6bce04959b
@ -22,10 +22,11 @@
|
||||
|
||||
#include "voyeur/events.h"
|
||||
#include "voyeur/voyeur.h"
|
||||
#include "graphics/palette.h"
|
||||
|
||||
namespace Voyeur {
|
||||
|
||||
EventsManager::EventsManager() {
|
||||
EventsManager::EventsManager(): _intPtr(_audioStruc) {
|
||||
_cycleStatus = 0;
|
||||
_mouseButton = 0;
|
||||
_priorFrameTime = g_system->getMillis();
|
||||
@ -56,7 +57,7 @@ void EventsManager::sWaitFlip() {
|
||||
// TODO: See if this needs a proper wait loop with event polling
|
||||
//while (_intPtr._field39) ;
|
||||
|
||||
Common::Array<ViewPortResource *> &viewPorts = *_vm->_graphicsManager._viewPortListPtr;
|
||||
Common::Array<ViewPortResource *> &viewPorts = _vm->_graphicsManager._viewPortListPtr->_entries;
|
||||
for (uint idx = 0; idx < viewPorts.size(); ++idx) {
|
||||
ViewPortResource &viewPort = *viewPorts[idx];
|
||||
|
||||
@ -81,6 +82,9 @@ void EventsManager::checkForNextFrameCounter() {
|
||||
++_gameCounter;
|
||||
_priorFrameTime = milli;
|
||||
|
||||
// Run the timer-based updates
|
||||
videoTimer();
|
||||
|
||||
// Display the frame
|
||||
g_system->copyRectToScreen((byte *)_vm->_graphicsManager._screenSurface.pixels,
|
||||
SCREEN_WIDTH, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
@ -91,7 +95,18 @@ void EventsManager::checkForNextFrameCounter() {
|
||||
}
|
||||
}
|
||||
|
||||
void EventsManager::delay(int totalMilli) {
|
||||
void EventsManager::videoTimer() {
|
||||
if (_audioStruc._hasPalette) {
|
||||
_audioStruc._hasPalette = false;
|
||||
|
||||
g_system->getPaletteManager()->setPalette(_audioStruc._palette,
|
||||
_audioStruc._palStartIndex,
|
||||
_audioStruc._palEndIndex - _audioStruc._palStartIndex + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void EventsManager::delay(int cycles) {
|
||||
uint32 totalMilli = cycles * 1000 / GAME_FRAME_RATE;
|
||||
uint32 delayEnd = g_system->getMillis() + totalMilli;
|
||||
|
||||
while (!_vm->shouldQuit() && g_system->getMillis() < delayEnd) {
|
||||
@ -134,4 +149,68 @@ void EventsManager::pollEvents() {
|
||||
}
|
||||
}
|
||||
|
||||
void EventsManager::startFade(CMapResource *cMap) {
|
||||
_fadeIntNode._flags |= 1;
|
||||
if (_cycleStatus & 1)
|
||||
_cycleIntNode._flags |= 1;
|
||||
|
||||
_fadeFirstCol = cMap->_start;
|
||||
_fadeLastCol = cMap->_end;
|
||||
_fadeCount = cMap->_steps + 1;
|
||||
|
||||
if (cMap->_steps > 0) {
|
||||
_vm->_graphicsManager._fadeStatus = cMap->_fadeStatus;
|
||||
uint16 *destP = (uint16 *)(_vm->_graphicsManager._viewPortListPtr->_palette +
|
||||
(_fadeFirstCol * 16));
|
||||
byte *vgaP = &_vm->_graphicsManager._VGAColors[_fadeFirstCol * 3];
|
||||
int mapIndex = 0;
|
||||
|
||||
for (int idx = _fadeFirstCol; idx <= _fadeLastCol; ++idx) {
|
||||
destP[0] = vgaP[0] << 8;
|
||||
uint32 rComp = (uint16)((cMap->_entries[mapIndex * 3] << 8) - destP[0]) | 0x80;
|
||||
destP[3] = rComp / cMap->_steps;
|
||||
|
||||
destP[1] = vgaP[1] << 8;
|
||||
uint32 gComp = (uint16)((cMap->_entries[mapIndex * 3 + 1] << 8) - destP[1]) | 0x80;
|
||||
destP[4] = gComp / cMap->_steps;
|
||||
|
||||
destP[2] = vgaP[2] << 8;
|
||||
uint32 bComp = (uint16)((cMap->_entries[mapIndex * 3 + 2] << 8) - destP[2]) | 0x80;
|
||||
destP[5] = bComp / cMap->_steps;
|
||||
destP[6] = bComp % cMap->_steps;
|
||||
|
||||
destP += 8;
|
||||
|
||||
if (!(cMap->_fadeStatus & 1))
|
||||
++mapIndex;
|
||||
}
|
||||
|
||||
if (cMap->_fadeStatus & 2)
|
||||
_intPtr._field3B = 1;
|
||||
_fadeIntNode._flags &= ~1;
|
||||
} else {
|
||||
byte *vgaP = &_vm->_graphicsManager._VGAColors[_fadeFirstCol * 3];
|
||||
int mapIndex = 0;
|
||||
|
||||
for (int idx = _fadeFirstCol; idx <= _fadeLastCol; ++idx, vgaP += 3) {
|
||||
Common::copy(&cMap->_entries[mapIndex], &cMap->_entries[mapIndex + 3], vgaP);
|
||||
|
||||
if (!(cMap->_fadeStatus & 1))
|
||||
mapIndex += 3;
|
||||
}
|
||||
|
||||
if (_intPtr._palStartIndex > _fadeFirstCol)
|
||||
_intPtr._palStartIndex = _fadeFirstCol;
|
||||
if (_intPtr._palEndIndex < _fadeLastCol)
|
||||
_intPtr._palEndIndex = _fadeLastCol;
|
||||
|
||||
_intPtr._hasPalette = true;
|
||||
if (!(cMap->_fadeStatus & 2))
|
||||
_intPtr._field38 = 1;
|
||||
}
|
||||
|
||||
if (_cycleStatus & 1)
|
||||
_cycleIntNode._flags &= ~1;
|
||||
}
|
||||
|
||||
} // End of namespace Voyeur
|
||||
|
@ -29,6 +29,7 @@
|
||||
namespace Voyeur {
|
||||
|
||||
class VoyeurEngine;
|
||||
class CMapResource;
|
||||
|
||||
#define GAME_FRAME_RATE 50
|
||||
#define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE)
|
||||
@ -44,14 +45,17 @@ private:
|
||||
static void mainVoyeurIntFunc();
|
||||
private:
|
||||
void checkForNextFrameCounter();
|
||||
|
||||
void videoTimer();
|
||||
public:
|
||||
IntData _intPtr;
|
||||
IntData _audioStruc;
|
||||
IntData &_intPtr;
|
||||
IntNode _fadeIntNode;
|
||||
IntNode _cycleIntNode;
|
||||
IntNode _evintnode;
|
||||
IntNode _mainIntNode;
|
||||
int _cycleStatus;
|
||||
int _fadeFirstCol, _fadeLastCol;
|
||||
int _fadeCount;
|
||||
public:
|
||||
EventsManager();
|
||||
void setVm(VoyeurEngine *vm) { _vm = vm; }
|
||||
@ -61,8 +65,9 @@ public:
|
||||
void vStopCycle();
|
||||
void sWaitFlip();
|
||||
|
||||
void delay(int totalMilli);
|
||||
void delay(int cycles);
|
||||
void pollEvents();
|
||||
void startFade(CMapResource *cMap);
|
||||
};
|
||||
|
||||
} // End of namespace Voyeur
|
||||
|
@ -251,6 +251,10 @@ bool BoltFile::getBoltGroup(uint32 id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void BoltFile::freeBoltGroup(uint32 id) {
|
||||
warning("TODO: freeBoltGroup");
|
||||
}
|
||||
|
||||
BoltEntry &BoltFile::getBoltEntry(uint32 id) {
|
||||
BoltGroup &group = _groups[id >> 24];
|
||||
assert(group._loaded);
|
||||
@ -268,6 +272,13 @@ PictureResource *BoltFile::getPictureResouce(uint32 id) {
|
||||
return getBoltEntry(id)._picResource;
|
||||
}
|
||||
|
||||
CMapResource *BoltFile::getCMapResource(uint32 id) {
|
||||
if ((int32)id == -1)
|
||||
return NULL;
|
||||
|
||||
return getBoltEntry(id)._cMapResource;
|
||||
}
|
||||
|
||||
byte *BoltFile::memberAddr(uint32 id) {
|
||||
BoltGroup &group = _groups[id >> 8];
|
||||
if (!group._loaded)
|
||||
@ -417,7 +428,7 @@ void BoltFile::initViewPortList() {
|
||||
_state._curMemberPtr->_viewPortListResource = res = new ViewPortListResource(
|
||||
_state, _state._curMemberPtr->_data);
|
||||
|
||||
_state._vm->_graphicsManager._viewPortListPtr = &res->_entries;
|
||||
_state._vm->_graphicsManager._viewPortListPtr = res;
|
||||
_state._vm->_graphicsManager._vPort = &res->_entries[0];
|
||||
}
|
||||
|
||||
@ -441,6 +452,7 @@ BoltGroup::BoltGroup(Common::SeekableReadStream *f): _file(f) {
|
||||
_file->read(&buffer[0], BOLT_GROUP_SIZE);
|
||||
_processed = buffer[0] != 0;
|
||||
_callInitGro = buffer[1] != 0;
|
||||
_termGroIndex = buffer[2];
|
||||
_count = buffer[3] ? buffer[3] : 256; // TODO: Added this in. Check it's okay
|
||||
_fileOffset = READ_LE_UINT32(&buffer[8]);
|
||||
}
|
||||
@ -546,8 +558,7 @@ PictureResource::PictureResource(BoltFilesState &state, const byte *src) {
|
||||
|
||||
if (mode != state._vm->_graphicsManager._SVGAMode) {
|
||||
state._vm->_graphicsManager._SVGAMode = mode;
|
||||
// TODO: If necessary, simulate SVGA mode change
|
||||
warning("TODO: May need to implement SVGA stub code");
|
||||
state._vm->_graphicsManager.clearPalette();
|
||||
}
|
||||
|
||||
// byte *imgData = _imgData;
|
||||
@ -746,6 +757,8 @@ ViewPortListResource::ViewPortListResource(BoltFilesState &state, const byte *sr
|
||||
assert(entry._viewPortResource);
|
||||
_entries.push_back(entry._viewPortResource);
|
||||
}
|
||||
|
||||
state._curLibPtr->resolveIt(READ_LE_UINT32(src + 4), &_palette);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
@ -756,17 +769,22 @@ FontResource::FontResource(BoltFilesState &state, const byte *src) {
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
CMapResource::CMapResource(BoltFilesState &state, const byte *src) {
|
||||
CMapResource::CMapResource(BoltFilesState &state, const byte *src): _vm(state._vm) {
|
||||
_steps = READ_LE_UINT16(src);
|
||||
_start = READ_LE_UINT16(src + 2);
|
||||
_end = READ_LE_UINT16(src + 4);
|
||||
|
||||
int count = _end - _start;
|
||||
_palette = new byte[count * 3];
|
||||
Common::copy(src + 6, src + 6 + 3 * count, _palette);
|
||||
_entries = new byte[count * 3];
|
||||
Common::copy(src + 6, src + 6 + 3 * count, _entries);
|
||||
}
|
||||
|
||||
CMapResource::~CMapResource() {
|
||||
delete[] _palette;
|
||||
delete[] _entries;
|
||||
}
|
||||
|
||||
void CMapResource::startFade() {
|
||||
_vm->_eventsManager.startFade(this);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
@ -127,6 +127,7 @@ public:
|
||||
~BoltFile();
|
||||
|
||||
bool getBoltGroup(uint32 id);
|
||||
void freeBoltGroup(uint32 id);
|
||||
byte *memberAddr(uint32 id);
|
||||
byte *memberAddrOffset(uint32 id);
|
||||
void resolveIt(uint32 id, byte **p);
|
||||
@ -134,6 +135,7 @@ public:
|
||||
|
||||
BoltEntry &getBoltEntry(uint32 id);
|
||||
PictureResource *getPictureResouce(uint32 id);
|
||||
CMapResource *getCMapResource(uint32 id);
|
||||
};
|
||||
|
||||
class BoltGroup {
|
||||
@ -143,6 +145,7 @@ public:
|
||||
byte _loaded;
|
||||
bool _processed;
|
||||
bool _callInitGro;
|
||||
int _termGroIndex;
|
||||
int _count;
|
||||
int _fileOffset;
|
||||
Common::Array<BoltEntry> _entries;
|
||||
@ -254,7 +257,7 @@ public:
|
||||
|
||||
class ViewPortListResource {
|
||||
public:
|
||||
byte *_field4;
|
||||
byte *_palette;
|
||||
Common::Array<ViewPortResource *> _entries;
|
||||
|
||||
ViewPortListResource(BoltFilesState &state, const byte *src);
|
||||
@ -270,13 +273,19 @@ public:
|
||||
};
|
||||
|
||||
class CMapResource {
|
||||
private:
|
||||
VoyeurEngine *_vm;
|
||||
public:
|
||||
int _steps;
|
||||
int _fadeStatus;
|
||||
int _start;
|
||||
int _end;
|
||||
byte *_palette;
|
||||
byte *_entries;
|
||||
public:
|
||||
CMapResource(BoltFilesState &state, const byte *src);
|
||||
virtual ~CMapResource();
|
||||
|
||||
void startFade();
|
||||
};
|
||||
|
||||
class VInitCyclResource {
|
||||
|
@ -27,7 +27,12 @@ namespace Voyeur {
|
||||
IntData::IntData() {
|
||||
_field9 = false;
|
||||
_flipWait = false;
|
||||
_hasPalette = false;
|
||||
_field3B = 0;
|
||||
_field2A = 0;
|
||||
_palStartIndex = 0;
|
||||
_palEndIndex = 0;
|
||||
_palette = NULL;
|
||||
}
|
||||
|
||||
void IntData::audioInit() {
|
||||
|
@ -114,7 +114,12 @@ public:
|
||||
bool _field9;
|
||||
bool _flipWait;
|
||||
int _field2A;
|
||||
byte *_colors;
|
||||
bool _hasPalette;
|
||||
int _field38;
|
||||
int _field3B;
|
||||
int _palStartIndex;
|
||||
int _palEndIndex;
|
||||
byte *_palette;
|
||||
Common::List<IntNode *> _intNodes;
|
||||
public:
|
||||
IntData();
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "voyeur/game.h"
|
||||
#include "voyeur/voyeur.h"
|
||||
#include "engines/util.h"
|
||||
#include "graphics/palette.h"
|
||||
#include "graphics/surface.h"
|
||||
|
||||
namespace Voyeur {
|
||||
@ -47,6 +48,8 @@ void GraphicsManager::sInitGraphics() {
|
||||
initGraphics(SCREEN_WIDTH, SCREEN_HEIGHT, false);
|
||||
_screenSurface.create(SCREEN_WIDTH, SCREEN_HEIGHT,
|
||||
Graphics::PixelFormat::createFormatCLUT8());
|
||||
|
||||
clearPalette();
|
||||
}
|
||||
|
||||
GraphicsManager::~GraphicsManager() {
|
||||
@ -360,7 +363,7 @@ void GraphicsManager::EMSMapPageHandle(int v1, int v2, int v3) {
|
||||
}
|
||||
|
||||
void GraphicsManager::flipPage() {
|
||||
Common::Array<ViewPortResource *> &viewPorts = *_viewPortListPtr;
|
||||
Common::Array<ViewPortResource *> &viewPorts = _viewPortListPtr->_entries;
|
||||
bool flipFlag = false;
|
||||
|
||||
for (uint idx = 0; idx < viewPorts.size(); ++idx) {
|
||||
@ -405,4 +408,14 @@ void GraphicsManager::restoreBack(Common::Array<Common::Rect> &rectList, int rec
|
||||
_saveBack = saveBack;
|
||||
}
|
||||
|
||||
void GraphicsManager::clearPalette() {
|
||||
byte palette[768];
|
||||
Common::fill(&palette[0], &palette[768], 0);
|
||||
g_system->getPaletteManager()->setPalette(&palette[0], 0, 256);
|
||||
}
|
||||
|
||||
void GraphicsManager::screenReset() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
} // End of namespace Voyeur
|
||||
|
@ -41,6 +41,7 @@ class GraphicsManager;
|
||||
class DisplayResource;
|
||||
class PictureResource;
|
||||
class ViewPortResource;
|
||||
class ViewPortListResource;
|
||||
|
||||
typedef void (GraphicsManager::*GraphicMethodPtr)();
|
||||
typedef void (GraphicsManager::*ViewPortSetupPtr)(ViewPortResource *);
|
||||
@ -57,7 +58,7 @@ public:
|
||||
int _SVGAPage;
|
||||
int _SVGAMode;
|
||||
int _SVGAReset;
|
||||
Common::Array<ViewPortResource *> *_viewPortListPtr;
|
||||
ViewPortListResource *_viewPortListPtr;
|
||||
ViewPortResource **_vPort;
|
||||
bool _MCGAMode;
|
||||
bool _saveBack;
|
||||
@ -66,6 +67,7 @@ public:
|
||||
uint _planeSelect;
|
||||
int _sImageShift;
|
||||
Graphics::Surface _screenSurface;
|
||||
int _fadeStatus;
|
||||
private:
|
||||
static void fadeIntFunc();
|
||||
static void vDoFadeInt();
|
||||
@ -92,6 +94,8 @@ public:
|
||||
void sDrawPic(DisplayResource *srcDisplay, DisplayResource *destDisplay, const Common::Point &offset);
|
||||
void sDisplayPic(PictureResource *pic);
|
||||
void flipPage();
|
||||
void clearPalette();
|
||||
void screenReset();
|
||||
};
|
||||
|
||||
} // End of namespace Voyeur
|
||||
|
@ -132,7 +132,7 @@ void VoyeurEngine::initBolt() {
|
||||
}
|
||||
|
||||
void VoyeurEngine::vInitInterrupts() {
|
||||
_eventsManager._intPtr._colors = &_graphicsManager._VGAColors[0];
|
||||
_eventsManager._intPtr._palette = &_graphicsManager._VGAColors[0];
|
||||
}
|
||||
|
||||
void VoyeurEngine::initInput() {
|
||||
@ -142,6 +142,8 @@ void VoyeurEngine::doHeadTitle() {
|
||||
// char dest[144];
|
||||
|
||||
_eventsManager.startMainClockInt();
|
||||
|
||||
// Show starting screen
|
||||
if (_bVoy->getBoltGroup(0x10500)) {
|
||||
_graphicsManager._backgroundPage = _bVoy->getBoltEntry(0x5020000)._picResource;
|
||||
(*_graphicsManager._vPort)->setupViewPort();
|
||||
@ -150,8 +152,36 @@ void VoyeurEngine::doHeadTitle() {
|
||||
_graphicsManager.flipPage();
|
||||
_eventsManager.sWaitFlip();
|
||||
|
||||
// TODO:
|
||||
_eventsManager.delay(1000);
|
||||
// Fade in the screen
|
||||
CMapResource *cMap = _bVoy->getCMapResource(0x5010000);
|
||||
assert(cMap);
|
||||
cMap->_steps = 60;
|
||||
cMap->startFade();
|
||||
|
||||
_eventsManager.delay(150);
|
||||
if (shouldQuit())
|
||||
return;
|
||||
/* Commented out until fade in is working
|
||||
// Fade out the screen
|
||||
cMap->_steps = 30;
|
||||
cMap->startFade();
|
||||
if (shouldQuit())
|
||||
return;
|
||||
|
||||
(*_graphicsManager._vPort)->_flags |= 8;
|
||||
_graphicsManager.flipPage();
|
||||
_eventsManager.sWaitFlip();
|
||||
|
||||
while (!shouldQuit() && (_graphicsManager._fadeStatus & 1))
|
||||
_eventsManager.delay(1);
|
||||
|
||||
_graphicsManager.screenReset();
|
||||
_bVoy->freeBoltGroup(0x10500);
|
||||
_graphicsManager.screenReset();
|
||||
|
||||
if (shouldQuit())
|
||||
return;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user