mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 05:38:56 +00:00
SCI/newgui: support for priority bands, kCoordPri kPriCoord implemented, priority band picture support also added
svn-id: r44825
This commit is contained in:
parent
22477093b4
commit
ed5a4625d5
@ -585,15 +585,15 @@ reg_t kWait(EngineState *s, int argc, reg_t *argv) {
|
||||
}
|
||||
|
||||
reg_t kCoordPri(EngineState *s, int argc, reg_t *argv) {
|
||||
int y = argv[0].toSint16();
|
||||
int16 y = argv[0].toSint16();
|
||||
|
||||
return make_reg(0, _find_view_priority(s, y));
|
||||
return make_reg(0, s->_gui->coordinateToPriority(y));
|
||||
}
|
||||
|
||||
reg_t kPriCoord(EngineState *s, int argc, reg_t *argv) {
|
||||
int priority = argv[0].toSint16();
|
||||
int16 priority = argv[0].toSint16();
|
||||
|
||||
return make_reg(0, _find_priority_band(s, priority));
|
||||
return make_reg(0, s->_gui->priorityToCoordinate(priority));
|
||||
}
|
||||
|
||||
void _k_dirloop(reg_t obj, uint16 angle, EngineState *s, int argc, reg_t *argv) {
|
||||
|
@ -112,6 +112,14 @@ void SciGui::localToGlobal(int16 *x, int16 *y) {
|
||||
*y = *y + curPort->top;
|
||||
}
|
||||
|
||||
int16 SciGui::coordinateToPriority(int16 y) {
|
||||
return _gfx->CoordinateToPriority(y);
|
||||
}
|
||||
|
||||
int16 SciGui::priorityToCoordinate(int16 priority) {
|
||||
return _gfx->PriorityToCoordinate(priority);
|
||||
}
|
||||
|
||||
reg_t SciGui::newWindow(Common::Rect dims, Common::Rect restoreRect, uint16 style, int16 priority, int16 colorPen, int16 colorBack, const char *title) {
|
||||
GuiWindow *wnd = NULL;
|
||||
|
||||
|
@ -51,6 +51,9 @@ public:
|
||||
virtual reg_t getPort();
|
||||
virtual void globalToLocal(int16 *x, int16 *y);
|
||||
virtual void localToGlobal(int16 *x, int16 *y);
|
||||
virtual int16 coordinateToPriority(int16 y);
|
||||
virtual int16 priorityToCoordinate(int16 priority);
|
||||
|
||||
virtual reg_t newWindow(Common::Rect dims, Common::Rect restoreRect, uint16 style, int16 priority, int16 colorPen, int16 colorBack, const char *title);
|
||||
virtual void disposeWindow(uint16 windowPtr, int16 arg2);
|
||||
|
||||
|
@ -65,6 +65,15 @@ void SciGuiGfx::init() {
|
||||
SetFont(0);
|
||||
_menuPort->rect = Common::Rect(0, 0, _screen->_width, _screen->_height);
|
||||
_menuRect = Common::Rect(0, 0, _screen->_width, 9);
|
||||
|
||||
// Initialize priority bands
|
||||
if (_s->usesOldGfxFunctions()) {
|
||||
_priorityBandCount = 15;
|
||||
PriorityBandsInit(42, 200);
|
||||
} else {
|
||||
_priorityBandCount = 14;
|
||||
PriorityBandsInit(42, 190);
|
||||
}
|
||||
}
|
||||
|
||||
GuiPort *SciGuiGfx::SetPort(GuiPort *newPort) {
|
||||
@ -571,14 +580,14 @@ void SciGuiGfx::TextBox(const char *text, int16 bshow, const Common::Rect &rect,
|
||||
}
|
||||
|
||||
// Update (part of) screen
|
||||
void SciGuiGfx::ShowBits(const Common::Rect &r, uint16 flags) {
|
||||
void SciGuiGfx::ShowBits(const Common::Rect &r, uint16 screenMask) {
|
||||
Common::Rect rect(r.left, r.top, r.right, r.bottom);
|
||||
rect.clip(_curPort->rect);
|
||||
if (rect.isEmpty()) // nothing to show
|
||||
return;
|
||||
|
||||
OffsetRect(rect);
|
||||
assert((flags&0x8000) == 0);
|
||||
assert((screenMask & 0x8000) == 0);
|
||||
_screen->copyToScreen();
|
||||
// _system->copyRectToScreen(GetSegment(flags) + _baseTable[rect.top] + rect.left, 320, rect.left, rect.top, rect.width(), rect.height());
|
||||
// _system->updateScreen();
|
||||
@ -1064,6 +1073,50 @@ static inline int sign_extend_byte(int value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
void SciGuiGfx::PriorityBandsInit(int16 top, int16 bottom) {
|
||||
double bandSize;
|
||||
int16 y;
|
||||
|
||||
_priorityTop = top;
|
||||
_priorityBottom = bottom;
|
||||
bandSize = (_priorityBottom - _priorityTop) / _priorityBandCount;
|
||||
|
||||
memset(_priorityBands, 0, _priorityTop);
|
||||
for (y = _priorityTop; y < _priorityBottom; y++)
|
||||
_priorityBands[y] = (byte)(1 + (y - _priorityTop) / bandSize);
|
||||
}
|
||||
|
||||
void SciGuiGfx::PriorityBandsInit(byte *data) {
|
||||
int i = 0, inx;
|
||||
byte priority = 0;
|
||||
|
||||
for (inx = 0; inx < 14; inx++) {
|
||||
priority = *data++;
|
||||
while (i < priority)
|
||||
_priorityBands[i++] = inx;
|
||||
}
|
||||
while (i < 200)
|
||||
_priorityBands[i++] = inx;
|
||||
}
|
||||
|
||||
byte SciGuiGfx::CoordinateToPriority(int16 y) {
|
||||
if (y < _priorityTop)
|
||||
return _priorityBands[_priorityTop];
|
||||
if (y > _priorityBottom)
|
||||
return _priorityBands[_priorityBottom];
|
||||
return _priorityBands[y];
|
||||
}
|
||||
|
||||
int16 SciGuiGfx::PriorityToCoordinate(byte priority) {
|
||||
int16 y;
|
||||
if (priority <= _priorityBandCount) {
|
||||
for (y = 0; y <= _priorityBottom; y++)
|
||||
if (_priorityBands[y] == priority)
|
||||
return y;
|
||||
}
|
||||
return _priorityBottom;
|
||||
}
|
||||
|
||||
void SciGuiGfx::AnimateDisposeLastCast() {
|
||||
// FIXME
|
||||
//if (!_lastCast->first.isNull())
|
||||
@ -1311,7 +1364,7 @@ void SciGuiGfx::AnimateUpdate(List *list) {
|
||||
// arr1[i] = 1;
|
||||
if ((signal[listNr] & SCI_ANIMATE_SIGNAL_IGNOREACTOR) == 0) {
|
||||
rect = celRect[listNr];
|
||||
//rect.top = CLIP<int16>(PriCoord(zs[i]) - 1, rect.top, rect.bottom - 1);
|
||||
rect.top = CLIP<int16>(PriorityToCoordinate(z[listNr]) - 1, rect.top, rect.bottom - 1);
|
||||
FillRect(rect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
|
||||
}
|
||||
}
|
||||
@ -1425,7 +1478,7 @@ void SciGuiGfx::AddToPicDrawCels(List *list) {
|
||||
GuiViewLoopNo loopNo;
|
||||
GuiViewCelNo celNo;
|
||||
int16 x, y, z, priority;
|
||||
uint16 paletteNo;
|
||||
uint16 paletteNo, signal;
|
||||
Common::Rect celRect;
|
||||
|
||||
while (curNode) {
|
||||
@ -1440,22 +1493,22 @@ void SciGuiGfx::AddToPicDrawCels(List *list) {
|
||||
z = GET_SEL32V(curObject, z);
|
||||
priority = GET_SEL32V(curObject, priority);
|
||||
if (priority == -1)
|
||||
priority = 0; //CoordPri(y);
|
||||
priority = CoordinateToPriority(y);
|
||||
paletteNo = GET_SEL32V(curObject, palette);
|
||||
signal = GET_SEL32V(curObject, signal);
|
||||
|
||||
// Get the corresponding view
|
||||
view = new SciGuiView(_s->resMan, _screen, _palette, viewId);
|
||||
|
||||
// Create rect according to coordinates and given cel
|
||||
view->getCelRect(loopNo, celNo, x, y, z, &celRect);
|
||||
view->getCelRect(loopNo, celNo, x, y, priority, &celRect);
|
||||
|
||||
// draw corresponding cel
|
||||
drawCel(viewId, loopNo, celNo, celRect.left, celRect.top, z, paletteNo);
|
||||
// FIXME find out what 17 is and implement this as well
|
||||
// if ((obj.getProperty(17) & 0x4000) == 0) {
|
||||
// rect.top = CLIP<int16>(PriCoord(prio) - 1, rect.top, rect.bottom - 1);
|
||||
// _gfx->RFillRect(rect, 4, 0, 0, 0xF);
|
||||
// }
|
||||
if ((signal & SCI_ANIMATE_SIGNAL_IGNOREACTOR) == 0) {
|
||||
celRect.top = CLIP<int16>(PriorityToCoordinate(priority) - 1, celRect.top, celRect.bottom - 1);
|
||||
FillRect(celRect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
|
||||
}
|
||||
|
||||
curAddress = curNode->succ;
|
||||
curNode = _s->_segMan->lookupNode(curAddress);
|
||||
|
@ -100,6 +100,12 @@ public:
|
||||
void drawCel(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, uint16 leftPos, uint16 topPos, byte priority, uint16 paletteNo);
|
||||
|
||||
int16 onControl(uint16 screenMask, Common::Rect rect);
|
||||
|
||||
void PriorityBandsInit(int16 top, int16 bottom);
|
||||
void PriorityBandsInit(byte *data);
|
||||
byte CoordinateToPriority(int16 y);
|
||||
int16 PriorityToCoordinate(byte priority);
|
||||
|
||||
void AnimateDisposeLastCast();
|
||||
void AnimateInvoke(List *list, int argc, reg_t *argv);
|
||||
void AnimateFill(List *list, byte &oldPicNotValid);
|
||||
@ -144,6 +150,10 @@ private:
|
||||
int _textColorsCount;
|
||||
uint16 *_textColors;
|
||||
|
||||
// Priority Bands related variables
|
||||
int16 _priorityTop, _priorityBottom, _priorityBandCount;
|
||||
byte _priorityBands[200];
|
||||
|
||||
// Animate* related variables
|
||||
List *_lastCast;
|
||||
|
||||
|
@ -483,15 +483,11 @@ void SciGuiPicture::drawVectorData(byte *data, int dataSize) {
|
||||
curPos += size;
|
||||
break;
|
||||
case PIC_OPX_VGA_PRIORITY_TABLE_EQDIST:
|
||||
//FIXME
|
||||
//g_sci->InitPri(READ_LE_UINT16(ptr), READ_LE_UINT16(ptr + 2));
|
||||
debug(5, "DrawPic::InitPri %d %d",
|
||||
READ_LE_UINT16(data + curPos), READ_LE_UINT16(data + curPos + 2));
|
||||
_gfx->PriorityBandsInit(READ_LE_UINT16(data + curPos), READ_LE_UINT16(data + curPos + 2));
|
||||
curPos += 4;
|
||||
break;
|
||||
case PIC_OPX_VGA_PRIORITY_TABLE_EXPLICIT:
|
||||
//FIXME
|
||||
//g_sci->PriBands(ptr);
|
||||
_gfx->PriorityBandsInit(data + curPos);
|
||||
curPos += 14;
|
||||
break;
|
||||
default:
|
||||
|
@ -166,6 +166,14 @@ void SciGui32::localToGlobal(int16 *x, int16 *y) {
|
||||
*y = *y + s->port->zone.y;
|
||||
}
|
||||
|
||||
int16 SciGui32::coordinateToPriority(int16 y) {
|
||||
return _find_view_priority(s, y);
|
||||
}
|
||||
|
||||
int16 SciGui32::priorityToCoordinate(int16 priority) {
|
||||
return _find_priority_band(s, priority);
|
||||
}
|
||||
|
||||
reg_t SciGui32::newWindow(Common::Rect dims, Common::Rect restoreRect, uint16 style, int16 priority, int16 colorPen, int16 colorBack, const char *title) {
|
||||
GfxPort *window;
|
||||
int x, y, xl, yl;
|
||||
|
@ -43,6 +43,9 @@ public:
|
||||
reg_t getPort();
|
||||
void globalToLocal(int16 *x, int16 *y);
|
||||
void localToGlobal(int16 *x, int16 *y);
|
||||
int16 coordinateToPriority(int16 y);
|
||||
int16 priorityToCoordinate(int16 priority);
|
||||
|
||||
reg_t newWindow(Common::Rect dims, Common::Rect restoreRect, uint16 style, int16 priority, int16 colorPen, int16 colorBack, const char *title);
|
||||
void disposeWindow(uint16 windowPtr, int16 arg2);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user