diff options
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/gui/gui.cpp | 32 | ||||
-rw-r--r-- | engines/sci/gui/gui.h | 6 | ||||
-rw-r--r-- | engines/sci/gui/gui_dbllist.cpp | 42 | ||||
-rw-r--r-- | engines/sci/gui/gui_font.cpp | 6 | ||||
-rw-r--r-- | engines/sci/gui/gui_font.h | 8 | ||||
-rw-r--r-- | engines/sci/gui/gui_gfx.cpp | 120 | ||||
-rw-r--r-- | engines/sci/gui/gui_gfx.h | 69 | ||||
-rw-r--r-- | engines/sci/gui/gui_helpers.h | 54 |
8 files changed, 183 insertions, 154 deletions
diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp index ea6adcb766..6358c86dee 100644 --- a/engines/sci/gui/gui.cpp +++ b/engines/sci/gui/gui.cpp @@ -74,7 +74,7 @@ void SciGUI::setPort(uint16 portPtr) { case 0: _gfx->SetPort(_windowMgr->_wmgrPort); break; case 0xFFFF: _gfx->SetPort(_gfx->_menuPort); break; default: - _gfx->SetPort((sciPort *)heap2Ptr(portPtr)); + _gfx->SetPort((GUIPort *)heap2Ptr(portPtr)); }; } @@ -91,19 +91,19 @@ reg_t SciGUI::getPort() { } void SciGUI::globalToLocal(int16 *x, int16 *y) { - sciPort *curPort = _gfx->GetPort(); + GUIPort *curPort = _gfx->GetPort(); *x = *x - curPort->left; *y = *y - curPort->top; } void SciGUI::localToGlobal(int16 *x, int16 *y) { - sciPort *curPort = _gfx->GetPort(); + GUIPort *curPort = _gfx->GetPort(); *x = *x + curPort->left; *y = *y + curPort->top; } reg_t SciGUI::newWindow(Common::Rect dims, Common::Rect restoreRect, uint16 style, int16 priority, int16 colorPen, int16 colorBack, const char *title) { - sciWnd *wnd = NULL; + GUIWindow *wnd = NULL; if (restoreRect.top != 0 && restoreRect.left != 0 && restoreRect.height() != 0 && restoreRect.width() != 0) wnd = _windowMgr->NewWindow(dims, &restoreRect, title, style, priority, 0); @@ -116,19 +116,19 @@ reg_t SciGUI::newWindow(Common::Rect dims, Common::Rect restoreRect, uint16 styl } void SciGUI::disposeWindow(uint16 windowPtr, int16 arg2) { - sciWnd *wnd = (sciWnd *)heap2Ptr(windowPtr); + GUIWindow *wnd = (GUIWindow *)heap2Ptr(windowPtr); _windowMgr->DisposeWindow(wnd, arg2); } void SciGUI::display(const char *text, int argc, reg_t *argv) { int displayArg; - sciPort oldPort; + GUIPort oldPort; int16 align = 0; int16 bgcolor = -1, width = -1, bRedraw = 1; byte bSaveUnder = false; - Common::Rect rect, *orect = &((sciWnd *)_gfx->GetPort())->dims; + Common::Rect rect, *orect = &((GUIWindow *)_gfx->GetPort())->dims; - memcpy(&oldPort, _gfx->GetPort(), sizeof(sciPort)); + memcpy(&oldPort, _gfx->GetPort(), sizeof(GUIPort)); // setting defaults _gfx->PenMode(0); _gfx->PenColor(0); @@ -200,10 +200,10 @@ void SciGUI::display(const char *text, int argc, reg_t *argv) { // if (_picNotValid == 0 && bRedraw) // _gfx->ShowBits(rect, 1); // restoring port and cursor pos - sciPort *currport = _gfx->GetPort(); + GUIPort *currport = _gfx->GetPort(); uint16 tTop = currport->curTop; uint16 tLeft = currport->curLeft; - memcpy(currport, &oldPort, sizeof(sciPort)); + memcpy(currport, &oldPort, sizeof(GUIPort)); currport->curTop = tTop; currport->curLeft = tLeft; @@ -226,9 +226,9 @@ void SciGUI::textColors(int argc, reg_t *argv) { _gfx->SetTextColors(argc, argv); } -void SciGUI::drawPicture(sciResourceId pictureId, uint16 style, uint16 flags, int16 EGApaletteNo) { +void SciGUI::drawPicture(GUIResourceId pictureId, uint16 style, uint16 flags, int16 EGApaletteNo) { bool addToFlag = flags ? true : false; - sciPort *oldPort = _gfx->SetPort((sciPort *)_windowMgr->_picWind); + GUIPort *oldPort = _gfx->SetPort((GUIPort *)_windowMgr->_picWind); if (_windowMgr->isFrontWindow(_windowMgr->_picWind)) { _gfx->drawPicture(pictureId, style, addToFlag, EGApaletteNo); @@ -243,7 +243,7 @@ void SciGUI::drawPicture(sciResourceId pictureId, uint16 style, uint16 flags, in _s->pic_not_valid = 1; } -void SciGUI::drawCell(sciResourceId viewId, uint16 loopNo, uint16 cellNo, uint16 leftPos, uint16 topPos, int16 priority, uint16 paletteNo) { +void SciGUI::drawCell(GUIResourceId viewId, GUIViewLoopNo loopNo, GUIViewCellNo cellNo, uint16 leftPos, uint16 topPos, int16 priority, uint16 paletteNo) { _gfx->drawCell(viewId, loopNo, cellNo, leftPos, topPos, priority, paletteNo); _gfx->SetCLUT(&_gfx->_sysPalette); _screen->UpdateWhole(); @@ -317,7 +317,7 @@ void SciGUI::paletteAnimate(int fromColor, int toColor, int speed) { } int16 SciGUI::onControl(byte screenMask, Common::Rect rect) { - sciPort *oldPort = _gfx->SetPort((sciPort *)_windowMgr->_picWind); + GUIPort *oldPort = _gfx->SetPort((GUIPort *)_windowMgr->_picWind); int16 result; result = _gfx->onControl(screenMask, rect); @@ -333,12 +333,12 @@ void SciGUI::addToPicList(reg_t listReference, int argc, reg_t *argv) { // FIXME: port over from gregs engine } -void SciGUI::addToPicView(sciResourceId viewId, uint16 loopNo, uint16 cellNo, int16 leftPos, int16 topPos, int16 priority, int16 control) { +void SciGUI::addToPicView(GUIResourceId viewId, GUIViewLoopNo loopNo, GUIViewCellNo cellNo, int16 leftPos, int16 topPos, int16 priority, int16 control) { // FIXME: port over from gregs engine } void SciGUI::setNowSeen(reg_t objectReference) { - // FIXME: port over from gregs engine + _gfx->SetNowSeen(objectReference); } void SciGUI::moveCursor(int16 x, int16 y) { diff --git a/engines/sci/gui/gui.h b/engines/sci/gui/gui.h index 5c52a59fcf..df57cb600a 100644 --- a/engines/sci/gui/gui.h +++ b/engines/sci/gui/gui.h @@ -58,8 +58,8 @@ public: virtual void textFonts(int argc, reg_t *argv); virtual void textColors(int argc, reg_t *argv); - virtual void drawPicture(sciResourceId pictureId, uint16 showStyle, uint16 flags, int16 EGApaletteNo); - virtual void drawCell(sciResourceId viewId, uint16 loopNo, uint16 cellNo, uint16 leftPos, uint16 topPos, int16 priority, uint16 paletteNo); + virtual void drawPicture(GUIResourceId pictureId, uint16 showStyle, uint16 flags, int16 EGApaletteNo); + virtual void drawCell(GUIResourceId viewId, GUIViewLoopNo loopNo, GUIViewCellNo cellNo, uint16 leftPos, uint16 topPos, int16 priority, uint16 paletteNo); virtual void drawControlButton(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 style, bool inverse); virtual void drawControlText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 mode, int16 style, bool inverse); @@ -78,7 +78,7 @@ public: // FIXME: argc/argv because of gui32.cpp, should get removed sometime virtual void animate(reg_t listReference, bool cycle, int argc, reg_t *argv); virtual void addToPicList(reg_t listReference, int argc, reg_t *argv); - virtual void addToPicView(sciResourceId viewId, uint16 loopNo, uint16 cellNo, int16 leftPos, int16 topPos, int16 priority, int16 control); + virtual void addToPicView(GUIResourceId viewId, GUIViewLoopNo loopNo, GUIViewCellNo cellNo, int16 leftPos, int16 topPos, int16 priority, int16 control); virtual void setNowSeen(reg_t objectReference); virtual void moveCursor(int16 x, int16 y); diff --git a/engines/sci/gui/gui_dbllist.cpp b/engines/sci/gui/gui_dbllist.cpp index c44130802e..55aa4b039b 100644 --- a/engines/sci/gui/gui_dbllist.cpp +++ b/engines/sci/gui/gui_dbllist.cpp @@ -52,7 +52,7 @@ void DblList::Dump(char*caption) { debug(" First: %04X Last: %04X", _hFirst, _hLast); HEAPHANDLE node = _hFirst; while (node) { - sciNode *pNode = (sciNode *)heap2Ptr(node); + GUINode *pNode = (GUINode *)heap2Ptr(node); debug(" %04X key=%04X prev=%04X next=%04X add.data=%db", node, pNode->key, pNode->prev, pNode->next, heapGetDataSize(node) - 6); node = pNode->next; @@ -67,10 +67,10 @@ HEAPHANDLE DblList::AddToFront(HEAPHANDLE node, uint16 key) { node); return node; } - sciNode *pNode = (sciNode *)heap2Ptr(node); + GUINode *pNode = (GUINode *)heap2Ptr(node); pNode->key = key; if (_hFirst) { // we already have a 1st node - sciNode *pnext = (sciNode *)heap2Ptr(_hFirst); + GUINode *pnext = (GUINode *)heap2Ptr(_hFirst); pnext->prev = node; pNode->next = _hFirst; } else { // list is empty, to passed node becames 1st one @@ -89,9 +89,9 @@ HEAPHANDLE DblList::AddToEnd(HEAPHANDLE node, uint16 key) { warning("Bad node handler (%04X) passed to DblList::AddToEnd !", node); return node; } - sciNode *pNode = (sciNode *)heap2Ptr(node); + GUINode *pNode = (GUINode *)heap2Ptr(node); if (_hFirst) { // list is not empty - sciNode *plast = (sciNode *)heap2Ptr(_hLast); + GUINode *plast = (GUINode *)heap2Ptr(_hLast); plast->next = node; pNode->prev = _hLast; } else { // list is empty, so the node becames 1st one @@ -110,7 +110,7 @@ HEAPHANDLE DblList::AddToEnd(HEAPHANDLE node, uint16 key) { HEAPHANDLE DblList::FindKey(uint16 key) { HEAPHANDLE node = _hFirst; while (node) { - sciNode *pNode = (sciNode *)heap2Ptr(node); + GUINode *pNode = (GUINode *)heap2Ptr(node); if (pNode->key == key) break; node = pNode->next; @@ -133,13 +133,13 @@ byte DblList::DeleteNode(HEAPHANDLE node) { return node; } // updating the links - sciNode *pNode = (sciNode *)heap2Ptr(node); + GUINode *pNode = (GUINode *)heap2Ptr(node); if (pNode->prev) { - sciNode *pprev = (sciNode *)heap2Ptr(pNode->prev); + GUINode *pprev = (GUINode *)heap2Ptr(pNode->prev); pprev->next = pNode->next; } if (pNode->next) { - sciNode *pnext = (sciNode *)heap2Ptr(pNode->next); + GUINode *pnext = (GUINode *)heap2Ptr(pNode->next); pnext->prev = pNode->prev; } // updating list head if needed @@ -158,7 +158,7 @@ HEAPHANDLE DblList::MoveToEnd(HEAPHANDLE node) { warning("Bad node handler (%04X) passed to DblList::MoveToEnd !", node); return node; } - sciNode *pNode = (sciNode *)heap2Ptr(node); + GUINode *pNode = (GUINode *)heap2Ptr(node); if (pNode->next) { // node is not the last one in list DeleteNode(node); AddToEnd(node, pNode->key); @@ -173,7 +173,7 @@ HEAPHANDLE DblList::MoveToFront(HEAPHANDLE node) { node); return node; } - sciNode *pNode = (sciNode *)heap2Ptr(node); + GUINode *pNode = (GUINode *)heap2Ptr(node); if (pNode->prev) { // node is not 1st one in list DeleteNode(node); AddToFront(node, pNode->key); @@ -186,14 +186,14 @@ HEAPHANDLE DblList::AddAfter(HEAPHANDLE ref, HEAPHANDLE node, uint16 key) { warning("Bad node handler (%04X) passed to DblList::AddAfter !", node); return node; } - sciNode *pNode = (sciNode *)heap2Ptr(node); - sciNode *pref = (sciNode *)heap2Ptr(ref); + GUINode *pNode = (GUINode *)heap2Ptr(node); + GUINode *pref = (GUINode *)heap2Ptr(ref); pNode->key = key; if (pref->next == 0) { // ref node is the last one pNode->next = 0; _hLast = node; } else { - sciNode *pnext = (sciNode *)heap2Ptr(pref->next); + GUINode *pnext = (GUINode *)heap2Ptr(pref->next); pNode->next = pref->next; pnext->prev = node; } @@ -208,14 +208,14 @@ HEAPHANDLE DblList::AddBefore(HEAPHANDLE ref, HEAPHANDLE node, uint16 key) { warning("Bad node handler (%04X) passed to DblList::AddBefore !", node); return node; } - sciNode *pNode = (sciNode *)heap2Ptr(node); - sciNode *pref = (sciNode *)heap2Ptr(ref); + GUINode *pNode = (GUINode *)heap2Ptr(node); + GUINode *pref = (GUINode *)heap2Ptr(ref); pNode->key = key; if (pref->prev == 0) { // ref node is the 1st one pNode->prev = 0; _hFirst = node; } else { - sciNode*pprev = (sciNode *)heap2Ptr(pref->prev); + GUINode*pprev = (GUINode *)heap2Ptr(pref->prev); pNode->prev = pref->prev; pprev->next = node; } @@ -232,9 +232,9 @@ void DblList::toHeap(HEAPHANDLE heap) { //------------------------------------------------ void DblList::DeleteList() { HEAPHANDLE node = getFirst(), next; - sciNode *pNode; + GUINode *pNode; while (node) { - pNode = (sciNode *)heap2Ptr(node); + pNode = (GUINode *)heap2Ptr(node); next = pNode->next; heapDisposePtr(node); node = next; @@ -245,9 +245,9 @@ void DblList::DeleteList() { uint16 DblList::getSize() { uint16 cnt = 0; HEAPHANDLE node = getFirst(); - sciNode *pNode; + GUINode *pNode; while (node) { - pNode = (sciNode *)heap2Ptr(node); + pNode = (GUINode *)heap2Ptr(node); node = pNode->next; cnt++; } diff --git a/engines/sci/gui/gui_font.cpp b/engines/sci/gui/gui_font.cpp index 8246aaa749..06aee14b9f 100644 --- a/engines/sci/gui/gui_font.cpp +++ b/engines/sci/gui/gui_font.cpp @@ -31,7 +31,7 @@ namespace Sci { -SciGUIfont::SciGUIfont(EngineState *state, SciGUIscreen *screen, sciResourceId resourceId) +SciGUIfont::SciGUIfont(EngineState *state, SciGUIscreen *screen, GUIResourceId resourceId) : _s(state), _screen(screen), _resourceId(resourceId) { assert(resourceId != -1); if (_s->_gameName == "lsl1sci") { @@ -44,7 +44,7 @@ SciGUIfont::SciGUIfont(EngineState *state, SciGUIscreen *screen, sciResourceId r SciGUIfont::~SciGUIfont() { } -void SciGUIfont::initData(sciResourceId resourceId) { +void SciGUIfont::initData(GUIResourceId resourceId) { Resource *fontResource = _s->resMan->findResource(ResourceId(kResourceTypeFont, resourceId), false); if (!fontResource) { error("font resource %d not found", resourceId); @@ -62,7 +62,7 @@ void SciGUIfont::initData(sciResourceId resourceId) { } } -sciResourceId SciGUIfont::getResourceId() { +GUIResourceId SciGUIfont::getResourceId() { return _resourceId; } diff --git a/engines/sci/gui/gui_font.h b/engines/sci/gui/gui_font.h index 1b0776e1d5..732f74c6d3 100644 --- a/engines/sci/gui/gui_font.h +++ b/engines/sci/gui/gui_font.h @@ -27,10 +27,10 @@ namespace Sci { class SciGUIfont { public: - SciGUIfont(EngineState *state, SciGUIscreen *screen, sciResourceId resourceId); + SciGUIfont(EngineState *state, SciGUIscreen *screen, GUIResourceId resourceId); ~SciGUIfont(); - sciResourceId getResourceId(); + GUIResourceId getResourceId(); byte getHeight(); byte getCharWidth(byte chr); byte getCharHeight(byte chr); @@ -38,12 +38,12 @@ public: void draw(int16 chr, int16 top, int16 left, byte color, byte textface); private: - void initData(sciResourceId resourceId); + void initData(GUIResourceId resourceId); EngineState *_s; SciGUIscreen *_screen; - sciResourceId _resourceId; + GUIResourceId _resourceId; byte *_resourceData; struct charinfo { diff --git a/engines/sci/gui/gui_gfx.cpp b/engines/sci/gui/gui_gfx.cpp index b417eb4fe8..e16fd7f105 100644 --- a/engines/sci/gui/gui_gfx.cpp +++ b/engines/sci/gui/gui_gfx.cpp @@ -111,10 +111,10 @@ void SciGUIgfx::timerHandler(void *ref) { ((SciGUIgfx *)ref)->_sysTicks++; } -sciPort *SciGUIgfx::mallocPort() { - sciPort *newPort = (sciPort *)malloc(sizeof(sciPort)); +GUIPort *SciGUIgfx::mallocPort() { + GUIPort *newPort = (GUIPort *)malloc(sizeof(GUIPort)); assert(newPort); - memset(newPort, 0, sizeof(sciPort)); + memset(newPort, 0, sizeof(GUIPort)); return newPort; } @@ -148,14 +148,14 @@ void SciGUIgfx::SetEGApalette() { SetCLUT(&_sysPalette); } -void SciGUIgfx::CreatePaletteFromData(byte *data, sciPalette *paletteOut) { +void SciGUIgfx::CreatePaletteFromData(byte *data, GUIPalette *paletteOut) { int palFormat = 0; int palOffset = 0; int palColorStart = 0; int palColorCount = 0; int colorNo = 0; - memset(paletteOut, 0, sizeof(sciPalette)); + memset(paletteOut, 0, sizeof(GUIPalette)); // Setup default mapping for (colorNo = 0; colorNo < 256; colorNo++) { paletteOut->mapping[colorNo] = colorNo; @@ -194,7 +194,7 @@ void SciGUIgfx::CreatePaletteFromData(byte *data, sciPalette *paletteOut) { bool SciGUIgfx::SetResPalette(int16 resourceNo, int16 flag) { Resource *palResource = _s->resMan->findResource(ResourceId(kResourceTypePalette, resourceNo), 0); - sciPalette palette; + GUIPalette palette; if (palResource) { CreatePaletteFromData(palResource->data, &palette); @@ -204,7 +204,7 @@ bool SciGUIgfx::SetResPalette(int16 resourceNo, int16 flag) { return false; } -void SciGUIgfx::SetPalette(sciPalette *sciPal, int16 flag) { +void SciGUIgfx::SetPalette(GUIPalette *sciPal, int16 flag) { uint32 systime = _sysPalette.timestamp; if (flag == 2 || sciPal->timestamp != systime) { MergePalettes(sciPal, &_sysPalette, flag); @@ -214,7 +214,7 @@ void SciGUIgfx::SetPalette(sciPalette *sciPal, int16 flag) { } } -void SciGUIgfx::MergePalettes(sciPalette *pFrom, sciPalette *pTo, uint16 flag) { +void SciGUIgfx::MergePalettes(GUIPalette *pFrom, GUIPalette *pTo, uint16 flag) { uint16 res; int i,j; // colors 0 (black) and 255 (white) are not affected by merging @@ -255,7 +255,7 @@ void SciGUIgfx::MergePalettes(sciPalette *pFrom, sciPalette *pTo, uint16 flag) { pTo->timestamp = _sysTicks; } -uint16 SciGUIgfx::MatchColor(sciPalette*pPal, byte r, byte g, byte b) { +uint16 SciGUIgfx::MatchColor(GUIPalette*pPal, byte r, byte g, byte b) { byte found = 0xFF; int diff = 0x2FFFF, cdiff; int16 dr,dg,db; @@ -280,9 +280,9 @@ uint16 SciGUIgfx::MatchColor(sciPalette*pPal, byte r, byte g, byte b) { return found; } -void SciGUIgfx::SetCLUT(sciPalette*pal) { +void SciGUIgfx::SetCLUT(GUIPalette*pal) { if (pal != &_sysPalette) - memcpy(&_sysPalette,pal,sizeof(sciPalette)); + memcpy(&_sysPalette,pal,sizeof(GUIPalette)); // just copy palette to system byte bpal[4 * 256]; // Get current palette, update it and put back @@ -299,18 +299,18 @@ void SciGUIgfx::SetCLUT(sciPalette*pal) { _system->updateScreen(); } -void SciGUIgfx::GetCLUT(sciPalette*pal) { +void SciGUIgfx::GetCLUT(GUIPalette*pal) { if (pal != &_sysPalette) - memcpy(pal,&_sysPalette,sizeof(sciPalette)); + memcpy(pal,&_sysPalette,sizeof(GUIPalette)); } -sciPort *SciGUIgfx::SetPort(sciPort *newPort) { - sciPort *oldPort = _curPort; +GUIPort *SciGUIgfx::SetPort(GUIPort *newPort) { + GUIPort *oldPort = _curPort; _curPort = newPort; return oldPort; } -sciPort *SciGUIgfx::GetPort(void) { +GUIPort *SciGUIgfx::GetPort(void) { return _curPort; } @@ -329,7 +329,7 @@ void SciGUIgfx::Move(int16 left, int16 top) { _curPort->curLeft += left; } -sciResourceId SciGUIgfx::GetFontId() { +GUIResourceId SciGUIgfx::GetFontId() { return _curPort->fontId; } @@ -340,7 +340,7 @@ SciGUIfont *SciGUIgfx::GetFont() { return _font; } -void SciGUIgfx::SetFont(sciResourceId fontId) { +void SciGUIgfx::SetFont(GUIResourceId fontId) { if ((_font == NULL) || (_font->getResourceId() != fontId)) { _font = new SciGUIfont(_s, _screen, fontId); } @@ -348,11 +348,11 @@ void SciGUIgfx::SetFont(sciResourceId fontId) { _curPort->fontHeight = _font->getHeight(); } -void SciGUIgfx::OpenPort(sciPort *port) { +void SciGUIgfx::OpenPort(GUIPort *port) { port->fontId = 0; port->fontHeight = 8; - sciPort *tmp = _curPort; + GUIPort *tmp = _curPort; _curPort = port; SetFont(port->fontId); _curPort = tmp; @@ -528,9 +528,9 @@ void SciGUIgfx::SetTextFonts(int argc, reg_t *argv) { delete _textFonts; } _textFontsCount = argc; - _textFonts = new sciResourceId[argc]; + _textFonts = new GUIResourceId[argc]; for (i = 0; i < argc; i++) { - _textFonts[i] = (sciResourceId)argv[i].toUint16(); + _textFonts[i] = (GUIResourceId)argv[i].toUint16(); } } @@ -551,7 +551,7 @@ void SciGUIgfx::SetTextColors(int argc, reg_t *argv) { // It will process the encountered code and set new font/set color // We only support one-digit codes currently, don't know if multi-digit codes are possible // Returns textcode character count -int16 SciGUIgfx::TextCodeProcessing(const char *&text, sciResourceId orgFontId, int16 orgPenColor) { +int16 SciGUIgfx::TextCodeProcessing(const char *&text, GUIResourceId orgFontId, int16 orgPenColor) { const char *textCode = text; int16 textCodeSize = 0; char curCode; @@ -594,11 +594,11 @@ int16 SciGUIgfx::TextCodeProcessing(const char *&text, sciResourceId orgFontId, } // return max # of chars to fit maxwidth with full words -int16 SciGUIgfx::GetLongest(const char *text, int16 maxWidth, sciResourceId orgFontId) { +int16 SciGUIgfx::GetLongest(const char *text, int16 maxWidth, GUIResourceId orgFontId) { char curChar; int16 maxChars = 0, curCharCount = 0; uint16 width = 0; - sciResourceId oldFontId = GetFontId(); + GUIResourceId oldFontId = GetFontId(); int16 oldPenColor = _curPort->penClr; GetFont(); @@ -636,9 +636,9 @@ int16 SciGUIgfx::GetLongest(const char *text, int16 maxWidth, sciResourceId orgF return maxChars; } -void SciGUIgfx::TextWidth(const char *text, int16 from, int16 len, sciResourceId orgFontId, int16 &textWidth, int16 &textHeight) { +void SciGUIgfx::TextWidth(const char *text, int16 from, int16 len, GUIResourceId orgFontId, int16 &textWidth, int16 &textHeight) { unsigned char curChar; - sciResourceId oldFontId = GetFontId(); + GUIResourceId oldFontId = GetFontId(); int16 oldPenColor = _curPort->penClr; textWidth = 0; textHeight = 0; @@ -667,12 +667,12 @@ void SciGUIgfx::TextWidth(const char *text, int16 from, int16 len, sciResourceId return; } -void SciGUIgfx::StringWidth(const char *str, sciResourceId orgFontId, int16 &textWidth, int16 &textHeight) { +void SciGUIgfx::StringWidth(const char *str, GUIResourceId orgFontId, int16 &textWidth, int16 &textHeight) { TextWidth(str, 0, (int16)strlen(str), orgFontId, textWidth, textHeight); } -int16 SciGUIgfx::TextSize(Common::Rect &rect, const char *str, sciResourceId fontId, int16 maxWidth) { - sciResourceId oldFontId = GetFontId(); +int16 SciGUIgfx::TextSize(Common::Rect &rect, const char *str, GUIResourceId fontId, int16 maxWidth) { + GUIResourceId oldFontId = GetFontId(); int16 oldPenColor = _curPort->penClr; int16 charCount; int16 maxTextWidth = 0, textWidth; @@ -713,7 +713,7 @@ int16 SciGUIgfx::TextSize(Common::Rect &rect, const char *str, sciResourceId fon } // returns maximum font height used -void SciGUIgfx::DrawText(const char *text, int16 from, int16 len, sciResourceId orgFontId, int16 orgPenColor) { +void SciGUIgfx::DrawText(const char *text, int16 from, int16 len, GUIResourceId orgFontId, int16 orgPenColor) { int16 curChar, charWidth; Common::Rect rect; @@ -752,7 +752,7 @@ void SciGUIgfx::DrawText(const char *text, int16 from, int16 len, sciResourceId } // returns maximum font height used -void SciGUIgfx::ShowText(const char *text, int16 from, int16 len, sciResourceId orgFontId, int16 orgPenColor) { +void SciGUIgfx::ShowText(const char *text, int16 from, int16 len, GUIResourceId orgFontId, int16 orgPenColor) { Common::Rect rect; rect.top = _curPort->curTop; @@ -764,10 +764,10 @@ void SciGUIgfx::ShowText(const char *text, int16 from, int16 len, sciResourceId } // Draws a text in rect. -void SciGUIgfx::TextBox(const char *text, int16 bshow, const Common::Rect &rect, int16 align, sciResourceId fontId) { +void SciGUIgfx::TextBox(const char *text, int16 bshow, const Common::Rect &rect, int16 align, GUIResourceId fontId) { int16 textWidth, textHeight, charCount, offset; int16 hline = 0; - sciResourceId orgFontId = GetFontId(); + GUIResourceId orgFontId = GetFontId(); int16 orgPenColor = _curPort->penClr; if (fontId != -1) @@ -821,8 +821,8 @@ void SciGUIgfx::ShowBits(const Common::Rect &r, uint16 flags) { // _system->updateScreen(); } -sciMemoryHandle SciGUIgfx::SaveBits(const Common::Rect &rect, byte screenMask) { - sciMemoryHandle memoryId; +GUIMemoryHandle SciGUIgfx::SaveBits(const Common::Rect &rect, byte screenMask) { + GUIMemoryHandle memoryId; byte *memoryPtr; int size; @@ -842,7 +842,7 @@ sciMemoryHandle SciGUIgfx::SaveBits(const Common::Rect &rect, byte screenMask) { return memoryId; } -void SciGUIgfx::RestoreBits(sciMemoryHandle memoryHandle) { +void SciGUIgfx::RestoreBits(GUIMemoryHandle memoryHandle) { byte *memoryPtr = kmem(_s->segMan, memoryHandle);; if (memoryPtr) { @@ -1192,7 +1192,7 @@ void SciGUIgfx::Pic_Fill(int16 x, int16 y, byte color, byte prio, byte control) } } -void SciGUIgfx::drawPicture(sciResourceId pictureId, uint16 style, bool addToFlag, sciResourceId paletteId) { +void SciGUIgfx::drawPicture(GUIResourceId pictureId, uint16 style, bool addToFlag, GUIResourceId paletteId) { SciGUIpicture *picture; picture = new SciGUIpicture(_s, this, _screen, pictureId); @@ -1203,7 +1203,7 @@ void SciGUIgfx::drawPicture(sciResourceId pictureId, uint16 style, bool addToFla picture->draw(style, addToFlag, paletteId); } -void SciGUIgfx::drawCell(sciResourceId viewId, uint16 loopNo, uint16 cellNo, uint16 leftPos, uint16 topPos, byte priority, uint16 paletteNo) { +void SciGUIgfx::drawCell(GUIResourceId viewId, GUIViewLoopNo loopNo, GUIViewCellNo cellNo, uint16 leftPos, uint16 topPos, byte priority, uint16 paletteNo) { SciGUIview *view = new SciGUIview(_system, _s, this, _screen, viewId); Common::Rect rect(0, 0); Common::Rect clipRect(0, 0); @@ -1223,7 +1223,7 @@ void SciGUIgfx::drawCell(sciResourceId viewId, uint16 loopNo, uint16 cellNo, uin } void SciGUIgfx::animatePalette(byte fromColor, byte toColor, int speed) { - sciColor col; + GUIColor col; int len = toColor - fromColor - 1; uint32 now = _sysTicks; // search for sheduled animations with the same 'from' value @@ -1233,11 +1233,11 @@ void SciGUIgfx::animatePalette(byte fromColor, byte toColor, int speed) { if (_palSchedules[i].schedule < now) { if (speed > 0) { col = _sysPalette.colors[fromColor]; - memmove(&_sysPalette.colors[fromColor], &_sysPalette.colors[fromColor + 1], len * sizeof(sciColor)); + memmove(&_sysPalette.colors[fromColor], &_sysPalette.colors[fromColor + 1], len * sizeof(GUIColor)); _sysPalette.colors[toColor - 1] = col; } else { col = _sysPalette.colors[toColor - 1]; - memmove(&_sysPalette.colors[fromColor+1], &_sysPalette.colors[fromColor], len * sizeof(sciColor)); + memmove(&_sysPalette.colors[fromColor+1], &_sysPalette.colors[fromColor], len * sizeof(GUIColor)); _sysPalette.colors[fromColor] = col; } // removing schedule @@ -1248,7 +1248,7 @@ void SciGUIgfx::animatePalette(byte fromColor, byte toColor, int speed) { } } // adding a new schedule - sciPalSched sched; + GUIPalSchedule sched; sched.from = fromColor; sched.schedule = now + ABS(speed); _palSchedules.push_back(sched); @@ -1280,4 +1280,38 @@ int16 SciGUIgfx::onControl(uint16 screenMask, Common::Rect rect) { return result; } +static inline int sign_extend_byte(int value) { + if (value & 0x80) + return value - 256; + else + return value; +} + +void SciGUIgfx::SetNowSeen(reg_t objectReference) { + SegManager *segMan = _s->segMan; + SciGUIview *view = NULL; + Common::Rect cellRect(0, 0); + GUIResourceId viewId = (GUIResourceId)GET_SEL32V(objectReference, view); + GUIViewLoopNo loopNo = sign_extend_byte((GUIViewLoopNo)GET_SEL32V(objectReference, loop)); + GUIViewCellNo cellNo = sign_extend_byte((GUIViewCellNo)GET_SEL32V(objectReference, cel)); + int16 x = (int16)GET_SEL32V(objectReference, x); + int16 y = (int16)GET_SEL32V(objectReference, y); + int16 z = 0; + if (_s->_kernel->_selectorCache.z > -1) { + z = (int16)GET_SEL32V(objectReference, z); + } + + // now get cell rectangle + view = new SciGUIview(_system, _s, this, _screen, viewId); + view->getCellRect(loopNo, cellNo, x, y, z, &cellRect); + + // TODO: sometimes loop is negative. Check what it means + if (lookup_selector(_s->segMan, objectReference, _s->_kernel->_selectorCache.nsTop, NULL, NULL) == kSelectorVariable) { + PUT_SEL32V(objectReference, nsLeft, cellRect.left); + PUT_SEL32V(objectReference, nsRight, cellRect.right); + PUT_SEL32V(objectReference, nsTop, cellRect.top); + PUT_SEL32V(objectReference, nsBottom, cellRect.bottom); + } +} + } // end of namespace Sci diff --git a/engines/sci/gui/gui_gfx.h b/engines/sci/gui/gui_gfx.h index 018b86090a..eda100d751 100644 --- a/engines/sci/gui/gui_gfx.h +++ b/engines/sci/gui/gui_gfx.h @@ -43,31 +43,31 @@ public: void initTimer(); static void timerHandler(void*ref); - sciPort *mallocPort (); + GUIPort *mallocPort (); byte *GetSegment(byte seg); void ResetScreen(); void SetEGApalette(); - void CreatePaletteFromData(byte *paletteData, sciPalette *paletteOut); + void CreatePaletteFromData(byte *paletteData, GUIPalette *paletteOut); bool SetResPalette(int16 resourceNo, int16 flag); - void SetPalette(sciPalette *sciPal, int16 flag); - void MergePalettes(sciPalette*pFrom, sciPalette*pTo, uint16 flag); - uint16 MatchColor(sciPalette*pPal, byte r, byte g, byte b); - void SetCLUT(sciPalette*pal); - void GetCLUT(sciPalette*pal); - - sciPort *SetPort(sciPort *port); - sciPort *GetPort(); + void SetPalette(GUIPalette *sciPal, int16 flag); + void MergePalettes(GUIPalette* pFrom, GUIPalette* pTo, uint16 flag); + uint16 MatchColor(GUIPalette* pPal, byte r, byte g, byte b); + void SetCLUT(GUIPalette*pal); + void GetCLUT(GUIPalette*pal); + + GUIPort *SetPort(GUIPort *port); + GUIPort *GetPort(); void SetOrigin(int16 left, int16 top); void MoveTo(int16 left, int16 top); void Move(int16 left, int16 top); - void OpenPort(sciPort *port); + void OpenPort(GUIPort *port); void PenColor(int16 color); void PenMode(int16 mode); void TextFace(int16 textFace); int16 GetPointSize(void); - sciResourceId GetFontId(); + GUIResourceId GetFontId(); SciGUIfont *GetFont(); - void SetFont(sciResourceId fontId); + void SetFont(GUIResourceId fontId); void ClearScreen(byte color = 255); void InvertRect(const Common::Rect &rect); @@ -85,17 +85,17 @@ public: void SetTextFonts(int argc, reg_t *argv); void SetTextColors(int argc, reg_t *argv); - int16 TextSize(Common::Rect &rect, const char *str, sciResourceId fontId, int16 maxwidth); - void ShowString(const char *str, sciResourceId orgFontId, int16 orgPenColor) { + int16 TextSize(Common::Rect &rect, const char *str, GUIResourceId fontId, int16 maxwidth); + void ShowString(const char *str, GUIResourceId orgFontId, int16 orgPenColor) { ShowText(str, 0, (int16)strlen(str), orgFontId, orgPenColor); } - void DrawString(const char *str, sciResourceId orgFontId, int16 orgPenColor) { + void DrawString(const char *str, GUIResourceId orgFontId, int16 orgPenColor) { DrawText(str, 0, (int16)strlen(str), orgFontId, orgPenColor); } - void TextBox(const char *str, int16 bshow, const Common::Rect &rect, int16 align, sciResourceId fontId); + void TextBox(const char *str, int16 bshow, const Common::Rect &rect, int16 align, GUIResourceId fontId); void ShowBits(const Common::Rect &r, uint16 flags); - sciMemoryHandle SaveBits(const Common::Rect &rect, byte screenFlags); - void RestoreBits(sciMemoryHandle memoryHandle); + GUIMemoryHandle SaveBits(const Common::Rect &rect, byte screenFlags); + void RestoreBits(GUIMemoryHandle memoryHandle); void Draw_Line(int16 left, int16 top, int16 right, int16 bottom, byte color, byte prio, byte control); void Draw_Horiz(int16 left, int16 right, int16 top, byte flag, byte color, byte prio, byte control); @@ -107,45 +107,46 @@ public: void Draw_Pattern(int16 x, int16 y, byte pic_color, byte pic_priority, byte pic_control, byte code, byte texture); void Pic_Fill(int16 x, int16 y, byte color, byte prio, byte control); - void drawPicture(sciResourceId pictureId, uint16 style, bool addToFlag, sciResourceId paletteId); - void drawCell(sciResourceId viewId, uint16 loopNo, uint16 cellNo, uint16 leftPos, uint16 topPos, byte priority, uint16 paletteNo); + void drawPicture(GUIResourceId pictureId, uint16 style, bool addToFlag, GUIResourceId paletteId); + void drawCell(GUIResourceId viewId, GUIViewLoopNo loopNo, GUIViewCellNo cellNo, uint16 leftPos, uint16 topPos, byte priority, uint16 paletteNo); void animatePalette(byte fromColor, byte toColor, int speed); int16 onControl(uint16 screenMask, Common::Rect rect); + void SetNowSeen(reg_t objectReference); - sciPort *_menuPort; + GUIPort *_menuPort; uint32 _sysTicks; int32 _sysSpeed; // ticker timer in ms - sciPalette _sysPalette; + GUIPalette _sysPalette; uint16 _resolutionWidth; uint16 _resolutionHeight; uint _resolutionPixels; private: - int16 TextCodeProcessing(const char *&text, sciResourceId orgFontId, int16 orgPenColor); - void TextWidth(const char*text, int16 from, int16 len, sciResourceId orgFontId, int16 &textWidth, int16 &textHeight); - void StringWidth(const char*str, sciResourceId orgFontId, int16 &textWidth, int16 &textHeight); - int16 GetLongest(const char *str, int16 maxwidth, sciResourceId orgFontId); - void DrawText(const char *str, int16 from, int16 len, sciResourceId orgFontId, int16 orgPenColor); - void ShowText(const char *str, int16 from, int16 len, sciResourceId orgFontId, int16 orgPenColor); + int16 TextCodeProcessing(const char *&text, GUIResourceId orgFontId, int16 orgPenColor); + void TextWidth(const char*text, int16 from, int16 len, GUIResourceId orgFontId, int16 &textWidth, int16 &textHeight); + void StringWidth(const char*str, GUIResourceId orgFontId, int16 &textWidth, int16 &textHeight); + int16 GetLongest(const char *str, int16 maxwidth, GUIResourceId orgFontId); + void DrawText(const char *str, int16 from, int16 len, GUIResourceId orgFontId, int16 orgPenColor); + void ShowText(const char *str, int16 from, int16 len, GUIResourceId orgFontId, int16 orgPenColor); OSystem *_system; EngineState *_s; SciGUIscreen *_screen; Common::Rect _bounds; - sciPort *_mainPort; - sciPort *_curPort; + GUIPort *_mainPort; + GUIPort *_curPort; uint16 _clrPowers[256]; byte bMapColors; - sciPalette *pPicPal; - Common::Array<sciPalSched> _palSchedules; + GUIPalette *pPicPal; + Common::Array<GUIPalSchedule> _palSchedules; int _textFontsCount; - sciResourceId *_textFonts; + GUIResourceId *_textFonts; int _textColorsCount; uint16 *_textColors; diff --git a/engines/sci/gui/gui_helpers.h b/engines/sci/gui/gui_helpers.h index 816a387cb7..c6a97be56a 100644 --- a/engines/sci/gui/gui_helpers.h +++ b/engines/sci/gui/gui_helpers.h @@ -28,67 +28,70 @@ namespace Sci { -typedef int sciResourceId; // is a resource-number and -1 means no parameter given -typedef reg_t sciMemoryHandle; -typedef uint16 SCIHANDLE; +typedef int GUIResourceId; // is a resource-number and -1 means no parameter given +typedef reg_t GUIMemoryHandle; +typedef int16 GUIViewLoopNo; +typedef int16 GUIViewCellNo; -struct sciNode { - SCIHANDLE next; // heap handle to next node - SCIHANDLE prev; // heap handle to data +typedef uint16 GUIHandle; + +struct GUINode { + GUIHandle next; // heap handle to next node + GUIHandle prev; // heap handle to data uint16 key; // maybe also a heap handle }; -struct sciNode1 : sciNode { +struct GUINode1 : GUINode { uint16 value; }; -// sciPort and sciWnd need to be binary identical, so if you change anything in one, you have to change it in the other one +// GUIPort and GUIWindow need to be binary identical, so if you change anything in one, you have to change it in the other one // as well! -struct sciPort { - sciNode node; // node struct for list operations +struct GUIPort { + GUINode node; // node struct for list operations int16 top, left; Common::Rect rect; int16 curTop, curLeft; int16 fontHeight; - sciResourceId fontId; + GUIResourceId fontId; int16 textFace, penClr, backClr; int16 penMode; }; -struct sciWnd : public sciPort { +struct GUIWindow : public GUIPort { Common::Rect dims; // client area of window Common::Rect restoreRect; // total area of window including borders uint16 wndStyle; uint16 uSaveFlag; reg_t hSaved1; reg_t hSaved2; - SCIHANDLE hTitle; - bool bDrawed; + GUIHandle hTitle; + bool bDrawn; }; -struct sciCast { - sciNode node; +struct GUICast { + GUINode node; uint16 view; uint16 loop; uint16 cel; uint16 z; uint16 pal; - SCIHANDLE hSaved; + GUIHandle hSaved; Common::Rect rect; }; -struct sciColor { +struct GUIColor { byte used; byte r, g, b; }; -struct sciPalette { +struct GUIPalette { byte mapping[256]; uint32 timestamp; - sciColor colors[256]; + GUIColor colors[256]; byte intensity[256]; }; -struct sciPalSched { +struct GUIPalSchedule { byte from; uint32 schedule; }; @@ -112,13 +115,4 @@ enum { GFX_REMOVEVIEW = 0x80 }; -enum SCILanguage{ - kLangNone = 0, - kLangEnglish = 1, - kLangFrench = 33, - kLangSpanish = 34, - kLangItalian = 39, - kLangGerman = 49 -}; - } |