aboutsummaryrefslogtreecommitdiff
path: root/engines/tony
diff options
context:
space:
mode:
Diffstat (limited to 'engines/tony')
-rw-r--r--engines/tony/custom.cpp4
-rw-r--r--engines/tony/gfxengine.cpp10
-rw-r--r--engines/tony/loc.cpp107
-rw-r--r--engines/tony/loc.h8
-rw-r--r--engines/tony/tonychar.cpp33
-rw-r--r--engines/tony/tonychar.h4
6 files changed, 109 insertions, 57 deletions
diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp
index 150e199fc8..c82d0fcd2b 100644
--- a/engines/tony/custom.cpp
+++ b/engines/tony/custom.cpp
@@ -1337,7 +1337,7 @@ DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint3
CORO_BEGIN_CODE(_ctx);
- Tony->Move(RMPoint(nX, nY));
+ CORO_INVOKE_1(Tony->Move, RMPoint(nX, nY));
if (!bSkipIdle)
CORO_INVOKE_0(Tony->WaitForEndMovement);
@@ -1346,7 +1346,7 @@ DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint3
}
DECLARE_CUSTOM_FUNCTION(MoveTony)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint32) {
- Tony->Move(RMPoint(nX, nY));
+ Tony->Move(coroParam, RMPoint(nX, nY));
}
DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 sX, uint32 sY) {
diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp
index 3952d0c227..5a9c0555e0 100644
--- a/engines/tony/gfxengine.cpp
+++ b/engines/tony/gfxengine.cpp
@@ -208,7 +208,7 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) {
// ***************
if (m_input.MouseRightReleased()) {
if (m_inv.RightRelease(m_input.MousePos(), m_curAction)) {
- m_tony.MoveAndDoAction(m_itemName.GetHotspot(),m_itemName.GetSelectedItem(),m_curAction);
+ CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction);
m_curAction = TA_GOTO;
m_point.SetAction(m_curAction);
@@ -240,9 +240,9 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) {
//if (m_itemName.IsItemSelected())
{
if (m_curAction != TA_COMBINE)
- m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_point.CurAction());
+ CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_point.CurAction());
else if (m_itemName.GetSelectedItem() != NULL)
- m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj);
+ CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj);
}
if (m_curAction == TA_COMBINE) {
@@ -283,7 +283,7 @@ SKIPCLICKSINISTRO:
if (m_bGUIInterface) {
if (m_inter.Released(m_input.MousePos(),m_curAction)) {
m_point.SetAction(m_curAction);
- m_tony.MoveAndDoAction(m_itemName.GetHotspot(),m_itemName.GetSelectedItem(), m_curAction);
+ CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction);
m_curAction = TA_GOTO;
m_point.SetAction(m_curAction);
@@ -304,7 +304,7 @@ SKIPCLICKSINISTRO:
}
// Anima Tony
- m_tony.DoFrame(&m_bigBuf, m_nCurLoc);
+ CORO_INVOKE_2(m_tony.DoFrame, &m_bigBuf, m_nCurLoc);
// Aggiorna lo scrolling per tenere Tony dentro lo schermo
if (m_tony.MustUpdateScrolling() && m_bLocationLoaded) {
diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp
index bba1ad2f23..080e06da87 100644
--- a/engines/tony/loc.cpp
+++ b/engines/tony/loc.cpp
@@ -1087,10 +1087,15 @@ short RMCharacter::FindPath(short source, short destination) {
}
-void RMCharacter::GoTo(RMPoint destcoord, bool bReversed) {
+void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) {
+ CORO_BEGIN_CONTEXT;
+ CORO_END_CONTEXT(_ctx);
+
+ CORO_BEGIN_CODE(_ctx);
+
if (m_pos == destcoord) {
if (minpath == 0) {
- Stop();
+ CORO_INVOKE_0(Stop);
g_scheduler->pulseEvent(hEndOfPath);
return;
}
@@ -1149,6 +1154,7 @@ void RMCharacter::GoTo(RMPoint destcoord, bool bReversed) {
olddy = dy;
// ResetEvent(hTonyEndMovement); @@@
+ CORO_END_CODE;
}
@@ -1413,10 +1419,15 @@ void RMCharacter::NewBoxEntered(int nBox) {
mpalQueryDoAction(2, curLocation, curbox);
}
-void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) {
- bool bEndNow;
+void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) {
+ CORO_BEGIN_CONTEXT;
+ bool bEndNow;
+ RMBoxLoc *cur;
+ CORO_END_CONTEXT(_ctx);
- bEndNow = false;
+ CORO_BEGIN_CODE(_ctx);
+
+ _ctx->bEndNow = false;
bEndOfPath = false;
bDrawNow = (curLocation == loc);
@@ -1435,7 +1446,7 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) {
if (((walkspeed > 0) && (m_pos.x > lineend.x)) || ((walkspeed < 0) && (m_pos.x < lineend.x))) {
m_pos = lineend;
status = STAND;
- bEndNow = true;
+ _ctx->bEndNow = true;
}
}
@@ -1450,7 +1461,7 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) {
if (((walkspeed > 0) && (m_pos.y > lineend.y)) || ((walkspeed < 0) && (m_pos.y < lineend.y))) {
m_pos = lineend;
status = STAND;
- bEndNow = true;
+ _ctx->bEndNow = true;
}
}
@@ -1463,9 +1474,9 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) {
// Se siamo appena arrivati alla destinazione temporanea ed è finito il percorso minimo,
// ci fermiamo definitivamente
- if (bEndNow && minpath == 0) {
+ if (_ctx->bEndNow && minpath == 0) {
if (!bEndOfPath)
- Stop();
+ CORO_INVOKE_0(Stop);
bEndOfPath = true;
g_scheduler->pulseEvent(hEndOfPath);
}
@@ -1487,15 +1498,15 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) {
if (status == STAND) {
// Controlliamo se c'è ancora percorso minimo da calcolare
if (minpath == 1) {
- RMBoxLoc *cur = theBoxes->GetBoxes(curLocation);
+ _ctx->cur = theBoxes->GetBoxes(curLocation);
// Se dobbiamo ancora attraversare un box
if (pathcount < pathlenght) {
// Controlliamo che il box su cui stiamo entrando sia attivo
- if (cur->boxes[path[pathcount-1]].attivo) {
+ if (_ctx->cur->boxes[path[pathcount-1]].attivo) {
// Muoviti in linea retta verso l'hotspot più vicino, tenendo conto del reversing please
// NEWBOX = path[pathcount-1]
- GoTo(NearestHotSpot(path[pathcount-1], path[pathcount]), cur->boxes[path[pathcount-1]].bReversed);
+ CORO_INVOKE_2(GoTo, NearestHotSpot(path[pathcount-1], path[pathcount]), _ctx->cur->boxes[path[pathcount-1]].bReversed);
pathcount++;
} else {
// Se il box è disattivato, possiamo solo bloccare tutto
@@ -1503,7 +1514,7 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) {
// la ricerca del percorso minimo
minpath = 0;
if (!bEndOfPath)
- Stop();
+ CORO_INVOKE_0(Stop);
bEndOfPath = true;
g_scheduler->pulseEvent(hEndOfPath);
}
@@ -1512,7 +1523,7 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) {
// punto di arrivo
// NEWBOX = InWhichBox(pathend)
minpath = 0;
- GoTo(pathend, cur->boxes[InWhichBox(pathend)].bReversed);
+ CORO_INVOKE_2(GoTo, pathend, _ctx->cur->boxes[InWhichBox(pathend)].bReversed);
}
}
}
@@ -1521,9 +1532,16 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) {
// Richiama il DoFrame dell'item
RMItem::DoFrame(bigBuf);
+
+ CORO_END_CODE;
}
-void RMCharacter::Stop(void) {
+void RMCharacter::Stop(CORO_PARAM) {
+ CORO_BEGIN_CONTEXT;
+ CORO_END_CONTEXT(_ctx);
+
+ CORO_BEGIN_CODE(_ctx);
+
bMoving = false;
// Non si sa mai...
@@ -1558,6 +1576,8 @@ void RMCharacter::Stop(void) {
SetPattern(PAT_STANDDOWN);
break;
}
+
+ CORO_END_CODE;
}
inline int RMCharacter::InWhichBox(RMPoint pt) {
@@ -1565,9 +1585,14 @@ inline int RMCharacter::InWhichBox(RMPoint pt) {
}
-bool RMCharacter::Move(RMPoint pt) {
- RMPoint dest;
- int numbox;
+void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) {
+ CORO_BEGIN_CONTEXT;
+ RMPoint dest;
+ int numbox;
+ RMBoxLoc *cur;
+ CORO_END_CONTEXT(_ctx);
+
+ CORO_BEGIN_CODE(_ctx);
bMoving = true;
@@ -1575,31 +1600,33 @@ bool RMCharacter::Move(RMPoint pt) {
if (pt.x == 0 && pt.y == 0) {
minpath = 0;
status = STAND;
- Stop();
- return true;
+ CORO_INVOKE_0(Stop);
+ if (result)
+ *result = true;
+ return;
}
// Se clicko fuori dai box
- numbox = InWhichBox(pt);
- if (numbox == -1) {
+ _ctx->numbox = InWhichBox(pt);
+ if (_ctx->numbox == -1) {
// Trova il punto più vicino dentro i box
- dest = NearestPoint(pt);
+ _ctx->dest = NearestPoint(pt);
// ???!??
- if (dest == pt)
- dest = InvScanLine(pt);
+ if (_ctx->dest == pt)
+ _ctx->dest = InvScanLine(pt);
- pt = dest;
- numbox = InWhichBox(pt);
+ pt = _ctx->dest;
+ _ctx->numbox = InWhichBox(pt);
}
- RMBoxLoc *cur = theBoxes->GetBoxes(curLocation);
+ _ctx->cur = theBoxes->GetBoxes(curLocation);
minpath = 0;
status = STAND;
bMovingWithoutMinpath = true;
if (ScanLine(pt))
- GoTo(pt, cur->boxes[numbox].bReversed);
+ CORO_INVOKE_2(GoTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed);
else if (FindPath(InWhichBox(m_pos), InWhichBox(pt))) {
bMovingWithoutMinpath = false;
minpath = 1;
@@ -1609,22 +1636,30 @@ bool RMCharacter::Move(RMPoint pt) {
// @@@ Questo caso è se un hotspot è dentro un box
// ma non c'è un path per arrivarci. Usiamo quindi
// la invscanline per cercare un punto intorno
- dest = InvScanLine(pt);
- pt = dest;
+ _ctx->dest = InvScanLine(pt);
+ pt = _ctx->dest;
if (ScanLine(pt))
- GoTo(pt,cur->boxes[numbox].bReversed);
+ CORO_INVOKE_2(GoTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed);
else if (FindPath(InWhichBox(m_pos), InWhichBox(pt))) {
bMovingWithoutMinpath = false;
minpath = 1;
pathcount = 1;
pathend = pt;
- return true;
- } else
- return false;
+ if (result)
+ *result = true;
+ } else {
+ if (result)
+ *result = false;
+ }
+
+ return;
}
- return true;
+ if (result)
+ *result = true;
+
+ CORO_END_CODE;
}
void RMCharacter::SetPosition(RMPoint pt, int newloc) {
diff --git a/engines/tony/loc.h b/engines/tony/loc.h
index 744dab3c25..f5826022e0 100644
--- a/engines/tony/loc.h
+++ b/engines/tony/loc.h
@@ -439,7 +439,7 @@ private:
RMPoint Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoint punto);
RMPoint NearestPoint(RMPoint punto);
- void GoTo(RMPoint destcoord, bool bReversed=false);
+ void GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed=false);
short ScanLine(RMPoint punto);
RMPoint InvScanLine(RMPoint punto);
RMPoint NearestHotSpot(int sourcebox, int destbox);
@@ -461,7 +461,7 @@ public:
virtual bool RemoveThis(void);
// Aggiorna la posizione del personaggio
- void DoFrame(RMGfxTargetBuffer* bigBuf, int loc);
+ void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc);
// Overloading del Draw
void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim);
@@ -470,13 +470,13 @@ public:
bool EndOfPath() { return bEndOfPath; }
// Cambia il pattern del personaggio per fermarlo
- virtual void Stop(void);
+ virtual void Stop(CORO_PARAM);
// Controlla se il personaggio si sta muovendo
bool IsMoving() { return bMoving; }
// Muove il personaggio a una certa posizione
- bool Move(RMPoint pt);
+ void Move(CORO_PARAM, RMPoint pt, bool *result = NULL);
// Posiziona il personaggio a una certa posizione SENZA farlo muovere
void SetPosition(RMPoint pt, int newloc=-1);
diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp
index 06adcd15b8..c3deae497b 100644
--- a/engines/tony/tonychar.cpp
+++ b/engines/tony/tonychar.cpp
@@ -125,20 +125,26 @@ void RMTony::Close(void) {
m_ombra.Destroy();
}
-void RMTony::DoFrame(RMGfxTargetBuffer *bigBuf, int curLoc) {
+void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) {
+ CORO_BEGIN_CONTEXT;
+ int time;
+ CORO_END_CONTEXT(_ctx);
+
+ CORO_BEGIN_CODE(_ctx);
+
if (!m_nInList && m_bShow)
bigBuf->AddPrim(new RMGfxPrimitive(this));
SetSpeed(nCfgTonySpeed);
// Esegue il movimento normale del personaggio
- int time = _vm->GetTime();
+ _ctx->time = _vm->GetTime();
do {
m_nTimeLastStep += (1000 / 40);
- RMCharacter::DoFrame(bigBuf, curLoc);
+ CORO_INVOKE_2(RMCharacter::DoFrame, bigBuf, curLoc);
- } while (time > m_nTimeLastStep + (1000 / 40));
+ } while (_ctx->time > m_nTimeLastStep + (1000 / 40));
// Controlla se siamo alla fine del percorso
if (EndOfPath() && m_bActionPending) {
@@ -148,6 +154,8 @@ void RMTony::DoFrame(RMGfxTargetBuffer *bigBuf, int curLoc) {
if (m_bIsTalking || m_bIsStaticTalk)
m_body.DoFrame(bigBuf, false);
+
+ CORO_END_CODE;
}
void RMTony::Show(void) {
@@ -192,7 +200,13 @@ void RMTony::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) {
}
}
-void RMTony::MoveAndDoAction(RMPoint dst, RMItem *item, int nAction, int nActionParm) {
+void RMTony::MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm) {
+ CORO_BEGIN_CONTEXT;
+ bool result;
+ CORO_END_CONTEXT(_ctx);
+
+ CORO_BEGIN_CODE(_ctx);
+
// Fa il movimento normale, ma si ricorda se deve poi eseguire un azione
if (item == NULL) {
m_bActionPending = false;
@@ -204,10 +218,13 @@ void RMTony::MoveAndDoAction(RMPoint dst, RMItem *item, int nAction, int nAction
m_bActionPending = true;
}
- if (!RMCharacter::Move(dst)) {
+ CORO_INVOKE_2(RMCharacter::Move, dst, &_ctx->result);
+ if (!_ctx->result) {
m_bActionPending = false;
m_ActionItem = NULL;
}
+
+ CORO_END_CODE;
}
@@ -290,14 +307,14 @@ void RMTony::Stop(CORO_PARAM) {
_ctx->pid = mpalQueryDoAction(21, m_ActionItem->MpalCode(), 0);
if (_ctx->pid == INVALID_PID_VALUE)
- RMCharacter::Stop();
+ CORO_INVOKE_0(RMCharacter::Stop);
else {
bNeedToStop = false; // Se facciamo la OnWhichDirection, almeno dopo non dobbiamo fare la Stop()
bMoving = false;
CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->pid, INFINITE); // @@@ Mettere un assert dopo 10 secondi
}
} else {
- RMCharacter::Stop();
+ CORO_INVOKE_0(RMCharacter::Stop);
}
if (!m_bActionPending)
diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h
index 98f247f688..050b39c0ca 100644
--- a/engines/tony/tonychar.h
+++ b/engines/tony/tonychar.h
@@ -385,7 +385,7 @@ public:
void Close(void);
// Fa un frame di Tony, aggiornando il movimento, etc
- void DoFrame(RMGfxTargetBuffer *bigBuf, int curLoc);
+ void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc);
// Metodi di Draw, che controlla la variabile di show
void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim);
@@ -395,7 +395,7 @@ public:
void Hide(bool bShowOmbra = false);
// Si muove e fa un azione, se necessario
- void MoveAndDoAction(RMPoint dst, RMItem *item, int nAction, int nActionParm = 0);
+ void MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm = 0);
// Ferma Tony (dalla parte giusta rispetto a un eventuale oggetto)
virtual void Stop(CORO_PARAM);