Code merge

svn-id: r31648
This commit is contained in:
Filippos Karapetis 2008-04-21 18:40:28 +00:00
parent 008c4ca9d6
commit 36bec1d5c8
5 changed files with 22 additions and 24 deletions

View File

@ -80,7 +80,7 @@ MadeEngine::MadeEngine(OSystem *syst, const MadeGameDescription *gameDesc) : Eng
if (cd_num >= 0)
_system->openCD(cd_num);
_pmvPlayer = new PmvPlayer(_system, _mixer);
_pmvPlayer = new PmvPlayer(this, _mixer);
_res = new ProjectReader();
_screen = new Screen(this);
_dat = new GameDatabase();

View File

@ -24,10 +24,11 @@
*/
#include "made/pmvplayer.h"
#include "made/screen.h"
namespace Made {
PmvPlayer::PmvPlayer(OSystem *system, Audio::Mixer *mixer) : _fd(NULL), _system(system), _mixer(mixer) {
PmvPlayer::PmvPlayer(MadeEngine *vm, Audio::Mixer *mixer) : _fd(NULL), _vm(vm), _mixer(mixer) {
}
PmvPlayer::~PmvPlayer() {
@ -68,7 +69,7 @@ void PmvPlayer::play(const char *filename) {
// Read palette
_fd->read(_palette, 768);
updatePalette();
_vm->_screen->setRGBPalette(_palette);
uint32 frameCount = 0;
uint16 chunkCount = 0;
@ -144,7 +145,7 @@ void PmvPlayer::play(const char *filename) {
firstTime = false;
}
updatePalette();
_vm->_screen->setRGBPalette(_palette);
handleEvents();
updateScreen();
@ -153,7 +154,7 @@ void PmvPlayer::play(const char *filename) {
delete[] frameData;
while (_mixer->getSoundElapsedTime(_audioStreamHandle) < frameCount * frameDelay) {
_system->delayMillis(10);
_vm->_system->delayMillis(10);
}
}
@ -180,7 +181,7 @@ void PmvPlayer::readChunk(uint32 &chunkType, uint32 &chunkSize) {
void PmvPlayer::handleEvents() {
Common::Event event;
while (_system->getEventManager()->pollEvent(event)) {
while (_vm->_system->getEventManager()->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
if (event.kbd.keycode == Common::KEYCODE_ESCAPE)
@ -196,20 +197,9 @@ void PmvPlayer::handleEvents() {
}
}
void PmvPlayer::updatePalette() {
byte colors[1024];
for (int i = 0; i < 256; i++) {
colors[i * 4 + 0] = _palette[i * 3 + 0];
colors[i * 4 + 1] = _palette[i * 3 + 1];
colors[i * 4 + 2] = _palette[i * 3 + 2];
colors[i * 4 + 3] = 0;
}
_system->setPalette(colors, 0, 256);
}
void PmvPlayer::updateScreen() {
_system->copyRectToScreen((const byte*)_surface->pixels, _surface->pitch, 0, 0, _surface->w, _surface->h);
_system->updateScreen();
_vm->_system->copyRectToScreen((const byte*)_surface->pixels, _surface->pitch, 0, 0, _surface->w, _surface->h);
_vm->_system->updateScreen();
}
void PmvPlayer::decompressPalette(byte *palData, byte *outPal, uint32 palDataSize) {

View File

@ -36,16 +36,17 @@
#include "made/graphics.h"
#include "made/sound.h"
#include "made/made.h"
namespace Made {
class PmvPlayer {
public:
PmvPlayer(OSystem *system, Audio::Mixer *mixer);
PmvPlayer(MadeEngine *vm, Audio::Mixer *mixer);
~PmvPlayer();
void play(const char *filename);
protected:
OSystem *_system;
MadeEngine *_vm;
Audio::Mixer *_mixer;
Common::File *_fd;
Audio::AppendableAudioStream *_audioStream;
@ -55,7 +56,6 @@ protected:
bool _abort;
void readChunk(uint32 &chunkType, uint32 &chunkSize);
void handleEvents();
void updatePalette();
void updateScreen();
void decompressPalette(byte *palData, byte *outPal, uint32 palDataSize);
};

View File

@ -73,7 +73,15 @@ void Screen::drawSurface(Graphics::Surface *source, int x, int y) {
}
void Screen::setPalette(byte *palette, int start, int count) {
void Screen::setRGBPalette(byte *palette, int start, int count) {
byte colors[1024];
for (int i = 0; i < count; i++) {
colors[i * 4 + 0] = palette[i * 3 + 0];
colors[i * 4 + 1] = palette[i * 3 + 1];
colors[i * 4 + 2] = palette[i * 3 + 2];
colors[i * 4 + 3] = 0;
}
_vm->_system->setPalette(colors, start, count);
}
uint16 Screen::updateChannel(uint16 channelIndex) {

View File

@ -61,7 +61,7 @@ public:
void clearScreen();
void drawSurface(Graphics::Surface *source, int x, int y);
void setPalette(byte *palette, int start, int count);
void setRGBPalette(byte *palette, int start = 0, int count = 256);
uint16 updateChannel(uint16 channelIndex);
void deleteChannel(uint16 channelIndex);