From 109e5f8226c1db18926e307d4ecb9c3c83fdd7bc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 12 May 2012 20:49:36 +1000 Subject: TONY: Conversion of more methods to coroutines --- engines/tony/custom.cpp | 9 +- engines/tony/detection_tables.h | 4 + engines/tony/font.cpp | 185 +++++++++++------ engines/tony/font.h | 24 +-- engines/tony/game.cpp | 431 +++++++++++++++++++++++++--------------- engines/tony/game.h | 28 +-- engines/tony/gfxcore.cpp | 124 ++++++++---- engines/tony/gfxcore.h | 33 +-- engines/tony/gfxengine.cpp | 24 ++- engines/tony/gfxengine.h | 1 + engines/tony/input.cpp | 12 ++ engines/tony/input.h | 11 +- engines/tony/inventory.cpp | 91 +++++---- engines/tony/inventory.h | 6 +- engines/tony/loc.cpp | 69 +++++-- engines/tony/loc.h | 16 +- engines/tony/tony.cpp | 27 +-- engines/tony/tonychar.cpp | 15 +- engines/tony/tonychar.h | 2 +- 19 files changed, 698 insertions(+), 414 deletions(-) diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index a9e8e5bc62..a3a57dfce9 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2155,6 +2155,9 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr if (_ctx->num == 1) { mpalQueryDialogSelection(_ctx->nChoice, _ctx->sl[0]); GlobalFree(_ctx->sl); + + // Wait for the next choice to be made + mpalQueryDialogWaitForChoice(&_ctx->nChoice); continue; } @@ -2181,7 +2184,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr while (!(Input->MouseLeftClicked() && ((_ctx->sel = _ctx->dc.GetSelection()) != -1))) { CORO_INVOKE_0(WaitFrame); Freeze(); - _ctx->dc.DoFrame(Input->MousePos()); + CORO_INVOKE_1(_ctx->dc.DoFrame, Input->MousePos()); Unfreeze(); } @@ -2214,7 +2217,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { // EnterCriticalSection(&cs[num]); // WaitForSingleObject(mut[num],CORO_INFINITE); - warning("TODO"); + warning("TODO: TakeOwnership"); } DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { @@ -2644,7 +2647,7 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 CORO_INVOKE_0(WaitFrame); if (Input->MouseLeftClicked() || Input->MouseRightClicked()) break; - if ((GetAsyncKeyState(Common::KEYCODE_TAB) & 0x8001) == 0x8001) + if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_TAB)) break; } diff --git a/engines/tony/detection_tables.h b/engines/tony/detection_tables.h index bb660dd862..afcf787ca1 100644 --- a/engines/tony/detection_tables.h +++ b/engines/tony/detection_tables.h @@ -32,7 +32,11 @@ static const TonyGameDescription gameDescriptions[] = { AD_ENTRY1s("roasted.mpr", "06203dbbc85fdd1e6dc8fc211c1a6207", 14972409), Common::EN_ANY, Common::kPlatformPC, +#ifdef TEMPORARY_DISABLED ADGF_DEMO, +#else + ADGF_NO_FLAGS, +#endif GUIO1(GUIO_NONE) }, }, diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 8cc60a917b..5712014bf2 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -152,12 +152,19 @@ RMGfxPrimitive *RMFont::MakeLetterPrimitive(byte bChar, int &nLength) { return prim; } -void RMFont::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim2) { - RMFontPrimitive *prim = (RMFontPrimitive *)prim2; +void RMFont::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim2) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + RMFontPrimitive *prim = (RMFontPrimitive *)prim2; + + CORO_BEGIN_CODE(_ctx); + + // Richiama la Draw della lettera assegnata alla primitiva + if (prim->m_nChar != -1) + CORO_INVOKE_2(m_letter[prim->m_nChar].Draw, bigBuf, prim); - // Richiama la Draw della lettera assegnata alla primitiva - if (prim->m_nChar != -1) - m_letter[prim->m_nChar].Draw(bigBuf,prim); + CORO_END_CODE; } void RMFont::Close(void) { @@ -1845,10 +1852,10 @@ void RMText::SetMaxLineLength(int max) { maxLineLength = max; } -bool RMText::RemoveThis() { +void RMText::RemoveThis(CORO_PARAM, bool &result) { // Qui possiamo fare i controlli sul numero di frame, sul tempo trascorso // etc. - return true; + result = true; } @@ -2007,7 +2014,11 @@ void RMText::ClipOnScreen(RMGfxPrimitive *prim) { if (prim->Dst().y1+m_dimy > 475) prim->Dst().y1 = 475 - m_dimy; } -void RMText::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMText::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); // Allinea orizzontalmente if (aHorType == HCENTER) prim->Dst().TopLeft() -= RMPoint(m_dimx / 2, 0); @@ -2016,22 +2027,20 @@ void RMText::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // Alinea verticalemente - switch (aVerType) { - case VTOP: - break; + if (aVerType == VTOP) { - case VCENTER: - prim->Dst().y1-=m_dimy/2; - break; + } else if (aVerType == VCENTER) { + prim->Dst().y1 -= m_dimy / 2; - case VBOTTOM: - prim->Dst().y1-=m_dimy; - break; + } else if (aVerType == VBOTTOM) { + prim->Dst().y1 -= m_dimy; } ClipOnScreen(prim); - RMGfxWoodyBuffer::Draw(bigBuf,prim); + CORO_INVOKE_2(RMGfxWoodyBuffer::Draw, bigBuf, prim); + + CORO_END_CODE; } /****************************************************************************\ @@ -2127,7 +2136,7 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { } if (!m_bNoTab) - if ((GetAsyncKeyState(Common::KEYCODE_TAB) & 0x8001) == 0x8001) + if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_TAB)) return; if (!m_bNoTab) @@ -2173,16 +2182,23 @@ void RMTextDialog::Unregister(void) { CoroScheduler.setEvent(hEndDisplay); } -void RMTextDialog::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMTextDialog::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (m_startTime == 0) m_startTime = _vm->GetTime(); if (m_bShowed) { if (bCfgSottotitoli || m_bAlwaysDisplay) { prim->Dst().TopLeft() = dst; - RMText::Draw(bigBuf, prim); + CORO_INVOKE_2(RMText::Draw, bigBuf, prim); } } + + CORO_END_CODE; } void RMTextDialog::SetCustomSkipHandle(uint32 hCustom) { @@ -2217,17 +2233,23 @@ RMTextDialogScrolling::RMTextDialogScrolling(RMLocation *loc) { RMTextDialogScrolling::~RMTextDialogScrolling() { } -void RMTextDialogScrolling::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - RMPoint curDst; +void RMTextDialogScrolling::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + RMPoint curDst; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); - curDst = dst; + _ctx->curDst = dst; if (curLoc != NULL) dst -= curLoc->ScrollPosition() - startScroll; - RMTextDialog::Draw(bigBuf, prim); + CORO_INVOKE_2(RMTextDialog::Draw, bigBuf, prim); + + dst = _ctx->curDst; - dst = curDst; + CORO_END_CODE; } void RMTextDialogScrolling::ClipOnScreen(RMGfxPrimitive *prim) { @@ -2298,7 +2320,12 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & } -void RMTextItemName::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMTextItemName::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + // Se non c'e' testo, e' inutile continuare if (m_buf == NULL) return; @@ -2306,7 +2333,9 @@ void RMTextItemName::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // Setta come coordinate destinazione quelle del mouse prim->Dst().TopLeft() = m_mpos-RMPoint(0, 30); - RMText::Draw(bigBuf,prim); + CORO_INVOKE_2(RMText::Draw, bigBuf, prim); + + CORO_END_CODE; } RMPoint RMTextItemName::GetHotspot() { @@ -2411,9 +2440,13 @@ void RMDialogChoice::AddChoice(RMString string) { m_drawedStrings[m_curAdded++].WriteText(string,0); } -void RMDialogChoice::Prepare(void) { - int i; - RMPoint ptPos; +void RMDialogChoice::Prepare(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + int i; + RMPoint ptPos; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); AddPrim(new RMGfxPrimitive(&DlgText,RMPoint(0,0))); AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155))); @@ -2421,53 +2454,60 @@ void RMDialogChoice::Prepare(void) { AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155+83+83))); AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155+83+83+83))); - ptPos.Set(20,90); + _ctx->ptPos.Set(20,90); - for (i = 0; i < m_numChoices; i++) { - AddPrim(new RMGfxPrimitive(&m_drawedStrings[i], ptPos)); - m_ptDrawStrings[i] = ptPos; - ptPos.Offset(0,m_drawedStrings[i].Dimy() + 15); + for (_ctx->i = 0; _ctx->i < m_numChoices; _ctx->i++) { + AddPrim(new RMGfxPrimitive(&m_drawedStrings[_ctx->i], _ctx->ptPos)); + m_ptDrawStrings[_ctx->i] = _ctx->ptPos; + _ctx->ptPos.Offset(0,m_drawedStrings[_ctx->i].Dimy() + 15); } - DrawOT(); + CORO_INVOKE_0(DrawOT); ClearOT(); - m_ptDrawPos.Set(0,480-ptPos.y); + m_ptDrawPos.Set(0,480-_ctx->ptPos.y); + + CORO_END_CODE; } -void RMDialogChoice::SetSelected(int pos) { - //uint16 * buf = (uint16 *)m_buf; - RMGfxBox box; - RMRect rc; +void RMDialogChoice::SetSelected(CORO_PARAM, int pos) { + CORO_BEGIN_CONTEXT; + RMGfxBox box; + RMRect rc; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); if (pos == m_curSelection) return; - box.SetPriority(5); + _ctx->box.SetPriority(5); if (m_curSelection != -1) { - box.SetColor(0xCC, 0xCC, 0xFF); - rc.TopLeft()=RMPoint(18, m_ptDrawStrings[m_curSelection].y); - rc.BottomRight() = rc.TopLeft() + RMPoint(597, m_drawedStrings[m_curSelection].Dimy()); - AddPrim(new RMGfxPrimitive(&box, rc)); + _ctx->box.SetColor(0xCC, 0xCC, 0xFF); + _ctx->rc.TopLeft()=RMPoint(18, m_ptDrawStrings[m_curSelection].y); + _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, m_drawedStrings[m_curSelection].Dimy()); + AddPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); AddPrim(new RMGfxPrimitive(&m_drawedStrings[m_curSelection], m_ptDrawStrings[m_curSelection])); - DrawOT(); + CORO_INVOKE_0(DrawOT); ClearOT(); } if (pos != -1) { - box.SetColor(100, 100, 100); - rc.TopLeft()=RMPoint(18, m_ptDrawStrings[pos].y); - rc.BottomRight() = rc.TopLeft()+RMPoint(597, m_drawedStrings[pos].Dimy()); - AddPrim(new RMGfxPrimitive(&box, rc)); + _ctx->box.SetColor(100, 100, 100); + _ctx->rc.TopLeft()=RMPoint(18, m_ptDrawStrings[pos].y); + _ctx->rc.BottomRight() = _ctx->rc.TopLeft()+RMPoint(597, m_drawedStrings[pos].Dimy()); + AddPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); AddPrim(new RMGfxPrimitive(&m_drawedStrings[pos], m_ptDrawStrings[pos])); } - DrawOT(); + CORO_INVOKE_0(DrawOT); ClearOT(); m_curSelection = pos; + + CORO_END_CODE; } void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { @@ -2480,7 +2520,7 @@ void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { CORO_BEGIN_CODE(_ctx); - Prepare(); + CORO_INVOKE_0(Prepare); m_bShow = false; if (!m_nInList && bigBuf != NULL) @@ -2513,12 +2553,19 @@ void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { CORO_END_CODE; } -void RMDialogChoice::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMDialogChoice::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (m_bShow == false) return; prim->SetDst(m_ptDrawPos); - RMGfxSourceBuffer16::Draw(bigBuf, prim); + CORO_INVOKE_2(RMGfxSourceBuffer16::Draw, bigBuf, prim); + + CORO_END_CODE; } @@ -2553,24 +2600,30 @@ void RMDialogChoice::Hide(CORO_PARAM) { } -bool RMDialogChoice::RemoveThis(void) { - return bRemoveFromOT; +void RMDialogChoice::RemoveThis(CORO_PARAM, bool &result) { + result = bRemoveFromOT; } -void RMDialogChoice::DoFrame(RMPoint ptMousePos) { - int i; - +void RMDialogChoice::DoFrame(CORO_PARAM, RMPoint ptMousePos) { + CORO_BEGIN_CONTEXT; + int i; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (ptMousePos.y > m_ptDrawPos.y) { - for (i = 0; i < m_numChoices; i++) { - if ((ptMousePos.y >= m_ptDrawPos.y+m_ptDrawStrings[i].y) && (ptMousePos.y < m_ptDrawPos.y+m_ptDrawStrings[i].y+m_drawedStrings[i].Dimy())) { - SetSelected(i); + for (_ctx->i = 0; _ctx->i < m_numChoices; _ctx->i++) { + if ((ptMousePos.y >= m_ptDrawPos.y+m_ptDrawStrings[_ctx->i].y) && (ptMousePos.y < m_ptDrawPos.y+m_ptDrawStrings[_ctx->i].y+m_drawedStrings[_ctx->i].Dimy())) { + CORO_INVOKE_1(SetSelected, _ctx->i); break; } } - if (i == m_numChoices) - SetSelected(-1); + if (_ctx->i == m_numChoices) + CORO_INVOKE_1(SetSelected, -1); } + + CORO_END_CODE; } int RMDialogChoice::GetSelection(void) { diff --git a/engines/tony/font.h b/engines/tony/font.h index d883733db6..7c766e5d01 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -112,7 +112,7 @@ public: virtual void Close(void); // Funzione del task da overloadare - void Draw(RMGfxTargetBuffer &bigBug, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBug, RMGfxPrimitive *prim); // Crea una primitiva per una lettera RMGfxPrimitive *MakeLetterPrimitive(byte bChar, int& nLength); @@ -230,10 +230,10 @@ public: // Overloading della funzione ereditata da RMGfxTask per decidere // quando eliminare un oggetto dalla OTLIST - virtual bool RemoveThis(void); + virtual void RemoveThis(CORO_PARAM, bool &result); // Overloading del Draw per centrare la scritta, se necessario - virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Setta il colore di base void SetColor(byte r, byte g, byte b) { m_r=r; m_g=g; m_b=b; } @@ -275,7 +275,7 @@ class RMTextDialog : public RMText { virtual void Unregister(void); // Overloading del Draw per centrare la scritta, se necessario - virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Setta la posizione void SetPosition(RMPoint pt) { dst=pt; } @@ -310,7 +310,7 @@ public: RMTextDialogScrolling(RMLocation* loc); virtual ~RMTextDialogScrolling(); - virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -334,14 +334,14 @@ public: void SetMouseCoord(RMPoint m) { m_mpos=m; } void DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); - virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); RMPoint GetHotspot(); RMItem *GetSelectedItem(); bool IsItemSelected(); bool IsNormalItemSelected(); - virtual bool RemoveThis() { return true; } + virtual void RemoveThis(CORO_PARAM, bool &result) { result = true; } }; @@ -363,12 +363,12 @@ private: bool bRemoveFromOT; protected: - void Prepare(void); - void SetSelected(int pos); + void Prepare(CORO_PARAM); + void SetSelected(CORO_PARAM, int pos); public: - bool RemoveThis(void); - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); void Unregister(void); public: @@ -394,7 +394,7 @@ public: void Hide(CORO_PARAM); // Polling di aggiornamento - void DoFrame(RMPoint ptMousePos); + void DoFrame(CORO_PARAM, RMPoint ptMousePos); // Ritorna la voce attualmente selezionata, o -1 se nessuna č selezionata int GetSelection(void); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 820641e48f..e5e08f57e7 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -217,12 +217,19 @@ bool RMOptionButton::DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick -void RMOptionButton::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMOptionButton::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (!m_bActive) return; if (m_bHasGfx) - m_buf->Draw(bigBuf,prim); + CORO_INVOKE_2(m_buf->Draw, bigBuf, prim); + + CORO_END_CODE; } void RMOptionButton::AddToList(RMGfxTargetBuffer &bigBuf) { @@ -310,37 +317,43 @@ bool RMOptionSlide::DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick) return bRefresh; } -void RMOptionSlide::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - int i; - int val; +void RMOptionSlide::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + int i; + int val; + RMPoint pos; + CORO_END_CONTEXT(_ctx); - RMPoint pos; - pos = m_pos; - pos.x += 4; - pos.y += 4; + CORO_BEGIN_CODE(_ctx); + + _ctx->pos = m_pos; + _ctx->pos.x += 4; + _ctx->pos.y += 4; - val = m_nValue * m_nStep; - if (val < 1) val = 1; - else if (val > 100) val = 100; + _ctx->val = m_nValue * m_nStep; + if (_ctx->val < 1) _ctx->val = 1; + else if (_ctx->val > 100) _ctx->val = 100; - if (val == 1) { - prim->SetDst(pos); - m_SliderSingle->Draw(bigBuf, prim); + if (_ctx->val == 1) { + prim->SetDst(_ctx->pos); + CORO_INVOKE_2(m_SliderSingle->Draw, bigBuf, prim); } else { - prim->SetDst(pos); - m_SliderLeft->Draw(bigBuf, prim); - pos.x += 3; - - for (i = 1; i < val - 1; i++) { - prim->SetDst(pos); - m_SliderCenter->Draw(bigBuf, prim); - pos.x += 3; + prim->SetDst(_ctx->pos); + CORO_INVOKE_2(m_SliderLeft->Draw, bigBuf, prim); + _ctx->pos.x += 3; + + for (_ctx->i = 1; _ctx->i < _ctx->val - 1; _ctx->i++) { + prim->SetDst(_ctx->pos); + CORO_INVOKE_2(m_SliderCenter->Draw, bigBuf, prim); + _ctx->pos.x += 3; } - prim->SetDst(pos); - m_SliderRight->Draw(bigBuf, prim); - pos.x += 3; + prim->SetDst(_ctx->pos); + CORO_INVOKE_2(m_SliderRight->Draw, bigBuf, prim); + _ctx->pos.x += 3; } + + CORO_END_CODE; } void RMOptionSlide::AddToList(RMGfxTargetBuffer &bigBuf) { @@ -379,12 +392,49 @@ RMOptionScreen::RMOptionScreen(void) { } m_statePos = 0; + m_ButtonQuitYes = NULL; + m_ButtonQuitNo = NULL; + m_ButtonQuit = NULL; + m_SaveEasy = NULL; + m_SaveHard = NULL; + m_ButtonGfx_Tips = NULL; + m_ButtonSound_DubbingOn = NULL; + m_ButtonSound_MusicOn = NULL; + m_ButtonSound_SFXOn = NULL; + m_SlideTonySpeed = NULL; + m_SlideTextSpeed = NULL; + m_ButtonGame_Lock = NULL; + m_ButtonGfx_Anni30 = NULL; + m_SliderSound_Music = NULL; + m_ButtonGame_TimerizedText = NULL; + m_ButtonGfx_AntiAlias = NULL; + m_SliderSound_SFX = NULL; + m_ButtonGame_Scrolling = NULL; + m_ButtonGfx_Sottotitoli = NULL; + m_SliderSound_Dubbing = NULL; + m_ButtonGame_InterUp = NULL; + m_ButtonGfx_Trans = NULL; + + m_FadeStep = 0; + m_FadeY = 0; + m_FadeTime = 0; + m_nEditPos = 0; + m_nLastState = MENUGAME; } + RMOptionScreen::~RMOptionScreen(void) { } -void RMOptionScreen::RefreshAll(void) { +void RMOptionScreen::RefreshAll(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + RMGfxSourceBuffer16 *thumb; + RMText* title; + RMText *num[6]; + int i; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); ClearOT(); AddPrim(new RMGfxPrimitive(m_menu)); @@ -428,22 +478,21 @@ void RMOptionScreen::RefreshAll(void) { m_ButtonSound_SFXOn->AddToList(*this); } - RMGfxSourceBuffer16 *thumb = NULL; - RMText* title = NULL; - RMText* num[6] = { NULL, NULL, NULL, NULL, NULL, NULL }; - int i; + _ctx->thumb = NULL; + _ctx->title = NULL; + Common::fill(&_ctx->num[0], &_ctx->num[6], (RMText *)NULL); if (m_nState == MENULOAD || m_nState == MENUSAVE) { - title = new RMText; + _ctx->title = new RMText; if (m_nState == MENULOAD) { RMMessage msg(10); - title->WriteText(msg[0], 1); + _ctx->title->WriteText(msg[0], 1); } else { RMMessage msg(11); - title->WriteText(msg[0], 1); + _ctx->title->WriteText(msg[0], 1); } - AddPrim(new RMGfxPrimitive(title, RMPoint(320, 10))); + AddPrim(new RMGfxPrimitive(_ctx->title, RMPoint(320, 10))); if (m_curThumbDiff[0] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(48, 57))); else if (m_curThumbDiff[0] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(48, 57))); @@ -466,56 +515,62 @@ void RMOptionScreen::RefreshAll(void) { if (m_curThumb[5] && !(m_bEditSaveName && m_nEditPos == 5)) AddPrim(new RMGfxPrimitive(m_curThumb[5], RMPoint(432, 239))); if (m_bEditSaveName) { - thumb = new RMGfxSourceBuffer16; - thumb->Init((byte *)_vm->GetThumbnail(), 640 / 4, 480 / 4); - - switch (m_nEditPos) { - case 0: AddPrim(new RMGfxPrimitive(thumb,RMPoint(48, 57))); break; - case 1: AddPrim(new RMGfxPrimitive(thumb,RMPoint(240, 57))); break; - case 2: AddPrim(new RMGfxPrimitive(thumb,RMPoint(432, 57))); break; - case 3: AddPrim(new RMGfxPrimitive(thumb,RMPoint(48, 239))); break; - case 4: AddPrim(new RMGfxPrimitive(thumb,RMPoint(240, 239))); break; - case 5: AddPrim(new RMGfxPrimitive(thumb,RMPoint(432, 239))); break; - } + _ctx->thumb = new RMGfxSourceBuffer16; + _ctx->thumb->Init((byte *)_vm->GetThumbnail(), 640 / 4, 480 / 4); + + if (m_nEditPos == 0) + AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(48, 57))); + else if (m_nEditPos == 1) + AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(240, 57))); + else if (m_nEditPos == 2) + AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(432, 57))); + else if (m_nEditPos == 3) + AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(48, 239))); + else if (m_nEditPos == 4) + AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(240, 239))); + else if (m_nEditPos == 5) + AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(432, 239))); } - for (i = 0; i < 6; i++) { + for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) { RMString s; - if (m_bEditSaveName && m_nEditPos == i) - s.Format("%02d)%s*", m_statePos + i, m_EditName); + if (m_bEditSaveName && m_nEditPos == _ctx->i) + s.Format("%02d)%s*", m_statePos + _ctx->i, m_EditName); else { - if (m_statePos == 0 && i == 0) + if (m_statePos == 0 && _ctx->i == 0) s.Format("Autosave"); else - s.Format("%02d)%s", m_statePos + i, (const char *)m_curThumbName[i]); + s.Format("%02d)%s", m_statePos + _ctx->i, (const char *)m_curThumbName[_ctx->i]); } - num[i] = new RMText; - num[i]->SetAlignType(RMText::HLEFT, RMText::VTOP); - num[i]->WriteText(s, 2); + _ctx->num[_ctx->i] = new RMText; + _ctx->num[_ctx->i]->SetAlignType(RMText::HLEFT, RMText::VTOP); + _ctx->num[_ctx->i]->WriteText(s, 2); } - AddPrim(new RMGfxPrimitive(num[0], RMPoint(55 - 3, 180 + 14))); - AddPrim(new RMGfxPrimitive(num[1], RMPoint(247 - 3, 180 + 14))); - AddPrim(new RMGfxPrimitive(num[2],RMPoint(439 - 3, 180 + 14))); - AddPrim(new RMGfxPrimitive(num[3],RMPoint(55 - 3, 362 + 14))); - AddPrim(new RMGfxPrimitive(num[4],RMPoint(247 - 3, 362 + 14))); - AddPrim(new RMGfxPrimitive(num[5],RMPoint(439 - 3, 362 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[0], RMPoint(55 - 3, 180 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[1], RMPoint(247 - 3, 180 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[2],RMPoint(439 - 3, 180 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[3],RMPoint(55 - 3, 362 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[4],RMPoint(247 - 3, 362 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[5],RMPoint(439 - 3, 362 + 14))); m_ButtonSave_ArrowLeft->AddToList(*this); m_ButtonSave_ArrowRight->AddToList(*this); } - DrawOT(); + CORO_INVOKE_0(DrawOT); if (m_nState == MENULOAD || m_nState == MENUSAVE) { - if (thumb) delete thumb; - if (title) delete title; + if (_ctx->thumb) delete _ctx->thumb; + if (_ctx->title) delete _ctx->title; - for (i = 0; i < 6; i++) - if (num[i]) delete num[i]; + for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) + if (_ctx->num[_ctx->i]) delete _ctx->num[_ctx->i]; } + + CORO_END_CODE; } void RMOptionScreen::RefreshThumbnails(void) { @@ -537,25 +592,29 @@ void RMOptionScreen::RefreshThumbnails(void) { } -void RMOptionScreen::InitState(void) { - RMResRaw *raw; +void RMOptionScreen::InitState(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + RMResRaw *raw; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) - raw = new RMResRaw(20000 + m_nState); + _ctx->raw = new RMResRaw(20000 + m_nState); else if (m_nState == MENULOAD || m_nState == MENUSAVE) { if (m_bAlterGfx) - raw = new RMResRaw(20024); + _ctx->raw = new RMResRaw(20024); else - raw = new RMResRaw(20003); + _ctx->raw = new RMResRaw(20003); } else { error("Invalid state"); } - assert(raw->IsValid()); + assert(_ctx->raw->IsValid()); assert(m_menu == NULL); m_menu = new RMGfxSourceBuffer16(false); - m_menu->Init(*raw, raw->Width(), raw->Height()); - delete raw; + m_menu->Init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + delete _ctx->raw; if (m_nState == MENULOAD || m_nState == MENUSAVE) { if (m_bAlterGfx) { @@ -566,8 +625,8 @@ void RMOptionScreen::InitState(void) { m_ButtonExit = new RMOptionButton(20012, RMPoint(560, 404)); } - INIT_GFX8_FROMRAW(20036, m_SaveEasy); - INIT_GFX8_FROMRAW(20037, m_SaveHard); + INIT_GFX8_FROMRAW(_ctx->raw, 20036, m_SaveEasy); + INIT_GFX8_FROMRAW(_ctx->raw, 20037, m_SaveHard); RefreshThumbnails(); @@ -612,12 +671,12 @@ void RMOptionScreen::InitState(void) { assert(m_ButtonSoundMenu == NULL); m_ButtonSoundMenu = new RMOptionButton(RMRect(212, 32, 306, 64)); - raw = new RMResRaw(20021); - assert(raw->IsValid()); + _ctx->raw = new RMResRaw(20021); + assert(_ctx->raw->IsValid()); assert(m_QuitConfirm == NULL); m_QuitConfirm = new RMGfxSourceBuffer16(false); - m_QuitConfirm->Init(*raw, raw->Width(), raw->Height()); - delete raw; + m_QuitConfirm->Init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + delete _ctx->raw; assert(m_ButtonQuitYes == NULL); m_ButtonQuitYes = new RMOptionButton(20022, RMPoint(281, 265)); @@ -627,12 +686,12 @@ void RMOptionScreen::InitState(void) { m_ButtonQuitNo->SetPriority(30); if (m_bNoLoadSave) { - raw = new RMResRaw(20028); - assert(raw->IsValid()); + _ctx->raw = new RMResRaw(20028); + assert(_ctx->raw->IsValid()); assert(m_HideLoadSave == NULL); m_HideLoadSave = new RMGfxSourceBuffer16(false); - m_HideLoadSave->Init(*raw, raw->Width(), raw->Height()); - delete raw; + m_HideLoadSave->Init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + delete _ctx->raw; } // Menu GAME @@ -693,7 +752,9 @@ void RMOptionScreen::InitState(void) { } } - RefreshAll(); + CORO_INVOKE_0(RefreshAll); + + CORO_END_CODE; } void RMOptionScreen::CloseState(void) { @@ -828,9 +889,16 @@ void RMOptionScreen::ReInit(RMGfxTargetBuffer &bigBuf) { bigBuf.AddPrim(new RMGfxPrimitive(this)); } -bool RMOptionScreen::Init(RMGfxTargetBuffer &bigBuf) { - if (m_FadeStep != 0) - return false; +void RMOptionScreen::Init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + if (m_FadeStep != 0) { + result = false; + return; + } m_FadeStep = 1; m_FadeY = -20; @@ -844,14 +912,24 @@ bool RMOptionScreen::Init(RMGfxTargetBuffer &bigBuf) { if (m_nState == MENULOAD || m_nState == MENUSAVE) m_nState = MENUGAME; - InitState(); + + CORO_INVOKE_0(InitState); - return true; + result = true; + + CORO_END_CODE; } -bool RMOptionScreen::InitLoadMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternateGfx) { - if (m_FadeStep != 0) - return false; +void RMOptionScreen::InitLoadMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + if (m_FadeStep != 0) { + result = false; + return; + } m_FadeStep = 1; m_FadeY = -20; @@ -864,14 +942,23 @@ bool RMOptionScreen::InitLoadMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternate bigBuf.AddPrim(new RMGfxPrimitive(this)); m_nState = MENULOAD; - InitState(); + CORO_INVOKE_0(InitState); - return true; + result = true; + + CORO_END_CODE; } -bool RMOptionScreen::InitSaveMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternateGfx) { - if (m_FadeStep != 0) - return false; +void RMOptionScreen::InitSaveMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + if (m_FadeStep != 0) { + result = false; + return; + } m_FadeStep = 1; m_FadeY = -20; @@ -884,14 +971,23 @@ bool RMOptionScreen::InitSaveMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternate bigBuf.AddPrim(new RMGfxPrimitive(this)); m_nState = MENUSAVE; - InitState(); + CORO_INVOKE_0(InitState); - return true; + result = true; + + CORO_END_CODE; } -bool RMOptionScreen::InitNoLoadSave(RMGfxTargetBuffer &bigBuf) { - if (m_FadeStep != 0) - return false; +void RMOptionScreen::InitNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + if (m_FadeStep != 0) { + result = false; + return; + } m_FadeStep = 1; m_FadeY = -20; @@ -903,9 +999,11 @@ bool RMOptionScreen::InitNoLoadSave(RMGfxTargetBuffer &bigBuf) { bigBuf.AddPrim(new RMGfxPrimitive(this)); m_nState = MENUGAME; - InitState(); + CORO_INVOKE_0(InitState); - return true; + result = true; + + CORO_END_CODE; } bool RMOptionScreen::Close(void) { @@ -927,11 +1025,18 @@ int RMOptionScreen::Priority() { return 190; } -void RMOptionScreen::ChangeState(STATE newState) { +void RMOptionScreen::ChangeState(CORO_PARAM, STATE newState) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + CloseState(); m_nLastState = m_nState; m_nState = newState; - InitState(); + CORO_INVOKE_0(InitState); + + CORO_END_CODE; } void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { @@ -1015,7 +1120,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } } -#define KEYPRESS(c) ((GetAsyncKeyState(c)&0x8001)==0x8001) +#define KEYPRESS(c) (_vm->GetEngine()->GetInput().GetAsyncKeyState(c)) #define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ m_EditName[strlen(m_EditName) +1 ] = '\0'; m_EditName[strlen(m_EditName)] = c; _ctx->bRefresh = true; } @@ -1029,8 +1134,8 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } for (_ctx->i=0;_ctx->i<26 && strlen(m_EditName)<12;_ctx->i++) - if ((GetAsyncKeyState(Common::KEYCODE_LSHIFT) & 0x8000) || - (GetAsyncKeyState(Common::KEYCODE_RSHIFT) & 0x8000)) { + if (KEYPRESS(Common::KEYCODE_LSHIFT) || + KEYPRESS(Common::KEYCODE_RSHIFT)) { PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'A'); } else { PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'a'); @@ -1073,7 +1178,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { // Se č solo il menu di loading, chiudiamo Close(); } else { - ChangeState(m_nLastState); + CORO_INVOKE_1(ChangeState, m_nLastState); _ctx->bRefresh = true; } } else if (m_ButtonSave_ArrowLeft->IsActive()) { @@ -1136,19 +1241,19 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } else if (m_ButtonExit->IsActive()) Close(); else if (m_ButtonLoad->IsActive()) { - ChangeState(MENULOAD); + CORO_INVOKE_1(ChangeState, MENULOAD); _ctx->bRefresh = true; } else if (m_ButtonSave->IsActive()) { - ChangeState(MENUSAVE); + CORO_INVOKE_1(ChangeState, MENUSAVE); _ctx->bRefresh = true; } else if (m_ButtonGameMenu->IsActive() && m_nState != MENUGAME) { - ChangeState(MENUGAME); + CORO_INVOKE_1(ChangeState, MENUGAME); _ctx->bRefresh = true; } else if (m_ButtonGfxMenu->IsActive() && m_nState != MENUGFX) { - ChangeState(MENUGFX); + CORO_INVOKE_1(ChangeState, MENUGFX); _ctx->bRefresh = true; } else if (m_ButtonSoundMenu->IsActive() && m_nState != MENUSOUND) { - ChangeState(MENUSOUND); + CORO_INVOKE_1(ChangeState, MENUSOUND); _ctx->bRefresh = true; } @@ -1178,24 +1283,29 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { Close(); if (_ctx->bRefresh) - RefreshAll(); + CORO_INVOKE_0(RefreshAll); CORO_END_CODE; } -void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - int curTime = _vm->GetTime(); +void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + int curTime; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->curTime = _vm->GetTime(); #define FADE_SPEED 20 -#define SYNC (curTime-m_FadeTime) / 25 +#define SYNC (_ctx->curTime-m_FadeTime) / 25 if (m_bExit) return; - switch (m_FadeStep) { + if (m_FadeStep == 1) { // Discesa veloce - case 1: if (m_FadeTime == -1) m_FadeY += FADE_SPEED; else @@ -1207,10 +1317,9 @@ void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // Setta la parte da disegnare per lo scrolling prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); - break; - - // Rimbalzo 1 - case 2: + + } else if (m_FadeStep == 2) { + // Rimbalzo 1 m_FadeY -= FADE_SPEED / 2 * SYNC; if (m_FadeY < 400) { m_FadeY = 400; @@ -1218,9 +1327,8 @@ void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); - break; - case 3: + } else if (m_FadeStep == 3) { m_FadeY -= FADE_SPEED / 4 * SYNC; if (m_FadeY < 380) { m_FadeY = 380; @@ -1228,10 +1336,9 @@ void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); - break; - // Rimbalzo 1 - 2 - case 4: + } else if (m_FadeStep == 4) { + // Rimbalzo 1 - 2 m_FadeY += FADE_SPEED / 3 * SYNC; if (m_FadeY > 420) { m_FadeY = 420; @@ -1239,9 +1346,8 @@ void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); - break; - case 5: + } else if (m_FadeStep == 5) { m_FadeY += FADE_SPEED / 2 * SYNC; if (m_FadeY > 480) { m_FadeY = 480; @@ -1250,29 +1356,25 @@ void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); - break; - // Menu ON - case 6: - break; + } else if (m_FadeStep == 6) { + // Menu ON - // Menu OFF - case 7: + } else if (m_FadeStep == 7) { + // Menu OFF _vm->ShowLocation(); m_FadeStep++; - break; - case 8: + } else if (m_FadeStep == 8) { m_FadeY -= FADE_SPEED * SYNC; if (m_FadeY < 0) { m_FadeY = 0; m_FadeStep++; } prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); - break; - // Ciao ciao! - case 9: + } else if (m_FadeStep == 9) { + // Ciao ciao! m_bExit = true; m_FadeStep = 0; @@ -1280,21 +1382,22 @@ void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CloseState(); return; - default: + } else { m_FadeStep = 0; - break; } - m_FadeTime = curTime; + m_FadeTime = _ctx->curTime; + + CORO_INVOKE_2(RMGfxWoodyBuffer::Draw, bigBuf, prim); - RMGfxWoodyBuffer::Draw(bigBuf,prim); + CORO_END_CODE; } -bool RMOptionScreen::RemoveThis() { +void RMOptionScreen::RemoveThis(CORO_PARAM, bool &result) { if (m_bExit) - return true; - - return false; + result = true; + else + result = false; } @@ -1434,30 +1537,36 @@ int RMPointer::Priority() { return 200; } -void RMPointer::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - int n; +void RMPointer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + int n; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); // Controlla il pointer - n = m_nCurPointer; - if (n == TA_COMBINE) n = TA_USE; + _ctx->n = m_nCurPointer; + if (_ctx->n == TA_COMBINE) _ctx->n = TA_USE; // Copia le coordinate di destinazione nella primitiva prim->SetDst(m_pos); if (m_pos.x >= 0 && m_pos.y >= 0 && m_pos.x < RM_SX && m_pos.y < RM_SY) { // Richiama il draw del puntatore - prim->Dst()-=m_hotspot[n]; + prim->Dst()-=m_hotspot[_ctx->n]; if (m_nCurSpecialPointer == 0) { - m_pointer[n]->Draw(bigBuf,prim); + CORO_INVOKE_2(m_pointer[_ctx->n]->Draw, bigBuf, prim); } else { if (m_nCurSpecialPointer == PTR_CUSTOM) - m_nCurCustomPointer->Draw(bigBuf, prim); + CORO_INVOKE_2(m_nCurCustomPointer->Draw, bigBuf, prim); else // Richiama il draw sul puntatore speciale - m_specialPointer[m_nCurSpecialPointer-1]->Draw(bigBuf, prim); + CORO_INVOKE_2(m_specialPointer[m_nCurSpecialPointer-1]->Draw, bigBuf, prim); } } + + CORO_END_CODE; } void RMPointer::DoFrame(RMGfxTargetBuffer *bigBuf) { @@ -1469,9 +1578,9 @@ void RMPointer::DoFrame(RMGfxTargetBuffer *bigBuf) { m_specialPointer[m_nCurSpecialPointer-1]->DoFrame(bigBuf,false); } -bool RMPointer::RemoveThis() { +void RMPointer::RemoveThis(CORO_PARAM, bool &result) { // Si leva sempre dalla lista di OT, per supportare la DisableInput - return true; + result = true; } int RMPointer::CurAction(void) { diff --git a/engines/tony/game.h b/engines/tony/game.h index 55fed71380..554279c13f 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -64,7 +64,7 @@ namespace Tony { (buf16)->Init(*raw,raw->Width(),raw->Height()); \ delete raw; -#define INIT_GFX8_FROMRAW(dwRes, buf8) \ +#define INIT_GFX8_FROMRAW(raw, dwRes, buf8) \ raw = new RMResRaw(dwRes); \ assert(raw->IsValid()); \ assert((buf8) == NULL); \ @@ -135,13 +135,13 @@ public: int Priority(); // Overloading draw method - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Sets the current co-ordinates void SetCoord(RMPoint pt) { m_pos = pt; } // Overloading of the method to see if rising from the list - bool RemoveThis(); + virtual void RemoveThis(CORO_PARAM, bool &result); // Sets a new action as current void SetAction(RMTonyAction action) { m_nCurPointer = action; } @@ -174,7 +174,7 @@ public: virtual ~RMOptionButton(); bool DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick); - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void AddToList(RMGfxTargetBuffer &bigBuf); bool IsActive() { return m_bActive; } void SetActiveState(bool bState) { m_bActive=bState; } @@ -199,7 +199,7 @@ public: virtual ~RMOptionSlide(); bool DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick); - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void AddToList(RMGfxTargetBuffer& bigBuf); int GetValue() { return m_nValue; } @@ -286,18 +286,18 @@ public: RMOptionScreen(); virtual ~RMOptionScreen(); - bool Init(RMGfxTargetBuffer& bigBuf); - bool InitLoadMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternateGfx = false); - bool InitSaveMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternateGfx = false); - bool InitNoLoadSave(RMGfxTargetBuffer &bigBuf); + void Init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result); + void InitLoadMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result); + void InitSaveMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result); + void InitNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result); void ReInit(RMGfxTargetBuffer &bigBuf); bool Close(); bool IsClosing(); // Metodi in overloading da RMGfxTask int Priority(); - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - bool RemoveThis(); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void RemoveThis(CORO_PARAM, bool &result); // Polling per l'option screen void DoFrame(CORO_PARAM, RMInput *m_input); @@ -305,12 +305,12 @@ public: protected: // Inizializza tutto per il nuovo stato - void InitState(void); + void InitState(CORO_PARAM); void CloseState(void); - void ChangeState(STATE newState); + void ChangeState(CORO_PARAM, STATE newState); // Ridisegna tutto il menu delle opzioni - void RefreshAll(void); + void RefreshAll(CORO_PARAM); void RefreshThumbnails(void); // Carica lo screenshot per il salvataggio diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 344542b801..6f24941545 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -63,8 +63,8 @@ int RMGfxTask::Priority() { return m_nPrior; } -bool RMGfxTask::RemoveThis() { - return true; +void RMGfxTask::RemoveThis(CORO_PARAM, bool &result) { + result = true; } @@ -261,12 +261,19 @@ RMGfxWoodyBuffer::~RMGfxWoodyBuffer() { } -void RMGfxWoodyBuffer::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxWoodyBuffer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + // Prima si fa disegnare tramite la propria OT list - DrawOT(); + CORO_INVOKE_0(DrawOT); // Poi disegna se stesso nel target buffer - RMGfxSourceBuffer16::Draw(bigBuf, prim); + CORO_INVOKE_2(RMGfxSourceBuffer16::Draw, bigBuf, prim); + + CORO_END_CODE; } RMGfxWoodyBuffer::RMGfxWoodyBuffer() { @@ -316,47 +323,53 @@ void RMGfxTargetBuffer::ClearOT(void) { g_system->unlockMutex(csModifyingOT); } -void RMGfxTargetBuffer::DrawOT(void) { - OTList *cur; - OTList *prev; - OTList *next; - RMGfxPrimitive *myprim; +void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + OTList *cur; + OTList *prev; + OTList *next; + RMGfxPrimitive *myprim; + bool result; + CORO_END_CONTEXT(_ctx); - prev = NULL; - cur = otlist; + CORO_BEGIN_CODE(_ctx); + + _ctx->prev = NULL; + _ctx->cur = otlist; // Lock del buffer per accederci Lock(); g_system->lockMutex(csModifyingOT); - while (cur != NULL) { + while (_ctx->cur != NULL) { // Richiama la draw sul task, passandogli una copia della primitiva - myprim=cur->prim->Duplicate(); - cur->prim->m_task->Draw(*this, myprim); - delete myprim; + _ctx->myprim=_ctx->cur->prim->Duplicate(); + CORO_INVOKE_2(_ctx->cur->prim->m_task->Draw, *this, _ctx->myprim); + delete _ctx->myprim; // Controlla se e' arrivato il momento di rimuovere il task dalla OTlist - if (cur->prim->m_task->RemoveThis()) { + CORO_INVOKE_1(_ctx->cur->prim->m_task->RemoveThis, _ctx->result); + if (_ctx->result) { // Deregistra il task - cur->prim->m_task->Unregister(); + _ctx->cur->prim->m_task->Unregister(); // Cancella il task liberando la memoria - delete cur->prim; - next=cur->next; - delete cur; + delete _ctx->cur->prim; + _ctx->next = _ctx->cur->next; + delete _ctx->cur; // Se era il primo elemento, aggiorna la testa della lista - if (prev == NULL) - otlist = next; + if (_ctx->prev == NULL) + otlist = _ctx->next; // Altrimenti aggiorna il puntatore al successivo dell'elemento precedente else - prev->next = next; + _ctx->prev->next = _ctx->next; - cur = next; + _ctx->cur = _ctx->next; } else { // Aggiorna il puntatore al precedente e scorre la lista - prev = cur; - cur = cur->next; + _ctx->prev = _ctx->cur; + _ctx->cur = _ctx->cur->next; } } @@ -364,6 +377,8 @@ void RMGfxTargetBuffer::DrawOT(void) { // Unlock dopo la scrittura Unlock(); + + CORO_END_CODE; } void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { @@ -490,7 +505,7 @@ int RMGfxSourceBufferPal::LoadPaletteWA(uint32 resID, bool bSwapped) { * Metodi di RMGfxSourceBuffer4 \****************************************************************************/ -void RMGfxSourceBuffer4::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer4::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw) @@ -524,7 +539,7 @@ RMGfxSourceBuffer8::~RMGfxSourceBuffer8() { } -void RMGfxSourceBuffer8::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer8::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int x, y, width, height, u, v; int bufx = bigBuf.Dimx(); uint16 *buf = bigBuf; @@ -637,7 +652,7 @@ int RMGfxSourceBuffer8AB::CalcTrasp(int fore, int back) } -void RMGfxSourceBuffer8AB::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int x, y, width, height, u, v; int bufx=bigBuf.Dimx(); uint16 *buf = bigBuf; @@ -838,7 +853,7 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { Common::copy(MegaRLEBuf, MegaRLEBuf + x, m_buf); } -void RMGfxSourceBuffer8RLE::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int y; byte *src; uint16 *buf = bigBuf; @@ -1750,9 +1765,16 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri -void RMGfxSourceBuffer8AA::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - RMGfxSourceBuffer8::Draw(bigBuf, prim); +void RMGfxSourceBuffer8AA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_2(RMGfxSourceBuffer8::Draw, bigBuf, prim); DrawAA(bigBuf, prim); + + CORO_END_CODE; } @@ -1770,10 +1792,17 @@ void RMGfxSourceBuffer8RLEByteAA::PrepareImage(void) { CompressRLE(); } -void RMGfxSourceBuffer8RLEByteAA::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - RMGfxSourceBuffer8RLE::Draw(bigBuf,prim); +void RMGfxSourceBuffer8RLEByteAA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_2(RMGfxSourceBuffer8RLE::Draw, bigBuf, prim); if (bCfgAntiAlias) DrawAA(bigBuf,prim); + + CORO_END_CODE; } int RMGfxSourceBuffer8RLEByteAA::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { @@ -1801,10 +1830,17 @@ void RMGfxSourceBuffer8RLEWordAA::PrepareImage(void) { CompressRLE(); } -void RMGfxSourceBuffer8RLEWordAA::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - RMGfxSourceBuffer8RLE::Draw(bigBuf,prim); +void RMGfxSourceBuffer8RLEWordAA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_2(RMGfxSourceBuffer8RLE::Draw, bigBuf, prim); if (bCfgAntiAlias) DrawAA(bigBuf,prim); + + CORO_END_CODE; } int RMGfxSourceBuffer8RLEWordAA::Init(byte *buf, int dimx, int dimy, bool bLoadPalette) { @@ -1833,7 +1869,7 @@ RMGfxSourceBuffer16::RMGfxSourceBuffer16(bool bTrasp0) { RMGfxSourceBuffer16::~RMGfxSourceBuffer16() { } -void RMGfxSourceBuffer16::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer16::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int x, y; uint16 *buf = bigBuf; uint16 *raw = (uint16*)m_buf; @@ -1927,8 +1963,8 @@ void RMGfxSourceBuffer16::Create(int dimx, int dimy, bool bUseDDraw) { * Metodi di RMGfxBox \****************************************************************************/ -bool RMGfxBox::RemoveThis(void) { - return true; +void RMGfxBox::RemoveThis(CORO_PARAM, bool &result) { + result = true; } void RMGfxBox::SetColor(byte r, byte g, byte b) { @@ -1938,7 +1974,7 @@ void RMGfxBox::SetColor(byte r, byte g, byte b) { wFillColor = (r << 10) | (g << 5) | b; } -void RMGfxBox::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxBox::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int i, j; uint16 *buf = bigBuf; RMRect rcDst; @@ -1966,14 +2002,14 @@ int RMGfxClearTask::Priority() { return 1; } -void RMGfxClearTask::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *) { +void RMGfxClearTask::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *) { // Pulisce tutto il target buffer Common::fill((byte *)bigBuf, (byte *)bigBuf + (bigBuf.Dimx() * bigBuf.Dimy() * 2), 0x0); } -bool RMGfxClearTask::RemoveThis() { +void RMGfxClearTask::RemoveThis(CORO_PARAM, bool &result) { // Il task di clear si disattiva sempre - return true; + result = true; } } // End of namespace Tony diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 88f2d6ed22..289c3e9564 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -49,6 +49,7 @@ #define TONY_GFXCORE_H #include "common/system.h" +#include "common/coroutines.h" #include "tony/utils.h" namespace Tony { @@ -190,8 +191,8 @@ public: virtual ~RMGfxTask() { } virtual int Priority(); - virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) = 0; - virtual bool RemoveThis(); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) = 0; + virtual void RemoveThis(CORO_PARAM, bool &result); // Registration virtual void Register(void) { m_nInList++; } @@ -217,8 +218,8 @@ public: virtual ~RMGfxClearTask() { } int Priority(); - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); - bool RemoveThis(); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void RemoveThis(CORO_PARAM, bool &result); }; @@ -233,8 +234,8 @@ public: virtual ~RMGfxBox() { } void SetColor(byte r, byte g, byte b); - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - bool RemoveThis(); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void RemoveThis(CORO_PARAM, bool &result); }; @@ -277,7 +278,7 @@ public: void Create(int dimx, int dimy, bool bUseDDraw = false); int Bpp(); - virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -322,7 +323,7 @@ public: void Create(int dimx, int dimy, bool bUseDDraw = false); int Bpp(); - virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer& bigBuf, RMGfxPrimitive *prim); }; @@ -335,7 +336,7 @@ protected: public: virtual ~RMGfxSourceBuffer8AB(); - virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -376,7 +377,7 @@ public: virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); // Draw image with RLE decompression - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Sets the color that will be alpha blended void SetAlphaBlendColor(int color); @@ -443,7 +444,7 @@ public: virtual ~RMGfxSourceBuffer8AA(); // Draw con antialiasing - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -452,7 +453,7 @@ protected: void PrepareImage(void); public: - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded initialisation methods virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); @@ -466,7 +467,7 @@ protected: void PrepareImage(void); public: - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded initialisation method virtual void Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette = false); @@ -488,7 +489,7 @@ public: void Create(int dimx, int dimy, bool bUseDDraw = false); int Bpp(); - virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -520,7 +521,7 @@ public: // management of the OT list void ClearOT(void); - void DrawOT(void); + void DrawOT(CORO_PARAM); void AddPrim(RMGfxPrimitive *prim); // The pointer must be delted // Adds a task to clear the screen @@ -547,7 +548,7 @@ public: RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw = false); virtual ~RMGfxWoodyBuffer(); - virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; } // End of namespace Tony diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 88aac99ebe..b5278b3b05 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -108,15 +108,15 @@ void RMGfxEngine::OpenOptionScreen(CORO_PARAM, int type) { _ctx->bRes = false; if (type == 0) - _ctx->bRes = m_opt.Init(m_bigBuf); + CORO_INVOKE_2(m_opt.Init, m_bigBuf, _ctx->bRes); else if (type == 1) - _ctx->bRes = m_opt.InitLoadMenuOnly(m_bigBuf, true); + CORO_INVOKE_3(m_opt.InitLoadMenuOnly, m_bigBuf, true, _ctx->bRes); else if (type == 2) - _ctx->bRes = m_opt.InitNoLoadSave(m_bigBuf); + CORO_INVOKE_2(m_opt.InitNoLoadSave, m_bigBuf, _ctx->bRes); else if (type == 3) - _ctx->bRes = m_opt.InitLoadMenuOnly(m_bigBuf, false); + CORO_INVOKE_3(m_opt.InitLoadMenuOnly, m_bigBuf, false, _ctx->bRes); else if (type == 4) - _ctx->bRes = m_opt.InitSaveMenuOnly(m_bigBuf, false); + CORO_INVOKE_3(m_opt.InitSaveMenuOnly, m_bigBuf, false, _ctx->bRes); if (_ctx->bRes) { _vm->PauseSound(true); @@ -222,12 +222,14 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { if ((m_input.MouseLeftClicked() && m_input.MousePos().x < 3 && m_input.MousePos().y < 3)) { CORO_INVOKE_1(OpenOptionScreen, 0); goto SKIPCLICKSINISTRO; - } else if ((GetAsyncKeyState(Common::KEYCODE_ESCAPE)&0x8001) == 0x8001) + } else if (m_input.GetAsyncKeyState(Common::KEYCODE_ESCAPE)) CORO_INVOKE_1(OpenOptionScreen, 0); - else if (_vm->getIsDemo()) { - if ((GetAsyncKeyState(Common::KEYCODE_F3) & 0x8001) == 0x8001) + else if (!_vm->getIsDemo()) { + if (m_input.GetAsyncKeyState(Common::KEYCODE_F3) || m_input.GetAsyncKeyState(Common::KEYCODE_F5)) + // Save game screen CORO_INVOKE_1(OpenOptionScreen, 3); - else if ((GetAsyncKeyState(Common::KEYCODE_F2) & 0x8001) == 0x8001) + else if (m_input.GetAsyncKeyState(Common::KEYCODE_F2) || m_input.GetAsyncKeyState(Common::KEYCODE_F7)) + // Load game screen CORO_INVOKE_1(OpenOptionScreen, 4); } } @@ -324,7 +326,7 @@ SKIPCLICKSINISTRO: // ********************** // Disegna la lista di OT // ********************** - m_bigBuf.DrawOT(); + m_bigBuf.DrawOT(Common::nullContext); #define FSTEP (480/32) @@ -579,7 +581,7 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { RMGfxSourceBuffer16 *load = NULL; INIT_GFX16_FROMRAW(20038, load); m_bigBuf.AddPrim(new RMGfxPrimitive(load)); - m_bigBuf.DrawOT(); + m_bigBuf.DrawOT(Common::nullContext); m_bigBuf.ClearOT(); delete load; _vm->_window.GetNewFrame(*this, NULL); diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index d119bb07a6..41255229b8 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -129,6 +129,7 @@ public: void DisableMouse(void); operator byte *() { return (byte *)m_bigBuf; } + RMInput &GetInput() { return m_input; } // Link to the custom function list void InitCustomDll(void); diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 3574980176..bd90ec641d 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -52,12 +52,16 @@ namespace Tony { #define DIRELEASE(x) if (x) { (x)->Release(); (x)=NULL; } RMInput::RMInput() { + // Setup mouse fields _clampMouse = false; _mousePos.Set(0, 0); _leftButton = _rightButton = false;; _leftClickMouse = _leftReleaseMouse = false; _rightClickMouse = _rightReleaseMouse = false; + + // Setup keyboard fields + Common::fill(&_keyDown[0], &_keyDown[350], 0); } RMInput::~RMInput() { @@ -95,6 +99,14 @@ void RMInput::Poll(void) { // Since a mouse button has changed, don't do any further event processing this frame return; + case Common::EVENT_KEYDOWN: + _keyDown[(int)_event.kbd.keycode] = true; + return; + + case Common::EVENT_KEYUP: + _keyDown[(int)_event.kbd.keycode] = false; + return; + default: break; } diff --git a/engines/tony/input.h b/engines/tony/input.h index dce35141c5..acb7fbd677 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -56,14 +56,15 @@ namespace Tony { class RMInput { private: Common::Event _event; - RMPoint _mousePos; -// DIMOUSESTATE m_mState; + // Mouse related fields + RMPoint _mousePos; bool _clampMouse; bool _leftButton, _rightButton; - bool _leftClickMouse, _leftReleaseMouse, _rightClickMouse, _rightReleaseMouse; + // Keyboard related fields + bool _keyDown[350]; private: // Deinizializza DirectInput void DIClose(void); @@ -96,8 +97,8 @@ public: bool MouseRightReleased() { return _rightReleaseMouse; } bool MouseBothReleased() { return _leftReleaseMouse && _rightReleaseMouse; } - // Warns when we are in the GDI loop - void GDIControl(bool bCon); + // Returns true if the given key is pressed + bool GetAsyncKeyState(Common::KeyCode kc) { return _keyDown[(int)kc]; } }; } // End of namespace Tony diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 9d673459c5..b5c28506a9 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -181,7 +181,7 @@ void RMInventory::Init(void) { // Prepara il primo inventario Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); } @@ -205,50 +205,62 @@ void RMInventory::Reset(void) { EndCombine(); } -void RMInventory::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMInventory::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + RMPoint pos; + RMPoint pos2; + RMGfxPrimitive *p; + RMGfxPrimitive *p2; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (m_state == OPENING || m_state == CLOSING) prim->SetDst(RMPoint(0, m_curPutY)); else prim->SetDst(RMPoint(0, m_curPutY)); g_system->lockMutex(m_csModifyInterface); - RMGfxWoodyBuffer::Draw(bigBuf, prim); + CORO_INVOKE_2(RMGfxWoodyBuffer::Draw, bigBuf, prim); g_system->unlockMutex(m_csModifyInterface); if (m_state == SELECTING) { - RMPoint pos; - RMPoint pos2; if (!bCfgInvUp) { - pos.Set((m_nSelectObj+1)*64 - 20,RM_SY - 113); - pos2.Set((m_nSelectObj+1)*64 + 34,RM_SY - 150); + _ctx->pos.Set((m_nSelectObj+1)*64 - 20,RM_SY - 113); + _ctx->pos2.Set((m_nSelectObj+1)*64 + 34,RM_SY - 150); } else { - pos.Set((m_nSelectObj+1)*64 - 20, 72 - 4); // la parte marrone sta in alto :( - pos2.Set((m_nSelectObj+1)*64 + 34, 119 - 4); + _ctx->pos.Set((m_nSelectObj+1)*64 - 20, 72 - 4); // la parte marrone sta in alto :( + _ctx->pos2.Set((m_nSelectObj+1)*64 + 34, 119 - 4); } - RMGfxPrimitive p(prim->m_task, pos); - RMGfxPrimitive p2(prim->m_task, pos2); + _ctx->p = new RMGfxPrimitive(prim->m_task, _ctx->pos); + _ctx->p2 = new RMGfxPrimitive(prim->m_task, _ctx->pos2); // Disegna l'interfaccina stupida - miniInterface.Draw(bigBuf,&p); + CORO_INVOKE_2(miniInterface.Draw, bigBuf, _ctx->p); if (bCfgInterTips) { if (miniAction == 1) // Esamina - m_hints[0].Draw(bigBuf, &p2); + CORO_INVOKE_2(m_hints[0].Draw, bigBuf, _ctx->p2); else if (miniAction == 2) // Parla - m_hints[1].Draw(bigBuf, &p2); + CORO_INVOKE_2(m_hints[1].Draw, bigBuf, _ctx->p2); else if (miniAction == 3) // Usa - m_hints[2].Draw(bigBuf, &p2); + CORO_INVOKE_2(m_hints[2].Draw, bigBuf, _ctx->p2); } + + delete _ctx->p; + delete _ctx->p2; } + + CORO_END_CODE; } -bool RMInventory::RemoveThis(void) { +void RMInventory::RemoveThis(CORO_PARAM, bool &result) { if (m_state == CLOSED) - return true; - - return false; + result = true; + else + result = false; } void RMInventory::RemoveItem(int code) { @@ -263,7 +275,7 @@ void RMInventory::RemoveItem(int code) { m_nInv--; Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); g_system->unlockMutex(m_csModifyInterface); return; @@ -287,7 +299,7 @@ void RMInventory::AddItem(int code) { m_inv[m_nInv++]=code-10000; Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); g_system->unlockMutex(m_csModifyInterface); } @@ -302,7 +314,7 @@ void RMInventory::ChangeItemStatus(uint32 code, uint32 dwStatus) { m_items[code - 10000].status = dwStatus; Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); g_system->unlockMutex(m_csModifyInterface); } @@ -384,7 +396,7 @@ bool RMInventory::LeftClick(RMPoint mpos, int& nCombineObj) { } Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); g_system->unlockMutex(m_csModifyInterface); } @@ -405,7 +417,7 @@ bool RMInventory::LeftClick(RMPoint mpos, int& nCombineObj) { } Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); g_system->unlockMutex(m_csModifyInterface); } @@ -450,7 +462,7 @@ void RMInventory::RightClick(RMPoint mpos) { } Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); g_system->unlockMutex(m_csModifyInterface); } else if ((m_state == OPENED) && m_bBlinkingLeft) { @@ -470,7 +482,7 @@ void RMInventory::RightClick(RMPoint mpos) { } Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); g_system->unlockMutex(m_csModifyInterface); } @@ -550,7 +562,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo g_system->unlockMutex(m_csModifyInterface); } - if ((GetAsyncKeyState(Common::KEYCODE_i) & 0x8001) == 0x8001) { + if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_i)) { bCfgInvLocked = !bCfgInvLocked; } @@ -759,7 +771,7 @@ int RMInventory::LoadState(byte *state) { m_items[28].icon.SetPattern(1); Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); return GetSaveStateSize(); @@ -795,30 +807,35 @@ int RMInterface::OnWhichBox(RMPoint pt) { return -1; } -void RMInterface::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - int h; +void RMInterface::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + int h; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); prim->Dst().TopLeft() = m_openStart; - RMGfxSourceBuffer8RLEByte::Draw(bigBuf, prim); + CORO_INVOKE_2(RMGfxSourceBuffer8RLEByte::Draw, bigBuf, prim); // Controlla se c'e' da disegnare una zona calda - h = OnWhichBox(m_mpos); - if (h != -1) { + _ctx->h = OnWhichBox(m_mpos); + if (_ctx->h != -1) { prim->Dst().TopLeft() = m_openStart; - m_hotzone[h].Draw(bigBuf, prim); + CORO_INVOKE_2(m_hotzone[_ctx->h].Draw, bigBuf, prim); - if (m_lastHotZone != h) { - m_lastHotZone = h; + if (m_lastHotZone != _ctx->h) { + m_lastHotZone = _ctx->h; _vm->PlayUtilSFX(1); } if (bCfgInterTips) { prim->Dst().TopLeft() = m_openStart + RMPoint(70, 177); - m_hints[h].Draw(bigBuf,prim); + CORO_INVOKE_2(m_hints[_ctx->h].Draw, bigBuf, prim); } } else m_lastHotZone = -1; + CORO_END_CODE; } diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 3d8650773f..e2143bb24b 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -119,10 +119,10 @@ public: void Reset(void); // Overload per la rimozione da otlist - bool RemoveThis(void); + virtual void RemoveThis(CORO_PARAM, bool &result); // Overload per il disegno (per la posizione x&y e l'interfaccina) - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Metodo per determinare se l'inventario sta comandando gli input bool HaveFocus(RMPoint mpos); @@ -205,7 +205,7 @@ public: bool GetPalesati(void); // Overloading del Draw per il posizionamente - virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; } // End of namespace Tony diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index e4a60cb52a..37fe29f359 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -398,8 +398,8 @@ void RMSprite::ReadFromStream(RMDataStream &ds, bool bLOX) { m_buf->Init(ds, dimx,dimy); } -void RMSprite::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - m_buf->Draw(bigBuf, prim); +void RMSprite::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + m_buf->Draw(coroParam, bigBuf, prim); } void RMSprite::SetPalette(byte *buf) { @@ -727,7 +727,12 @@ RMPoint RMItem::CalculatePos(void) { return m_pos + m_patterns[m_nCurPattern].Pos(); } -void RMItem::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMItem::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + // Se CurSprite == -1, allora e' finito il pattern if (m_nCurSprite == -1) return; @@ -746,13 +751,15 @@ void RMItem::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->SetStrecth(false); // Ora la passiamo alla routine di drawing generica per surface - m_sprites[m_nCurSprite].Draw(bigBuf, prim); + CORO_INVOKE_2(m_sprites[m_nCurSprite].Draw, bigBuf, prim); + + CORO_END_CODE; } -bool RMItem::RemoveThis() { +void RMItem::RemoveThis(CORO_PARAM, bool &result) { // Rimuove dalla OT list se il frame corrente e' -1 (pattern finito) - return (m_nCurSprite == -1); + result = (m_nCurSprite == -1); } @@ -907,8 +914,8 @@ void RMWipe::Unregister(void) { CoroScheduler.setEvent(m_hUnregistered); } -bool RMWipe::RemoveThis(void) { - return m_bUnregister; +void RMWipe::RemoveThis(CORO_PARAM, bool &result) { + result = m_bUnregister; } void RMWipe::WaitForFadeEnd(CORO_PARAM) { @@ -972,13 +979,20 @@ void RMWipe::DoFrame(RMGfxTargetBuffer &bigBuf) { } } -void RMWipe::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMWipe::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (m_bFading) { - m_wip0r.Draw(bigBuf, prim); + CORO_INVOKE_2(m_wip0r.Draw, bigBuf, prim); } if (m_bEndFade) Common::fill((byte *)bigBuf, (byte *)bigBuf + bigBuf.Dimx() * bigBuf.Dimy() * 2, 0x0); + + CORO_END_CODE; } @@ -1369,12 +1383,19 @@ RMPoint RMCharacter::NearestHotSpot(int sourcebox, int destbox) { return puntocaldo; } -void RMCharacter::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMCharacter::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (bDrawNow) { prim->Dst() += m_fixedScroll; - RMItem::Draw(bigBuf, prim); + CORO_INVOKE_2(RMItem::Draw, bigBuf, prim); } + + CORO_END_CODE; } void RMCharacter::NewBoxEntered(int nBox) { @@ -1692,11 +1713,18 @@ void RMCharacter::WaitForEndMovement(CORO_PARAM) { CORO_END_CODE; } -bool RMCharacter::RemoveThis(void) { +void RMCharacter::RemoveThis(CORO_PARAM, bool &result) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (bRemoveFromOT) - return true; + result = true; + else + CORO_INVOKE_1(RMItem::RemoveThis, result); - return RMItem::RemoveThis(); + CORO_END_CODE; } RMCharacter::RMCharacter() { @@ -2214,7 +2242,12 @@ bool RMLocation::LoadLOX(RMDataStream &ds) { * \****************************************************************************/ -void RMLocation::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMLocation::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + // Setta la posizione sorgente dello scrolling if (m_buf->Dimy()>RM_SY || m_buf->Dimx()>RM_SX) { prim->SetSrc(RMRect(m_curScroll,m_curScroll+RMPoint(640,480))); @@ -2224,7 +2257,9 @@ void RMLocation::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // Richiama il metodo di drawing della classe dell'immagine, che disegnerą il background // della locazione - m_buf->Draw(bigBuf, prim); + CORO_INVOKE_2(m_buf->Draw, bigBuf, prim); + + CORO_END_CODE; } diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 218aca02e7..bbe37778c0 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -202,7 +202,7 @@ public: void Init(RMGfxSourceBuffer* buf); friend RMDataStream& operator>>(RMDataStream& ds, RMSprite& sprite); - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void SetPalette(byte *lpBuf); void GetSizeFromStream(RMDataStream& ds, int* dimx, int* dimy); void LOXGetSizeFromStream(RMDataStream& ds, int* dimx, int* dimy); @@ -265,10 +265,10 @@ public: void SetScrollPosition(RMPoint scroll); // Overloading della funzione per la rimozione da ot list - virtual bool RemoveThis(); + virtual void RemoveThis(CORO_PARAM, bool &result); // Overloading del draw - virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloading della prioritą: č la Z virtual int Priority() { return m_z; } @@ -457,13 +457,13 @@ public: void LinkToBoxes(RMGameBoxes* theBoxes); - virtual bool RemoveThis(void); + virtual void RemoveThis(CORO_PARAM, bool &result); // Aggiorna la posizione del personaggio void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc); // Overloading del Draw - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // TRUE se si č appena fermato bool EndOfPath() { return bEndOfPath; } @@ -505,14 +505,14 @@ public: virtual ~RMWipe(); void DoFrame(RMGfxTargetBuffer& bigBuf); - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void InitFade(int type); void CloseFade(void); void WaitForFadeEnd(CORO_PARAM); virtual void Unregister(void); - virtual bool RemoveThis(void); + virtual void RemoveThis(CORO_PARAM, bool &result); virtual int Priority(void); }; @@ -557,7 +557,7 @@ public: void Unload(void); // Overloading del Draw - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Prepara un frame disegnando la locazione e tutti i suoi item void DoFrame(RMGfxTargetBuffer *bigBuf); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 76f6cfcecb..f86576d5c2 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -216,12 +216,14 @@ void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, in m_stream[nextChannel]->Stop(); m_stream[nextChannel]->UnloadFile(); -#ifndef DEMO - if (!m_stream[nextChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync)) - theGame.Abort(); -#else - m_stream[nextChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync); -#endif + + if (!getIsDemo()) { + if (!m_stream[nextChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync)) + theGame.Abort(); + } else { + m_stream[nextChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync); + } + m_stream[nextChannel]->SetLoop(bLoop); m_stream[nextChannel]->Play(); @@ -229,12 +231,13 @@ void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, in } else { -#ifndef DEMO - if (!m_stream[nChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync)) - theGame.Abort(); -#else - m_stream[nChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync); -#endif + if (!getIsDemo()) { + if (!m_stream[nChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync)) + theGame.Abort(); + } else { + m_stream[nChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync); + } + m_stream[nChannel]->SetLoop(bLoop); m_stream[nChannel]->Play(); } diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 982949870c..0e59779229 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -187,7 +187,12 @@ void RMTony::Hide(bool bShowOmbra) { } -void RMTony::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMTony::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + // Richiama il Draw() della classe madre se tony č visibile if (m_bShow && bDrawNow) { if (m_bCorpoDavanti) { @@ -195,7 +200,7 @@ void RMTony::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->Dst().Offset(-44, -134); if (m_bPastorella) prim->Dst().Offset(1, 4); - RMCharacter::Draw(bigBuf, prim); + CORO_INVOKE_2(RMCharacter::Draw, bigBuf, prim); } if (m_bIsTalking || m_bIsStaticTalk) { @@ -205,7 +210,7 @@ void RMTony::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->Dst().Offset(m_pos); prim->Dst().Offset(-44, -134); prim->Dst() += m_nBodyOffset; - m_body.Draw(bigBuf, prim); + CORO_INVOKE_2(m_body.Draw, bigBuf, prim); } if (!m_bCorpoDavanti) { @@ -213,9 +218,11 @@ void RMTony::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->Dst().Offset(-44, -134); if (m_bPastorella) prim->Dst().Offset(0, 3); - RMCharacter::Draw(bigBuf, prim); + CORO_INVOKE_2(RMCharacter::Draw, bigBuf, prim); } } + + CORO_END_CODE; } void RMTony::MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm) { diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index bbb1667c9b..17b5be23dc 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -390,7 +390,7 @@ public: void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc); // Metodi di Draw, che controlla la variabile di show - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Mostra o nascondi void Show(void); -- cgit v1.2.3