From 4719fd99007df8b4e20b93484a2229e32aed6261 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 09:22:14 +1000 Subject: COMMON: Fix comparison operation on coroutine wait methods --- common/coroutines.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/coroutines.cpp b/common/coroutines.cpp index d511ab4b35..4a45f2ec23 100644 --- a/common/coroutines.cpp +++ b/common/coroutines.cpp @@ -386,7 +386,7 @@ void CoroutineScheduler::waitForSingleObject(CORO_PARAM, int pid, uint32 duratio *expired = true; // Outer loop for doing checks until expiry - while (g_system->getMillis() < _ctx->endTime) { + while (g_system->getMillis() <= _ctx->endTime) { // Check to see if a process or event with the given Id exists _ctx->pProcess = getProcess(pid); _ctx->pEvent = !_ctx->pProcess ? getEvent(pid) : NULL; @@ -456,7 +456,7 @@ void CoroutineScheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 * *expired = true; // Outer loop for doing checks until expiry - while (g_system->getMillis() < _ctx->endTime) { + while (g_system->getMillis() <= _ctx->endTime) { _ctx->signalled = bWaitAll; for (_ctx->i = 0; _ctx->i < nCount; ++_ctx->i) { -- cgit v1.2.3 From 839527a9553e94234a1eb802648a4ed64e926a5c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 25 May 2012 23:13:55 +1000 Subject: COMMON: Fix method error messages --- common/coroutines.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/coroutines.cpp b/common/coroutines.cpp index 4a45f2ec23..aff13a5494 100644 --- a/common/coroutines.cpp +++ b/common/coroutines.cpp @@ -433,7 +433,7 @@ void CoroutineScheduler::waitForSingleObject(CORO_PARAM, int pid, uint32 duratio void CoroutineScheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, bool bWaitAll, uint32 duration, bool *expired) { if (!pCurrent) - error("Called CoroutineScheduler::waitForMultipleEvents from the main process"); + error("Called CoroutineScheduler::waitForMultipleObjects from the main process"); CORO_BEGIN_CONTEXT; uint32 endTime; @@ -505,7 +505,7 @@ void CoroutineScheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 * */ void CoroutineScheduler::sleep(CORO_PARAM, uint32 duration) { if (!pCurrent) - error("Called CoroutineScheduler::waitForSingleObject from the main process"); + error("Called CoroutineScheduler::sleep from the main process"); CORO_BEGIN_CONTEXT; uint32 endTime; -- cgit v1.2.3 From a2b51174aad31f66280da91e9c7ec25babd045e6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 25 May 2012 23:36:18 +1000 Subject: COMMON: Cleaned up coroutine comments --- common/coroutines.cpp | 58 +++++++++++++++++++++++++++++++-------------------- common/coroutines.h | 4 +++- 2 files changed, 38 insertions(+), 24 deletions(-) (limited to 'common') diff --git a/common/coroutines.cpp b/common/coroutines.cpp index aff13a5494..b1b08c6bae 100644 --- a/common/coroutines.cpp +++ b/common/coroutines.cpp @@ -37,11 +37,15 @@ DECLARE_SINGLETON(CoroutineScheduler); #ifdef COROUTINE_DEBUG namespace { +/** Count of active coroutines */ static int s_coroCount = 0; typedef Common::HashMap CoroHashMap; static CoroHashMap *s_coroFuncs = 0; +/** + * Change the current coroutine status + */ static void changeCoroStats(const char *func, int change) { if (!s_coroFuncs) s_coroFuncs = new CoroHashMap(); @@ -49,6 +53,9 @@ static void changeCoroStats(const char *func, int change) { (*s_coroFuncs)[func] += change; } +/** + * Display the details of active coroutines + */ static void displayCoroStats() { debug("%d active coros", s_coroCount); @@ -65,6 +72,9 @@ static void displayCoroStats() { } #endif +/** + * Creates a coroutine context + */ CoroBaseContext::CoroBaseContext(const char *func) : _line(0), _sleep(0), _subctx(0) { #ifdef COROUTINE_DEBUG @@ -74,6 +84,9 @@ CoroBaseContext::CoroBaseContext(const char *func) #endif } +/** + * Destructor for coroutine context + */ CoroBaseContext::~CoroBaseContext() { #ifdef COROUTINE_DEBUG s_coroCount--; @@ -499,7 +512,7 @@ void CoroutineScheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 * /** * Make the active process sleep for the given duration in milliseconds - * @param duration Duration in milliseconds + * @param duration Duration in milliseconds * @remarks This duration won't be precise, since it relies on the frequency the * scheduler is called. */ @@ -530,9 +543,9 @@ void CoroutineScheduler::sleep(CORO_PARAM, uint32 duration) { * Creates a new process. * * @param pid process identifier - * @param CORO_ADDR coroutine start address - * @param pParam process specific info - * @param sizeParam size of process specific info + * @param CORO_ADDR Coroutine start address + * @param pParam Process specific info + * @param sizeParam Size of process specific info */ PROCESS *CoroutineScheduler::createProcess(uint32 pid, CORO_ADDR coroAddr, const void *pParam, int sizeParam) { PROCESS *pProc; @@ -601,9 +614,9 @@ PROCESS *CoroutineScheduler::createProcess(uint32 pid, CORO_ADDR coroAddr, const /** * Creates a new process with an auto-incrementing Process Id. * - * @param CORO_ADDR coroutine start address - * @param pParam process specific info - * @param sizeParam size of process specific info + * @param CORO_ADDR Coroutine start address + * @param pParam Process specific info + * @param sizeParam Size of process specific info */ uint32 CoroutineScheduler::createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam) { PROCESS *pProc = createProcess(++pidCounter, coroAddr, pParam, sizeParam); @@ -613,9 +626,9 @@ uint32 CoroutineScheduler::createProcess(CORO_ADDR coroAddr, const void *pParam, /** * Creates a new process with an auto-incrementing Process Id, and a single pointer parameter. * - * @param CORO_ADDR coroutine start address - * @param pParam process specific info - * @param sizeParam size of process specific info + * @param CORO_ADDR Coroutine start address + * @param pParam Process specific info + * @param sizeParam Size of process specific info */ uint32 CoroutineScheduler::createProcess(CORO_ADDR coroAddr, const void *pParam) { return createProcess(coroAddr, &pParam, sizeof(void *)); @@ -625,7 +638,7 @@ uint32 CoroutineScheduler::createProcess(CORO_ADDR coroAddr, const void *pParam) /** * Kills the specified process. * - * @param pKillProc which process to kill + * @param pKillProc Which process to kill */ void CoroutineScheduler::killProcess(PROCESS *pKillProc) { // make sure a valid process pointer @@ -674,7 +687,7 @@ PROCESS *CoroutineScheduler::getCurrentProcess() { /** * Returns the process identifier of the specified process. * - * @param pProc which process + * @param pProc Which process */ int CoroutineScheduler::getCurrentPID() const { PROCESS *pProc = pCurrent; @@ -690,9 +703,9 @@ int CoroutineScheduler::getCurrentPID() const { * Kills any process matching the specified PID. The current * process cannot be killed. * - * @param pidKill process identifier of process to kill - * @param pidMask mask to apply to process identifiers before comparison - * @return The number of processes killed is returned. + * @param pidKill Process identifier of process to kill + * @param pidMask Mask to apply to process identifiers before comparison + * @return The number of processes killed is returned. */ int CoroutineScheduler::killMatchingProcess(uint32 pidKill, int pidMask) { int numKilled = 0; @@ -750,7 +763,7 @@ int CoroutineScheduler::killMatchingProcess(uint32 pidKill, int pidMask) { * called by killProcess() to allow the resource allocator to free * resources allocated to the dying process. * - * @param pFunc Function to be called by killProcess() + * @param pFunc Function to be called by killProcess() */ void CoroutineScheduler::setResourceCallback(VFPTRPP pFunc) { pRCfunction = pFunc; @@ -778,9 +791,9 @@ EVENT *CoroutineScheduler::getEvent(uint32 pid) { /** * Creates a new event object - * @param bManualReset Events needs to be manually reset. Otherwise, events + * @param bManualReset Events needs to be manually reset. Otherwise, events * will be automatically reset after a process waits on the event finishes - * @param bInitialState Specifies whether the event is signalled or not initially + * @param bInitialState Specifies whether the event is signalled or not initially */ uint32 CoroutineScheduler::createEvent(bool bManualReset, bool bInitialState) { EVENT *evt = new EVENT(); @@ -794,7 +807,7 @@ uint32 CoroutineScheduler::createEvent(bool bManualReset, bool bInitialState) { /** * Destroys the given event - * @param pidEvent Event PID + * @param pidEvent Event Process Id */ void CoroutineScheduler::closeEvent(uint32 pidEvent) { EVENT *evt = getEvent(pidEvent); @@ -806,7 +819,7 @@ void CoroutineScheduler::closeEvent(uint32 pidEvent) { /** * Sets the event - * @param pidEvent Event PID + * @param pidEvent Event Process Id */ void CoroutineScheduler::setEvent(uint32 pidEvent) { EVENT *evt = getEvent(pidEvent); @@ -816,7 +829,7 @@ void CoroutineScheduler::setEvent(uint32 pidEvent) { /** * Resets the event - * @param pidEvent Event PID + * @param pidEvent Event Process Id */ void CoroutineScheduler::resetEvent(uint32 pidEvent) { EVENT *evt = getEvent(pidEvent); @@ -827,7 +840,7 @@ void CoroutineScheduler::resetEvent(uint32 pidEvent) { /** * Temporarily sets a given event to true, and then runs all waiting processes, allowing any * processes waiting on the event to be fired. It then immediately resets the event again. - * @param pidEvent Event PID + * @param pidEvent Event Process Id * * @remarks Should not be run inside of another process */ @@ -880,5 +893,4 @@ void CoroutineScheduler::pulseEvent(uint32 pidEvent) { evt->signalled = false; } - } // end of namespace Common diff --git a/common/coroutines.h b/common/coroutines.h index 6df843887c..06af245ba7 100644 --- a/common/coroutines.h +++ b/common/coroutines.h @@ -65,7 +65,8 @@ typedef CoroBaseContext *CoroContext; /** This is a special constant that can be temporarily used as a parameter to call coroutine-ised * from methods from methods that haven't yet been converted to being a coroutine, so code at least - * compiles correctly. Be aware, though, that if you use this, you will get runtime errors. + * compiles correctly. Be aware, though, that an error will occur if a coroutine that was passed + * the nullContext tries to sleep or yield control. */ extern CoroContext nullContext; @@ -283,6 +284,7 @@ public: #define CORO_INFINITE 0xffffffff #define CORO_INVALID_PID_VALUE 0 +/** Coroutine parameter for methods converted to coroutines */ typedef void (*CORO_ADDR)(CoroContext &, const void *); /** process structure */ -- cgit v1.2.3 From 5ba886ce8b3dc5b543d81e3f3a655b328749d778 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 29 May 2012 21:43:23 +1000 Subject: COMMON: Fixed CORO_ADDR parameter names in Doxygen comments --- common/coroutines.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/coroutines.cpp b/common/coroutines.cpp index b1b08c6bae..6159bdc0f3 100644 --- a/common/coroutines.cpp +++ b/common/coroutines.cpp @@ -542,8 +542,8 @@ void CoroutineScheduler::sleep(CORO_PARAM, uint32 duration) { /** * Creates a new process. * - * @param pid process identifier - * @param CORO_ADDR Coroutine start address + * @param pid process identifier + * @param coroAddr Coroutine start address * @param pParam Process specific info * @param sizeParam Size of process specific info */ @@ -614,7 +614,7 @@ PROCESS *CoroutineScheduler::createProcess(uint32 pid, CORO_ADDR coroAddr, const /** * Creates a new process with an auto-incrementing Process Id. * - * @param CORO_ADDR Coroutine start address + * @param coroAddr Coroutine start address * @param pParam Process specific info * @param sizeParam Size of process specific info */ @@ -626,7 +626,7 @@ uint32 CoroutineScheduler::createProcess(CORO_ADDR coroAddr, const void *pParam, /** * Creates a new process with an auto-incrementing Process Id, and a single pointer parameter. * - * @param CORO_ADDR Coroutine start address + * @param coroAddr Coroutine start address * @param pParam Process specific info * @param sizeParam Size of process specific info */ -- cgit v1.2.3 From 415831987d542e249ef9032fdab49bece24934fa Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 29 May 2012 21:51:10 +1000 Subject: COMMON: Copied coroutine doxygen method descriptions to the header file --- common/coroutines.h | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/coroutines.h b/common/coroutines.h index 06af245ba7..5daec4b426 100644 --- a/common/coroutines.h +++ b/common/coroutines.h @@ -356,7 +356,6 @@ private: PROCESS *getProcess(uint32 pid); EVENT *getEvent(uint32 pid); public: - CoroutineScheduler(); ~CoroutineScheduler(); @@ -366,31 +365,62 @@ public: void printStats(); #endif + /** Give all active processes a chance to run */ void schedule(); + + /** Reschedules all the processes to run again this tick */ void rescheduleAll(); + + /** If the specified process has already run on this tick, make it run again on the current tick. */ void reschedule(PPROCESS pReSchedProc = NULL); + + /** Moves the specified process to the end of the dispatch queue, so it can again in the current tick */ void giveWay(PPROCESS pReSchedProc = NULL); + + /** Continously makes a given process wait for another process to finish or event to signal. */ void waitForSingleObject(CORO_PARAM, int pid, uint32 duration, bool *expired = NULL); + + /** Continously makes a given process wait for given prcesses to finished or events to be set */ void waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, bool bWaitAll, uint32 duration, bool *expired = NULL); - void sleep(CORO_PARAM, uint32 duration); + /** Make the active process sleep for the given duration in milliseconds */ + void sleep(CORO_PARAM, uint32 duration); + + /** Creates a new process. */ PROCESS *createProcess(uint32 pid, CORO_ADDR coroAddr, const void *pParam, int sizeParam); uint32 createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam); uint32 createProcess(CORO_ADDR coroAddr, const void *pParam); + + /** Kills the specified process. */ void killProcess(PROCESS *pKillProc); + /** Returns a pointer to the currently running process. */ PROCESS *getCurrentProcess(); + + /** Returns the process identifier of the specified process. */ int getCurrentPID() const; + + /** Kills any process matching the specified PID. The current process cannot be killed. */ int killMatchingProcess(uint32 pidKill, int pidMask = -1); + /** Set pointer to a function to be called by killProcess() */ void setResourceCallback(VFPTRPP pFunc); /* Event methods */ + /** Creates a new event (semaphore) object */ uint32 createEvent(bool bManualReset, bool bInitialState); + + /** Destroys the given event */ void closeEvent(uint32 pidEvent); + + /** Sets the event */ void setEvent(uint32 pidEvent); + + /** Resets the event */ void resetEvent(uint32 pidEvent); + + /** Temporarily sets a given event to true, allowing other waiting processes to fire */ void pulseEvent(uint32 pidEvent); }; -- cgit v1.2.3 From 29ebb2823dfe5fff95c47a2847f11e11bde95fd1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 31 May 2012 08:06:59 +1000 Subject: COMMON: Fix comment typo in coroutine comments --- common/coroutines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/coroutines.h b/common/coroutines.h index 5daec4b426..abc114e0cf 100644 --- a/common/coroutines.h +++ b/common/coroutines.h @@ -64,7 +64,7 @@ typedef CoroBaseContext *CoroContext; /** This is a special constant that can be temporarily used as a parameter to call coroutine-ised - * from methods from methods that haven't yet been converted to being a coroutine, so code at least + * methods from code that haven't yet been converted to being a coroutine, so code at least * compiles correctly. Be aware, though, that an error will occur if a coroutine that was passed * the nullContext tries to sleep or yield control. */ -- cgit v1.2.3 From 5de3f9c765ff50ffb386bf62213c882bd5c93cf1 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 31 May 2012 10:30:29 +0200 Subject: ALL: Correct spelling of "Mac OS X" in various places --- common/taskbar.h | 2 +- common/updates.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/taskbar.h b/common/taskbar.h index ba99d4e487..6f28028e74 100644 --- a/common/taskbar.h +++ b/common/taskbar.h @@ -34,7 +34,7 @@ namespace Common { * The TaskbarManager allows interaction with the ScummVM application icon: * - in the taskbar on Windows 7 and later * - in the launcher for Unity - * - in the dock on MacOSX + * - in the dock on Mac OS X * - ... * * This allows GUI code and engines to display a progress bar, an overlay icon and/or count diff --git a/common/updates.h b/common/updates.h index 1e0babdf6d..4d58a216fb 100644 --- a/common/updates.h +++ b/common/updates.h @@ -30,7 +30,7 @@ namespace Common { /** * The UpdateManager allows configuring of the automatic update checking * for systems that support it: - * - using Sparkle on MacOSX + * - using Sparkle on Mac OS X * - using WinSparkle on Windows * * Most of the update checking is completely automated and this class only -- cgit v1.2.3 From a401f0a19e09d7d00a3ee94d928db82e658b7b48 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 3 Jun 2012 02:02:57 +0200 Subject: ALL: Replace cursorTargetScale in OSystem API with a simple "do not scale" logic. All uses of the old target scale API actually wanted to disallow scaling of the mouse cursor. This commit adapts our API to this and thus simplifies backend implementations. Some backends, most notable the Wii and Android, did some implementation of the cursor target scale, which I didn't adapt yet. I added a TODO for the porters there. --- common/system.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/system.h b/common/system.h index dc74533861..976a3d2c4a 100644 --- a/common/system.h +++ b/common/system.h @@ -883,10 +883,11 @@ public: * @param keycolor transparency color value. This should not exceed the maximum color value of the specified format. * In case it does the behavior is undefined. The backend might just error out or simply ignore the * value. (The SDL backend will just assert to prevent abuse of this). - * @param cursorTargetScale scale factor which cursor is designed for + * @param dontScale Whether the cursor should never be scaled. An exception are high ppi displays, where the cursor + * would be too small to notice otherwise, these are allowed to scale the cursor anyway. * @param format pointer to the pixel format which cursor graphic uses (0 means CLUT8) */ - virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL) = 0; + virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = NULL) = 0; /** * Replace the specified range of cursor the palette with new colors. -- cgit v1.2.3 From b17b38cc364d13992b3be360a460d5b075e5848e Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 7 Jun 2012 17:50:20 +0200 Subject: COMMON: Move coroutine documentation to the header file. --- common/coroutines.cpp | 139 ------------------------------------------- common/coroutines.h | 161 ++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 143 insertions(+), 157 deletions(-) (limited to 'common') diff --git a/common/coroutines.cpp b/common/coroutines.cpp index 6159bdc0f3..102db8d26d 100644 --- a/common/coroutines.cpp +++ b/common/coroutines.cpp @@ -72,9 +72,6 @@ static void displayCoroStats() { } #endif -/** - * Creates a coroutine context - */ CoroBaseContext::CoroBaseContext(const char *func) : _line(0), _sleep(0), _subctx(0) { #ifdef COROUTINE_DEBUG @@ -84,9 +81,6 @@ CoroBaseContext::CoroBaseContext(const char *func) #endif } -/** - * Destructor for coroutine context - */ CoroBaseContext::~CoroBaseContext() { #ifdef COROUTINE_DEBUG s_coroCount--; @@ -100,9 +94,6 @@ CoroBaseContext::~CoroBaseContext() { //--------------------- Scheduler Class ------------------------ -/** - * Constructor - */ CoroutineScheduler::CoroutineScheduler() { processList = NULL; pFreeProcesses = NULL; @@ -124,9 +115,6 @@ CoroutineScheduler::CoroutineScheduler() { reset(); } -/** - * Destructor - */ CoroutineScheduler::~CoroutineScheduler() { // Kill all running processes (i.e. free memory allocated for their state). PROCESS *pProc = active->pNext; @@ -148,9 +136,6 @@ CoroutineScheduler::~CoroutineScheduler() { delete (*i); } -/** - * Kills all processes and places them on the free list. - */ void CoroutineScheduler::reset() { #ifdef DEBUG @@ -195,19 +180,12 @@ void CoroutineScheduler::reset() { #ifdef DEBUG -/** - * Shows the maximum number of process used at once. - */ void CoroutineScheduler::printStats() { debug("%i process of %i used", maxProcs, CORO_NUM_PROCESS); } #endif #ifdef DEBUG -/** - * Checks both the active and free process list to insure all the links are valid, - * and that no processes have been lost - */ void CoroutineScheduler::CheckStack() { Common::List pList; @@ -242,9 +220,6 @@ void CoroutineScheduler::CheckStack() { } #endif -/** - * Give all active processes a chance to run - */ void CoroutineScheduler::schedule() { // start dispatching active process list PROCESS *pNext; @@ -274,9 +249,6 @@ void CoroutineScheduler::schedule() { } } -/** - * Reschedules all the processes to run again this query - */ void CoroutineScheduler::rescheduleAll() { assert(pCurrent); @@ -292,10 +264,6 @@ void CoroutineScheduler::rescheduleAll() { pCurrent->pPrevious = active; } -/** - * If the specified process has already run on this tick, make it run - * again on the current tick. - */ void CoroutineScheduler::reschedule(PPROCESS pReSchedProc) { // If not currently processing the schedule list, then no action is needed if (!pCurrent) @@ -333,11 +301,6 @@ void CoroutineScheduler::reschedule(PPROCESS pReSchedProc) { pReSchedProc->pNext = NULL; } -/** - * Moves the specified process to the end of the dispatch queue - * allowing it to run again within the current game cycle. - * @param pGiveProc Which process - */ void CoroutineScheduler::giveWay(PPROCESS pReSchedProc) { // If not currently processing the schedule list, then no action is needed if (!pCurrent) @@ -371,13 +334,6 @@ void CoroutineScheduler::giveWay(PPROCESS pReSchedProc) { pReSchedProc->pNext = NULL; } -/** - * Continously makes a given process wait for another process to finish or event to signal. - * - * @param pid Process/Event identifier - * @param duration Duration in milliseconds - * @param expired If specified, set to true if delay period expired - */ void CoroutineScheduler::waitForSingleObject(CORO_PARAM, int pid, uint32 duration, bool *expired) { if (!pCurrent) error("Called CoroutineScheduler::waitForSingleObject from the main process"); @@ -434,15 +390,6 @@ void CoroutineScheduler::waitForSingleObject(CORO_PARAM, int pid, uint32 duratio CORO_END_CODE; } -/** - * Continously makes a given process wait for given prcesses to finished or events to be set - * - * @param nCount Number of Id's being passed - * @param evtList List of pids to wait for - * @param bWaitAll Specifies whether all or any of the processes/events - * @param duration Duration in milliseconds - * @param expired Set to true if delay period expired - */ void CoroutineScheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, bool bWaitAll, uint32 duration, bool *expired) { if (!pCurrent) @@ -510,12 +457,6 @@ void CoroutineScheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 * CORO_END_CODE; } -/** - * Make the active process sleep for the given duration in milliseconds - * @param duration Duration in milliseconds - * @remarks This duration won't be precise, since it relies on the frequency the - * scheduler is called. - */ void CoroutineScheduler::sleep(CORO_PARAM, uint32 duration) { if (!pCurrent) error("Called CoroutineScheduler::sleep from the main process"); @@ -539,14 +480,6 @@ void CoroutineScheduler::sleep(CORO_PARAM, uint32 duration) { CORO_END_CODE; } -/** - * Creates a new process. - * - * @param pid process identifier - * @param coroAddr Coroutine start address - * @param pParam Process specific info - * @param sizeParam Size of process specific info - */ PROCESS *CoroutineScheduler::createProcess(uint32 pid, CORO_ADDR coroAddr, const void *pParam, int sizeParam) { PROCESS *pProc; @@ -611,35 +544,15 @@ PROCESS *CoroutineScheduler::createProcess(uint32 pid, CORO_ADDR coroAddr, const return pProc; } -/** - * Creates a new process with an auto-incrementing Process Id. - * - * @param coroAddr Coroutine start address - * @param pParam Process specific info - * @param sizeParam Size of process specific info - */ uint32 CoroutineScheduler::createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam) { PROCESS *pProc = createProcess(++pidCounter, coroAddr, pParam, sizeParam); return pProc->pid; } -/** - * Creates a new process with an auto-incrementing Process Id, and a single pointer parameter. - * - * @param coroAddr Coroutine start address - * @param pParam Process specific info - * @param sizeParam Size of process specific info - */ uint32 CoroutineScheduler::createProcess(CORO_ADDR coroAddr, const void *pParam) { return createProcess(coroAddr, &pParam, sizeof(void *)); } - -/** - * Kills the specified process. - * - * @param pKillProc Which process to kill - */ void CoroutineScheduler::killProcess(PROCESS *pKillProc) { // make sure a valid process pointer assert(pKillProc >= processList && pKillProc <= processList + CORO_NUM_PROCESS - 1); @@ -675,20 +588,10 @@ void CoroutineScheduler::killProcess(PROCESS *pKillProc) { pFreeProcesses = pKillProc; } - - -/** - * Returns a pointer to the currently running process. - */ PROCESS *CoroutineScheduler::getCurrentProcess() { return pCurrent; } -/** - * Returns the process identifier of the specified process. - * - * @param pProc Which process - */ int CoroutineScheduler::getCurrentPID() const { PROCESS *pProc = pCurrent; @@ -699,14 +602,6 @@ int CoroutineScheduler::getCurrentPID() const { return pProc->pid; } -/** - * Kills any process matching the specified PID. The current - * process cannot be killed. - * - * @param pidKill Process identifier of process to kill - * @param pidMask Mask to apply to process identifiers before comparison - * @return The number of processes killed is returned. - */ int CoroutineScheduler::killMatchingProcess(uint32 pidKill, int pidMask) { int numKilled = 0; PROCESS *pProc, *pPrev; // process list pointers @@ -756,15 +651,6 @@ int CoroutineScheduler::killMatchingProcess(uint32 pidKill, int pidMask) { return numKilled; } -/** - * Set pointer to a function to be called by killProcess(). - * - * May be called by a resource allocator, the function supplied is - * called by killProcess() to allow the resource allocator to free - * resources allocated to the dying process. - * - * @param pFunc Function to be called by killProcess() - */ void CoroutineScheduler::setResourceCallback(VFPTRPP pFunc) { pRCfunction = pFunc; } @@ -789,12 +675,6 @@ EVENT *CoroutineScheduler::getEvent(uint32 pid) { } -/** - * Creates a new event object - * @param bManualReset Events needs to be manually reset. Otherwise, events - * will be automatically reset after a process waits on the event finishes - * @param bInitialState Specifies whether the event is signalled or not initially - */ uint32 CoroutineScheduler::createEvent(bool bManualReset, bool bInitialState) { EVENT *evt = new EVENT(); evt->pid = ++pidCounter; @@ -805,10 +685,6 @@ uint32 CoroutineScheduler::createEvent(bool bManualReset, bool bInitialState) { return evt->pid; } -/** - * Destroys the given event - * @param pidEvent Event Process Id - */ void CoroutineScheduler::closeEvent(uint32 pidEvent) { EVENT *evt = getEvent(pidEvent); if (evt) { @@ -817,33 +693,18 @@ void CoroutineScheduler::closeEvent(uint32 pidEvent) { } } -/** - * Sets the event - * @param pidEvent Event Process Id - */ void CoroutineScheduler::setEvent(uint32 pidEvent) { EVENT *evt = getEvent(pidEvent); if (evt) evt->signalled = true; } -/** - * Resets the event - * @param pidEvent Event Process Id - */ void CoroutineScheduler::resetEvent(uint32 pidEvent) { EVENT *evt = getEvent(pidEvent); if (evt) evt->signalled = false; } -/** - * Temporarily sets a given event to true, and then runs all waiting processes, allowing any - * processes waiting on the event to be fired. It then immediately resets the event again. - * @param pidEvent Event Process Id - * - * @remarks Should not be run inside of another process - */ void CoroutineScheduler::pulseEvent(uint32 pidEvent) { EVENT *evt = getEvent(pidEvent); if (!evt) diff --git a/common/coroutines.h b/common/coroutines.h index abc114e0cf..f5519902dd 100644 --- a/common/coroutines.h +++ b/common/coroutines.h @@ -56,7 +56,14 @@ struct CoroBaseContext { #ifdef COROUTINE_DEBUG const char *_funcName; #endif + /** + * Creates a coroutine context + */ CoroBaseContext(const char *func); + + /** + * Destructor for coroutine context + */ virtual ~CoroBaseContext(); }; @@ -344,6 +351,10 @@ private: int numProcs; int maxProcs; + /** + * Checks both the active and free process list to insure all the links are valid, + * and that no processes have been lost + */ void CheckStack(); #endif @@ -356,71 +367,185 @@ private: PROCESS *getProcess(uint32 pid); EVENT *getEvent(uint32 pid); public: + /** + * Constructor + */ CoroutineScheduler(); + + /** + * Destructor + */ ~CoroutineScheduler(); + /** + * Kills all processes and places them on the free list. + */ void reset(); #ifdef DEBUG + /** + * Shows the maximum number of process used at once. + */ void printStats(); #endif - /** Give all active processes a chance to run */ + /** + * Give all active processes a chance to run + */ void schedule(); - /** Reschedules all the processes to run again this tick */ + /** + * Reschedules all the processes to run again this tick + */ void rescheduleAll(); - /** If the specified process has already run on this tick, make it run again on the current tick. */ + /** + * If the specified process has already run on this tick, make it run + * again on the current tick. + */ void reschedule(PPROCESS pReSchedProc = NULL); - /** Moves the specified process to the end of the dispatch queue, so it can again in the current tick */ + /** + * Moves the specified process to the end of the dispatch queue + * allowing it to run again within the current game cycle. + * @param pGiveProc Which process + */ void giveWay(PPROCESS pReSchedProc = NULL); - /** Continously makes a given process wait for another process to finish or event to signal. */ + /** + * Continously makes a given process wait for another process to finish or event to signal. + * + * @param pid Process/Event identifier + * @param duration Duration in milliseconds + * @param expired If specified, set to true if delay period expired + */ void waitForSingleObject(CORO_PARAM, int pid, uint32 duration, bool *expired = NULL); - /** Continously makes a given process wait for given prcesses to finished or events to be set */ + /** + * Continously makes a given process wait for given prcesses to finished or events to be set + * + * @param nCount Number of Id's being passed + * @param evtList List of pids to wait for + * @param bWaitAll Specifies whether all or any of the processes/events + * @param duration Duration in milliseconds + * @param expired Set to true if delay period expired + */ void waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, bool bWaitAll, uint32 duration, bool *expired = NULL); - /** Make the active process sleep for the given duration in milliseconds */ + /** + * Make the active process sleep for the given duration in milliseconds + * + * @param duration Duration in milliseconds + * @remarks This duration won't be precise, since it relies on the frequency the + * scheduler is called. + */ void sleep(CORO_PARAM, uint32 duration); - /** Creates a new process. */ + /** + * Creates a new process. + * + * @param pid process identifier + * @param coroAddr Coroutine start address + * @param pParam Process specific info + * @param sizeParam Size of process specific info + */ PROCESS *createProcess(uint32 pid, CORO_ADDR coroAddr, const void *pParam, int sizeParam); + + /** + * Creates a new process with an auto-incrementing Process Id. + * + * @param coroAddr Coroutine start address + * @param pParam Process specific info + * @param sizeParam Size of process specific info + */ uint32 createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam); + + /** + * Creates a new process with an auto-incrementing Process Id, and a single pointer parameter. + * + * @param coroAddr Coroutine start address + * @param pParam Process specific info + */ uint32 createProcess(CORO_ADDR coroAddr, const void *pParam); - /** Kills the specified process. */ + /** + * Kills the specified process. + * + * @param pKillProc Which process to kill + */ void killProcess(PROCESS *pKillProc); - /** Returns a pointer to the currently running process. */ + /** + * Returns a pointer to the currently running process. + */ PROCESS *getCurrentProcess(); - /** Returns the process identifier of the specified process. */ + /** + * Returns the process identifier of the currently running process. + */ int getCurrentPID() const; - /** Kills any process matching the specified PID. The current process cannot be killed. */ + /** + * Kills any process matching the specified PID. The current + * process cannot be killed. + * + * @param pidKill Process identifier of process to kill + * @param pidMask Mask to apply to process identifiers before comparison + * @return The number of processes killed is returned. + */ int killMatchingProcess(uint32 pidKill, int pidMask = -1); - /** Set pointer to a function to be called by killProcess() */ + /** + * Set pointer to a function to be called by killProcess(). + * + * May be called by a resource allocator, the function supplied is + * called by killProcess() to allow the resource allocator to free + * resources allocated to the dying process. + * + * @param pFunc Function to be called by killProcess() + */ void setResourceCallback(VFPTRPP pFunc); /* Event methods */ - /** Creates a new event (semaphore) object */ + /** + * Creates a new event (semaphore) object + * + * @param bManualReset Events needs to be manually reset. Otherwise, + * events will be automatically reset after a + * process waits on the event finishes + * @param bInitialState Specifies whether the event is signalled or not + * initially + */ uint32 createEvent(bool bManualReset, bool bInitialState); - /** Destroys the given event */ + /** + * Destroys the given event + * @param pidEvent Event Process Id + */ void closeEvent(uint32 pidEvent); - /** Sets the event */ + /** + * Sets the event + * @param pidEvent Event Process Id + */ void setEvent(uint32 pidEvent); - /** Resets the event */ + /** + * Resets the event + * @param pidEvent Event Process Id + */ void resetEvent(uint32 pidEvent); - /** Temporarily sets a given event to true, allowing other waiting processes to fire */ + /** + * Temporarily sets a given event to true, and then runs all waiting + * processes,allowing any processes waiting on the event to be fired. It + * then immediately resets the event again. + * + * @param pidEvent Event Process Id + * + * @remarks Should not be run inside of another process + */ void pulseEvent(uint32 pidEvent); }; -- cgit v1.2.3 From 27aa0974499c6012da894872913f4f44cf6b6a5c Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 7 Jun 2012 17:51:58 +0200 Subject: COMMON: Slightly adapt coroutine code to better match our guidelines. I used astyle here, which automatically removes the use of tabs in comments. --- common/coroutines.cpp | 34 ++++----- common/coroutines.h | 203 +++++++++++++++++++++++++------------------------- 2 files changed, 118 insertions(+), 119 deletions(-) (limited to 'common') diff --git a/common/coroutines.cpp b/common/coroutines.cpp index 102db8d26d..241d31e0d7 100644 --- a/common/coroutines.cpp +++ b/common/coroutines.cpp @@ -34,7 +34,6 @@ CoroContext nullContext = NULL; DECLARE_SINGLETON(CoroutineScheduler); - #ifdef COROUTINE_DEBUG namespace { /** Count of active coroutines */ @@ -63,13 +62,13 @@ static void displayCoroStats() { if (!s_coroFuncs) return; for (CoroHashMap::const_iterator it = s_coroFuncs->begin(); - it != s_coroFuncs->end(); ++it) { + it != s_coroFuncs->end(); ++it) { if (it->_value != 0) debug(" %3d x %s", it->_value, it->_key.c_str()); } } -} +} // End of anonymous namespace #endif CoroBaseContext::CoroBaseContext(const char *func) @@ -86,7 +85,7 @@ CoroBaseContext::~CoroBaseContext() { s_coroCount--; changeCoroStats(_funcName, -1); debug("Deleting coro in %s at %p (subctx %p)", - _funcName, (void *)this, (void *)_subctx); + _funcName, (void *)this, (void *)_subctx); displayCoroStats(); #endif delete _subctx; @@ -133,11 +132,10 @@ CoroutineScheduler::~CoroutineScheduler() { // Clear the event list Common::List::iterator i; for (i = _events.begin(); i != _events.end(); ++i) - delete (*i); + delete *i; } void CoroutineScheduler::reset() { - #ifdef DEBUG // clear number of process in use numProcs = 0; @@ -179,14 +177,14 @@ void CoroutineScheduler::reset() { } -#ifdef DEBUG +#ifdef DEBUG void CoroutineScheduler::printStats() { debug("%i process of %i used", maxProcs, CORO_NUM_PROCESS); } #endif #ifdef DEBUG -void CoroutineScheduler::CheckStack() { +void CoroutineScheduler::checkStack() { Common::List pList; // Check both the active and free process lists @@ -354,7 +352,7 @@ void CoroutineScheduler::waitForSingleObject(CORO_PARAM, int pid, uint32 duratio // Presume it will expire *expired = true; - // Outer loop for doing checks until expiry + // Outer loop for doing checks until expiry while (g_system->getMillis() <= _ctx->endTime) { // Check to see if a process or event with the given Id exists _ctx->pProcess = getProcess(pid); @@ -368,7 +366,7 @@ void CoroutineScheduler::waitForSingleObject(CORO_PARAM, int pid, uint32 duratio break; } - // If a process was found, don't go into the if statement, and keep waiting. + // If a process was found, don't go into the if statement, and keep waiting. // Likewise if it's an event that's not yet signalled if ((_ctx->pEvent != NULL) && _ctx->pEvent->signalled) { // Unless the event is flagged for manual reset, reset it now @@ -390,8 +388,8 @@ void CoroutineScheduler::waitForSingleObject(CORO_PARAM, int pid, uint32 duratio CORO_END_CODE; } -void CoroutineScheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, bool bWaitAll, - uint32 duration, bool *expired) { +void CoroutineScheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, bool bWaitAll, + uint32 duration, bool *expired) { if (!pCurrent) error("Called CoroutineScheduler::waitForMultipleObjects from the main process"); @@ -415,7 +413,7 @@ void CoroutineScheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 * // Presume that delay will expire *expired = true; - // Outer loop for doing checks until expiry + // Outer loop for doing checks until expiry while (g_system->getMillis() <= _ctx->endTime) { _ctx->signalled = bWaitAll; @@ -471,7 +469,7 @@ void CoroutineScheduler::sleep(CORO_PARAM, uint32 duration) { _ctx->endTime = g_system->getMillis() + duration; - // Outer loop for doing checks until expiry + // Outer loop for doing checks until expiry while (g_system->getMillis() < _ctx->endTime) { // Sleep until the next cycle CORO_SLEEP(1); @@ -510,7 +508,7 @@ PROCESS *CoroutineScheduler::createProcess(uint32 pid, CORO_ADDR coroAddr, const pCurrent->pNext = pProc; pProc->pPrevious = pCurrent; - } else { // no active processes, place process at head of list + } else { // no active processes, place process at head of list pProc->pNext = active->pNext; pProc->pPrevious = active; @@ -604,7 +602,7 @@ int CoroutineScheduler::getCurrentPID() const { int CoroutineScheduler::killMatchingProcess(uint32 pidKill, int pidMask) { int numKilled = 0; - PROCESS *pProc, *pPrev; // process list pointers + PROCESS *pProc, *pPrev; // process list pointers for (pProc = active->pNext, pPrev = active; pProc != NULL; pPrev = pProc, pProc = pProc->pNext) { if ((pProc->pid & (uint32)pidMask) == pidKill) { @@ -709,10 +707,10 @@ void CoroutineScheduler::pulseEvent(uint32 pidEvent) { EVENT *evt = getEvent(pidEvent); if (!evt) return; - + // Set the event as true evt->signalled = true; - + // start dispatching active process list for any processes that are currently waiting PROCESS *pOriginal = pCurrent; PROCESS *pNext; diff --git a/common/coroutines.h b/common/coroutines.h index f5519902dd..3b8b1a77f9 100644 --- a/common/coroutines.h +++ b/common/coroutines.h @@ -23,7 +23,7 @@ #define COMMON_COROUTINES_H #include "common/scummsys.h" -#include "common/util.h" // for SCUMMVM_CURRENT_FUNCTION +#include "common/util.h" // for SCUMMVM_CURRENT_FUNCTION #include "common/list.h" #include "common/singleton.h" @@ -133,42 +133,43 @@ public: /** * End the declaration of a coroutine context. - * @param x name of the coroutine context + * @param x name of the coroutine context * @see CORO_BEGIN_CONTEXT */ #define CORO_END_CONTEXT(x) } *x = (CoroContextTag *)coroParam /** * Begin the code section of a coroutine. - * @param x name of the coroutine context + * @param x name of the coroutine context * @see CORO_BEGIN_CODE */ #define CORO_BEGIN_CODE(x) \ - if (&coroParam == &Common::nullContext) assert(!Common::nullContext);\ - if (!x) {coroParam = x = new CoroContextTag();}\ - Common::CoroContextHolder tmpHolder(coroParam);\ - switch (coroParam->_line) { case 0:; + if (&coroParam == &Common::nullContext) assert(!Common::nullContext); \ + if (!x) { coroParam = x = new CoroContextTag(); } \ + Common::CoroContextHolder tmpHolder(coroParam); \ + switch (coroParam->_line) { case 0:; /** * End the code section of a coroutine. * @see CORO_END_CODE */ #define CORO_END_CODE \ - if (&coroParam == &Common::nullContext) { \ - delete Common::nullContext; \ - Common::nullContext = NULL; \ - } \ - } + if (&coroParam == &Common::nullContext) { \ + delete Common::nullContext; \ + Common::nullContext = NULL; \ + } \ + } /** * Sleep for the specified number of scheduler cycles. */ -#define CORO_SLEEP(delay) do {\ - coroParam->_line = __LINE__;\ - coroParam->_sleep = delay;\ - assert(&coroParam != &Common::nullContext);\ - return; case __LINE__:;\ - } while (0) +#define CORO_SLEEP(delay) \ + do { \ + coroParam->_line = __LINE__; \ + coroParam->_sleep = delay; \ + assert(&coroParam != &Common::nullContext); \ + return; case __LINE__:; \ + } while (0) #define CORO_GIVE_WAY do { CoroScheduler.giveWay(); CORO_SLEEP(1); } while (0) #define CORO_RESCHEDULE do { CoroScheduler.reschedule(); CORO_SLEEP(1); } while (0) @@ -182,7 +183,7 @@ public: * then delete the entire coroutine's state, including all subcontexts). */ #define CORO_KILL_SELF() \ - do { if (&coroParam != &Common::nullContext) { coroParam->_sleep = -1; } return; } while (0) + do { if (&coroParam != &Common::nullContext) { coroParam->_sleep = -1; } return; } while (0) /** @@ -201,8 +202,8 @@ public: * If the subcontext is null, the coroutine ended normally, and we can * simply break out of the loop and continue execution. * - * @param subCoro name of the coroutine-enabled function to invoke - * @param ARGS list of arguments to pass to subCoro + * @param subCoro name of the coroutine-enabled function to invoke + * @param ARGS list of arguments to pass to subCoro * * @note ARGS must be surrounded by parentheses, and the first argument * in this list must always be CORO_SUBCTX. For example, the @@ -211,18 +212,18 @@ public: * becomes the following: * CORO_INVOKE_ARGS(myFunc, (CORO_SUBCTX, a, b)); */ -#define CORO_INVOKE_ARGS(subCoro, ARGS) \ - do {\ - coroParam->_line = __LINE__;\ - coroParam->_subctx = 0;\ - do {\ - subCoro ARGS;\ - if (!coroParam->_subctx) break;\ - coroParam->_sleep = coroParam->_subctx->_sleep;\ - assert(&coroParam != &Common::nullContext);\ - return; case __LINE__:;\ - } while (1);\ - } while (0) +#define CORO_INVOKE_ARGS(subCoro, ARGS) \ + do { \ + coroParam->_line = __LINE__; \ + coroParam->_subctx = 0; \ + do { \ + subCoro ARGS; \ + if (!coroParam->_subctx) break; \ + coroParam->_sleep = coroParam->_subctx->_sleep; \ + assert(&coroParam != &Common::nullContext); \ + return; case __LINE__:; \ + } while (1); \ + } while (0) /** * Invoke another coroutine. Similar to CORO_INVOKE_ARGS, @@ -230,62 +231,62 @@ public: * if invoked coroutine yields (thus causing the current * coroutine to yield, too). */ -#define CORO_INVOKE_ARGS_V(subCoro, RESULT, ARGS) \ - do {\ - coroParam->_line = __LINE__;\ - coroParam->_subctx = 0;\ - do {\ - subCoro ARGS;\ - if (!coroParam->_subctx) break;\ - coroParam->_sleep = coroParam->_subctx->_sleep;\ - assert(&coroParam != &Common::nullContext);\ - return RESULT; case __LINE__:;\ - } while (1);\ - } while (0) +#define CORO_INVOKE_ARGS_V(subCoro, RESULT, ARGS) \ + do { \ + coroParam->_line = __LINE__; \ + coroParam->_subctx = 0; \ + do { \ + subCoro ARGS; \ + if (!coroParam->_subctx) break; \ + coroParam->_sleep = coroParam->_subctx->_sleep; \ + assert(&coroParam != &Common::nullContext); \ + return RESULT; case __LINE__:; \ + } while (1); \ + } while (0) /** * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine * with no parameters. */ #define CORO_INVOKE_0(subCoroutine) \ - CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX)) + CORO_INVOKE_ARGS(subCoroutine, (CORO_SUBCTX)) /** * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine * with one parameter. */ #define CORO_INVOKE_1(subCoroutine, a0) \ - CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0)) + CORO_INVOKE_ARGS(subCoroutine, (CORO_SUBCTX, a0)) /** * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine * with two parameters. */ #define CORO_INVOKE_2(subCoroutine, a0,a1) \ - CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0,a1)) + CORO_INVOKE_ARGS(subCoroutine, (CORO_SUBCTX, a0, a1)) /** * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine * with three parameters. */ #define CORO_INVOKE_3(subCoroutine, a0,a1,a2) \ - CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0,a1,a2)) + CORO_INVOKE_ARGS(subCoroutine, (CORO_SUBCTX, a0, a1, a2)) /** * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine * with four parameters. */ #define CORO_INVOKE_4(subCoroutine, a0,a1,a2,a3) \ - CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0,a1,a2,a3)) + CORO_INVOKE_ARGS(subCoroutine, (CORO_SUBCTX, a0, a1, a2, a3)) // the size of process specific info -#define CORO_PARAM_SIZE 32 +#define CORO_PARAM_SIZE 32 // the maximum number of processes -#define CORO_NUM_PROCESS 100 -#define CORO_MAX_PROCESSES 100 +#define CORO_NUM_PROCESS 100 +#define CORO_MAX_PROCESSES 100 #define CORO_MAX_PID_WAITING 5 #define CORO_INFINITE 0xffffffff @@ -296,16 +297,16 @@ typedef void (*CORO_ADDR)(CoroContext &, const void *); /** process structure */ struct PROCESS { - PROCESS *pNext; ///< pointer to next process in active or free list - PROCESS *pPrevious; ///< pointer to previous process in active or free list + PROCESS *pNext; ///< pointer to next process in active or free list + PROCESS *pPrevious; ///< pointer to previous process in active or free list - CoroContext state; ///< the state of the coroutine - CORO_ADDR coroAddr; ///< the entry point of the coroutine + CoroContext state; ///< the state of the coroutine + CORO_ADDR coroAddr; ///< the entry point of the coroutine - int sleepTime; ///< number of scheduler cycles to sleep - uint32 pid; ///< process ID - uint32 pidWaiting[CORO_MAX_PID_WAITING]; ///< Process ID(s) process is currently waiting on - char param[CORO_PARAM_SIZE]; ///< process specific info + int sleepTime; ///< number of scheduler cycles to sleep + uint32 pid; ///< process ID + uint32 pidWaiting[CORO_MAX_PID_WAITING]; ///< Process ID(s) process is currently waiting on + char param[CORO_PARAM_SIZE]; ///< process specific info }; typedef PROCESS *PPROCESS; @@ -321,7 +322,7 @@ struct EVENT { /** * Creates and manages "processes" (really coroutines). */ -class CoroutineScheduler: public Singleton { +class CoroutineScheduler : public Singleton { public: /** Pointer to a function of the form "void function(PPROCESS)" */ typedef void (*VFPTRPP)(PROCESS *); @@ -355,7 +356,7 @@ private: * Checks both the active and free process list to insure all the links are valid, * and that no processes have been lost */ - void CheckStack(); + void checkStack(); #endif /** @@ -382,12 +383,12 @@ public: */ void reset(); - #ifdef DEBUG +#ifdef DEBUG /** * Shows the maximum number of process used at once. */ void printStats(); - #endif +#endif /** * Give all active processes a chance to run @@ -408,71 +409,71 @@ public: /** * Moves the specified process to the end of the dispatch queue * allowing it to run again within the current game cycle. - * @param pGiveProc Which process + * @param pGiveProc Which process */ void giveWay(PPROCESS pReSchedProc = NULL); /** * Continously makes a given process wait for another process to finish or event to signal. * - * @param pid Process/Event identifier - * @param duration Duration in milliseconds - * @param expired If specified, set to true if delay period expired + * @param pid Process/Event identifier + * @param duration Duration in milliseconds + * @param expired If specified, set to true if delay period expired */ void waitForSingleObject(CORO_PARAM, int pid, uint32 duration, bool *expired = NULL); /** * Continously makes a given process wait for given prcesses to finished or events to be set * - * @param nCount Number of Id's being passed - * @param evtList List of pids to wait for - * @param bWaitAll Specifies whether all or any of the processes/events - * @param duration Duration in milliseconds - * @param expired Set to true if delay period expired + * @param nCount Number of Id's being passed + * @param evtList List of pids to wait for + * @param bWaitAll Specifies whether all or any of the processes/events + * @param duration Duration in milliseconds + * @param expired Set to true if delay period expired */ - void waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, bool bWaitAll, - uint32 duration, bool *expired = NULL); + void waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, bool bWaitAll, + uint32 duration, bool *expired = NULL); /** * Make the active process sleep for the given duration in milliseconds * - * @param duration Duration in milliseconds - * @remarks This duration won't be precise, since it relies on the frequency the + * @param duration Duration in milliseconds + * @remarks This duration won't be precise, since it relies on the frequency the * scheduler is called. */ void sleep(CORO_PARAM, uint32 duration); - + /** * Creates a new process. * - * @param pid process identifier - * @param coroAddr Coroutine start address - * @param pParam Process specific info - * @param sizeParam Size of process specific info + * @param pid process identifier + * @param coroAddr Coroutine start address + * @param pParam Process specific info + * @param sizeParam Size of process specific info */ PROCESS *createProcess(uint32 pid, CORO_ADDR coroAddr, const void *pParam, int sizeParam); /** * Creates a new process with an auto-incrementing Process Id. * - * @param coroAddr Coroutine start address - * @param pParam Process specific info - * @param sizeParam Size of process specific info + * @param coroAddr Coroutine start address + * @param pParam Process specific info + * @param sizeParam Size of process specific info */ uint32 createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam); /** * Creates a new process with an auto-incrementing Process Id, and a single pointer parameter. * - * @param coroAddr Coroutine start address - * @param pParam Process specific info + * @param coroAddr Coroutine start address + * @param pParam Process specific info */ uint32 createProcess(CORO_ADDR coroAddr, const void *pParam); /** * Kills the specified process. * - * @param pKillProc Which process to kill + * @param pKillProc Which process to kill */ void killProcess(PROCESS *pKillProc); @@ -490,9 +491,9 @@ public: * Kills any process matching the specified PID. The current * process cannot be killed. * - * @param pidKill Process identifier of process to kill - * @param pidMask Mask to apply to process identifiers before comparison - * @return The number of processes killed is returned. + * @param pidKill Process identifier of process to kill + * @param pidMask Mask to apply to process identifiers before comparison + * @return The number of processes killed is returned. */ int killMatchingProcess(uint32 pidKill, int pidMask = -1); @@ -503,7 +504,7 @@ public: * called by killProcess() to allow the resource allocator to free * resources allocated to the dying process. * - * @param pFunc Function to be called by killProcess() + * @param pFunc Function to be called by killProcess() */ void setResourceCallback(VFPTRPP pFunc); @@ -511,29 +512,29 @@ public: /** * Creates a new event (semaphore) object * - * @param bManualReset Events needs to be manually reset. Otherwise, + * @param bManualReset Events needs to be manually reset. Otherwise, * events will be automatically reset after a * process waits on the event finishes - * @param bInitialState Specifies whether the event is signalled or not + * @param bInitialState Specifies whether the event is signalled or not * initially */ uint32 createEvent(bool bManualReset, bool bInitialState); /** * Destroys the given event - * @param pidEvent Event Process Id + * @param pidEvent Event Process Id */ void closeEvent(uint32 pidEvent); /** * Sets the event - * @param pidEvent Event Process Id + * @param pidEvent Event Process Id */ void setEvent(uint32 pidEvent); /** * Resets the event - * @param pidEvent Event Process Id + * @param pidEvent Event Process Id */ void resetEvent(uint32 pidEvent); @@ -542,9 +543,9 @@ public: * processes,allowing any processes waiting on the event to be fired. It * then immediately resets the event again. * - * @param pidEvent Event Process Id + * @param pidEvent Event Process Id * - * @remarks Should not be run inside of another process + * @remarks Should not be run inside of another process */ void pulseEvent(uint32 pidEvent); }; @@ -553,4 +554,4 @@ public: } // end of namespace Common -#endif // COMMON_COROUTINES_H +#endif // COMMON_COROUTINES_H -- cgit v1.2.3 From 8e7f874db35395d100ca73d9433b25f2f7eae19d Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 7 Jun 2012 18:11:38 +0200 Subject: COMMON: Make CoroutineScheduler's constructor and destructor private. CoroutineSchedule is a singleton, thus it should not be possible to create a custom instance of it. --- common/coroutines.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'common') diff --git a/common/coroutines.h b/common/coroutines.h index 3b8b1a77f9..64eabbf8f4 100644 --- a/common/coroutines.h +++ b/common/coroutines.h @@ -328,6 +328,18 @@ public: typedef void (*VFPTRPP)(PROCESS *); private: + friend class Singleton; + + /** + * Constructor + */ + CoroutineScheduler(); + + /** + * Destructor + */ + ~CoroutineScheduler(); + /** list of all processes */ PROCESS *processList; @@ -368,16 +380,6 @@ private: PROCESS *getProcess(uint32 pid); EVENT *getEvent(uint32 pid); public: - /** - * Constructor - */ - CoroutineScheduler(); - - /** - * Destructor - */ - ~CoroutineScheduler(); - /** * Kills all processes and places them on the free list. */ -- cgit v1.2.3 From d99eb1e6141ba6dc33ca9f600267d4787a67db48 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 13 Jun 2012 04:57:55 +0200 Subject: COMMON: Remove last traces of 8bpp overlay support from OSystem docs. --- common/system.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'common') diff --git a/common/system.h b/common/system.h index 976a3d2c4a..60c0e0f8ef 100644 --- a/common/system.h +++ b/common/system.h @@ -389,10 +389,7 @@ public: * graphics have a resolution of 320x200; then the overlay shall * have a resolution of 640x400, but it still has the same * physical size as the game graphics. - * The overlay usually uses 16bpp, but on some ports, only 8bpp - * are availble, so that is supported, too, via a compile time - * switch (see also the OverlayColor typedef in scummsys.h). - * + * The overlay is forced to a 16bpp mode right now. * * Finally, there is the mouse layer. This layer doesn't have to * actually exist within the backend -- it all depends on how a @@ -758,13 +755,11 @@ public: * In order to be able to display dialogs atop the game graphics, backends * must provide an overlay mode. * - * The overlay can be 8 or 16 bpp. Depending on which it is, OverlayColor - * is 8 or 16 bit. + * The overlay is currently forced at 16 bpp. * * For 'coolness' we usually want to have an overlay which is blended over * the game graphics. On backends which support alpha blending, this is - * no issue; but on other systems (in particular those which only support - * 8bpp), this needs some trickery. + * no issue; but on other systems this needs some trickery. * * Essentially, we fake (alpha) blending on these systems by copying the * current game graphics into the overlay buffer when activating the overlay, -- cgit v1.2.3 From 09ea48978a80e5148be74a7a5ffb2ff099e74ad7 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 13 Jun 2012 05:06:58 +0200 Subject: COMMON: Remove traces of overlay scale from the OSystem documentation. --- common/system.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'common') diff --git a/common/system.h b/common/system.h index 60c0e0f8ef..97205846cb 100644 --- a/common/system.h +++ b/common/system.h @@ -380,15 +380,15 @@ public: * * * The next layer is the overlay. It is composed over the game - * graphics. By default, it has exactly the same size and - * resolution as the game graphics. However, client code can - * specify an overlay scale (as an additional parameter to - * initSize()). This is meant to increase the resolution of the - * overlay while keeping its size the same as that of the game - * graphics. For example, if the overlay scale is 2, and the game - * graphics have a resolution of 320x200; then the overlay shall - * have a resolution of 640x400, but it still has the same - * physical size as the game graphics. + * graphics. Historically the overlay size had always been a + * multiple of the game resolution, for example when the game + * resolution was 320x200 and the user selected a 2x scaler and did + * not enable aspect ratio correction it had a size of 640x400. + * An exception was the aspect ratio correction, which did allow + * for non multiples of the vertical resolution of the game screen. + * Nowadays the overlay size does not need to have any relation to + * the game resolution though, for example the overlay resolution + * might be the same as the physical screen resolution. * The overlay is forced to a 16bpp mode right now. * * Finally, there is the mouse layer. This layer doesn't have to -- cgit v1.2.3 From 51466ecfbb8158792931c27ff00c3bf937adfd40 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 13 Jun 2012 05:09:02 +0200 Subject: COMMON: Remove traces of mouse cursor target scale from OSystem docs. --- common/system.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'common') diff --git a/common/system.h b/common/system.h index 97205846cb..94bf7f01eb 100644 --- a/common/system.h +++ b/common/system.h @@ -396,14 +396,6 @@ public: * backend chooses to implement mouse cursors, but in the default * SDL backend, it really is a separate layer. The mouse can * have a palette of its own, if the backend supports it. - * The scale of the mouse cursor is called 'cursorTargetScale'. - * This is meant as a hint to the backend. For example, let us - * assume the overlay is not visible, and the game graphics are - * displayed using a 2x scaler. If a mouse cursor with a - * cursorTargetScale of 1 is set, then it should be scaled by - * factor 2x, too, just like the game graphics. But if it has a - * cursorTargetScale of 2, then it shouldn't be scaled again by - * the game graphics scaler. * * On a note for OSystem users here. We do not require our graphics * to be thread safe and in fact most/all backends using OpenGL are -- cgit v1.2.3