DRAGONS: work on screen palette handling
This commit is contained in:
parent
77d0b6770e
commit
c7b9b69035
5 changed files with 82 additions and 15 deletions
|
@ -172,12 +172,13 @@ void Minigame3::run() {
|
|||
origSceneId = _vm->getCurrentSceneId();
|
||||
_vm->_scene->setSceneId(6);
|
||||
_vm->_scene->loadScene(6 | 0x8000, 0);
|
||||
_vm->_scene->setFgLayerPriority(0);
|
||||
_vm->_scene->setFgLayerPriority(4);
|
||||
|
||||
// TODO
|
||||
// load_palette_into_frame_buffer(1,scrFileData_maybe);
|
||||
// load_palette_into_frame_buffer(4,scrFileData_maybe);
|
||||
_vm->_screen->loadPalette(1, _vm->_scene->getPalette());
|
||||
_vm->_screen->loadPalette(4, _vm->_scene->getPalette());
|
||||
_vm->_screen->updatePaletteTransparency(4, 1, 0xff, true);
|
||||
// FUN_80017ef0();
|
||||
FUN_80017ef0();
|
||||
oldEngineFlags = _vm->getAllFlags();
|
||||
_vm->clearFlags(ENGINE_FLAG_80);
|
||||
_vm->clearFlags(ENGINE_FLAG_20);
|
||||
|
@ -754,12 +755,10 @@ void Minigame3::run() {
|
|||
flicker->sceneId = 1;
|
||||
_vm->setAllFlags(oldEngineFlags);
|
||||
_vm->setFlags(ENGINE_FLAG_40);
|
||||
// load_palette_into_frame_buffer
|
||||
// (1,(uint)*(uint16 *)(*(int *)(&DAT_80071c30 + (uint)actors[0].actorFileDictionaryIndex * 8) + 10) +
|
||||
// _vm->_screen->loadPalette(1,(uint)*(uint16 *)(*(int *)(&DAT_80071c30 + (uint)actors[0].actorFileDictionaryIndex * 8) + 10) +
|
||||
// *(int *)(&DAT_80071c30 + (uint)actors[0].actorFileDictionaryIndex * 8));
|
||||
// UnkCursorFunc1();
|
||||
// load_palette_into_frame_buffer
|
||||
// (4,(uint)*(uint16 *)(*(int *)(&DAT_80071c30 + (uint)actors[0].actorFileDictionaryIndex * 8) + 10) +
|
||||
// _vm->_screen->loadPalette(4,(uint)*(uint16 *)(*(int *)(&DAT_80071c30 + (uint)actors[0].actorFileDictionaryIndex * 8) + 10) +
|
||||
// *(int *)(&DAT_80071c30 + (uint)actors[0].actorFileDictionaryIndex * 8));
|
||||
_vm->_screen->updatePaletteTransparency(4,1,0xff,true);
|
||||
_vm->_inventory->setType(origInventoryType);
|
||||
|
@ -769,10 +768,32 @@ void Minigame3::run() {
|
|||
|
||||
void Minigame3::FUN_80017e64(uint32 param_1, int16 param_2, int16 param_3) {
|
||||
//TODO what does this do?
|
||||
// int iVar1;
|
||||
//
|
||||
// iVar1 = (param_1 & 0xffff) * 0x24;
|
||||
// *(undefined2 *)(&DAT_80069644 + iVar1) = param_2;
|
||||
// *(short *)(&DAT_80069646 + iVar1) = param_3 + 8;
|
||||
|
||||
}
|
||||
|
||||
void Minigame3::FUN_80017f70_paletteRelated(uint16 unk) {
|
||||
//TODO
|
||||
void Minigame3::FUN_80017f70_paletteRelated(uint16 param_1) {
|
||||
if (0x1f < param_1) {
|
||||
param_1 = 0x1f;
|
||||
}
|
||||
// uVar1 = IsVSyncEventEnabled & 1;
|
||||
// DisableVSyncEvent();
|
||||
_vm->_screen->loadPalette(0, _vm->_scene->getPalette());
|
||||
_vm->_screen->setPaletteRecord(0, 0x3f, param_1 * 0x421);
|
||||
// load_palette_into_frame_buffer(0,abStack528);
|
||||
_vm->_screen->updatePaletteTransparency(0, 0x3f,0x3f, true);
|
||||
// if (uVar1 != 0) {
|
||||
// EnableVSyncEvent();
|
||||
// }
|
||||
}
|
||||
|
||||
void Minigame3::FUN_80017ef0() {
|
||||
//TODO DAT_80069680 = DAT_80069680 | 0x50000000;
|
||||
FUN_80017f70_paletteRelated(0);
|
||||
}
|
||||
|
||||
} // End of namespace Dragons
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
private:
|
||||
void FUN_80017e64(uint32 param_1, int16 param_2, int16 param_3);
|
||||
void FUN_80017f70_paletteRelated(uint16 unk);
|
||||
void FUN_80017ef0();
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ void Minigame4::run() {
|
|||
_vm->clearFlags(ENGINE_FLAG_1);
|
||||
DAT_80090428_videoUpdateRelated = 0;
|
||||
//TODO vsync_updater_function = videoUpdateFunction;
|
||||
//load_palette_into_frame_buffer(4,DAT_8006a3f8);
|
||||
_vm->_screen->loadPalette(4, _vm->_scene->getPalette());
|
||||
_vm->_screen->updatePaletteTransparency(4,1,0xff,true);
|
||||
_vm->videoFlags |= 4;
|
||||
_vm->_scene->setBgLayerPriority(2);
|
||||
|
@ -103,8 +103,7 @@ void Minigame4::run() {
|
|||
// EnableVSyncEvent();
|
||||
_vm->_dragonINIResource->setFlickerRecord(uVar2);
|
||||
_vm->_inventory->setType(uVar3);
|
||||
// load_palette_into_frame_buffer
|
||||
// (4,(uint)*(ushort *)
|
||||
// _vm->_screen->loadPalette(4,(uint)*(ushort *)
|
||||
// (*(int *)(&DAT_80071c30 + (uint)actors[0].actorFileDictionaryIndex * 8) + 10)
|
||||
// + *(int *)(&DAT_80071c30 + (uint)actors[0].actorFileDictionaryIndex * 8));
|
||||
_vm->_screen->updatePaletteTransparency(4,1,0xff,true);
|
||||
|
|
|
@ -19,9 +19,12 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
#include <common/endian.h>
|
||||
#include "common/system.h"
|
||||
#include "common/rect.h"
|
||||
#include "engines/util.h"
|
||||
#include "dragons/dragons.h"
|
||||
#include "dragons/scene.h"
|
||||
#include "screen.h"
|
||||
|
||||
namespace Dragons {
|
||||
|
@ -133,7 +136,46 @@ Common::Rect Screen::clipRectToScreen(int destX, int destY, const Common::Rect r
|
|||
}
|
||||
|
||||
void Screen::updatePaletteTransparency(uint16 paletteNum, uint16 startOffset, uint16 endOffset, bool isTransparent) {
|
||||
//TODO
|
||||
assert(paletteNum < DRAGONS_NUM_PALETTES);
|
||||
assert(startOffset < 256);
|
||||
assert(endOffset < 256);
|
||||
|
||||
// TODO
|
||||
// this is needed for palette 0 for some reason.
|
||||
// DAT_80069638 = DAT_80069638 | 0x50000000;
|
||||
// DAT_8006965c = DAT_8006965c | 0x50000000;
|
||||
// DAT_80069680 = DAT_80069680 | 0x50000000;
|
||||
|
||||
for (int i = startOffset; i <= endOffset; i++) {
|
||||
if (isTransparent) {
|
||||
_palettes[paletteNum][i * 2 + 1] |= 0x80;
|
||||
} else {
|
||||
_palettes[paletteNum][i * 2 + 1] &= ~0x80;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Screen::loadPalette(uint16 paletteNum, byte *palette) {
|
||||
assert(paletteNum < DRAGONS_NUM_PALETTES);
|
||||
if (paletteNum == 0) {
|
||||
Dragons::getEngine()->_scene->setStagePalette(palette);
|
||||
} else {
|
||||
memcpy(&_palettes[paletteNum][0], palette, 512);
|
||||
}
|
||||
}
|
||||
|
||||
void Screen::setPaletteRecord(uint16 paletteNum, uint16 offset, uint16 newValue) {
|
||||
assert(paletteNum < DRAGONS_NUM_PALETTES);
|
||||
assert(offset < 256);
|
||||
WRITE_LE_UINT16(&_palettes[paletteNum][offset * 2], newValue);
|
||||
if (paletteNum == 0) {
|
||||
Dragons::getEngine()->_scene->setStagePalette(&_palettes[0][0]);
|
||||
}
|
||||
}
|
||||
|
||||
byte *Screen::getPalette(uint16 paletteNum) {
|
||||
assert(paletteNum < DRAGONS_NUM_PALETTES);
|
||||
return _palettes[paletteNum];
|
||||
}
|
||||
|
||||
} // End of namespace Dragons
|
||||
|
|
|
@ -26,11 +26,12 @@
|
|||
#include "graphics/pixelformat.h"
|
||||
|
||||
namespace Dragons {
|
||||
|
||||
#define DRAGONS_NUM_PALETTES 5
|
||||
class Screen {
|
||||
private:
|
||||
Graphics::PixelFormat _pixelFormat;
|
||||
Graphics::Surface *_backSurface;
|
||||
byte _palettes[DRAGONS_NUM_PALETTES][512];
|
||||
public:
|
||||
virtual ~Screen();
|
||||
|
||||
|
@ -40,6 +41,9 @@ public:
|
|||
void copyRectToSurface(const Graphics::Surface &srcSurface, int destX, int destY);
|
||||
void copyRectToSurface(const Graphics::Surface &srcSurface, int destX, int destY, Common::Rect srcRect, bool flipX = false);
|
||||
void updateScreen();
|
||||
void loadPalette(uint16 paletteNum, byte *palette);
|
||||
byte *getPalette(uint16 paletteNum);
|
||||
void setPaletteRecord(uint16 paletteNum, uint16 offset, uint16 newValue);
|
||||
void updatePaletteTransparency(uint16 paletteNum, uint16 startOffset, uint16 endOffset, bool isTransparent);
|
||||
private:
|
||||
void copyRectToSurface(const void *buffer, int srcPitch, int srcWidth, int srcXOffset, int destX, int destY, int width, int height, bool flipX);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue