[Scummvm-cvs-logs] SF.net SVN: scummvm: [29589] scummvm/trunk/engines/agi/picture.cpp
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Wed Nov 21 01:34:32 CET 2007
Revision: 29589
http://scummvm.svn.sourceforge.net/scummvm/?rev=29589&view=rev
Author: thebluegr
Date: 2007-11-20 16:34:32 -0800 (Tue, 20 Nov 2007)
Log Message:
-----------
Common::FixedStack is used now for AGI flood fill routines
Modified Paths:
--------------
scummvm/trunk/engines/agi/picture.cpp
Modified: scummvm/trunk/engines/agi/picture.cpp
===================================================================
--- scummvm/trunk/engines/agi/picture.cpp 2007-11-20 23:42:45 UTC (rev 29588)
+++ scummvm/trunk/engines/agi/picture.cpp 2007-11-21 00:34:32 UTC (rev 29589)
@@ -23,12 +23,10 @@
*
*/
-
-
#include "agi/agi.h"
#include "agi/graphics.h"
+#include "common/stack.h"
-
namespace Agi {
PictureMgr::PictureMgr(AgiBase *agi, GfxMgr *gfx) {
@@ -64,29 +62,11 @@
*p = _scrColor | (*p & 0xf0);
}
-/* For the flood fill routines */
+// For the flood fill routines
-/* MH2 needs stack size > 300 */
-// FIXME: Consider using FixedStack<> or Stack<> from common/stack.h here
-#define STACK_SIZE 512
-static unsigned int stackPtr;
-static uint16 stack[STACK_SIZE];
+// MH2 needs stack size > 300
+Common::FixedStack<uint16> _stack[512];
-static INLINE void lpush(uint16 c) {
- assert(stackPtr < STACK_SIZE);
-
- stack[stackPtr] = c;
- stackPtr++;
-}
-
-static INLINE uint16 lpop() {
- if (stackPtr == 0)
- return 0xffff;
-
- stackPtr--;
- return stack[stackPtr];
-}
-
/**
* Draw an AGI line.
* A line drawing routine sent by Joshua Neal, modified by Stuart George
@@ -291,7 +271,7 @@
putVirtPixel(c, y);
if (isOkFillHere(c, y - 1)) {
if (newspanUp) {
- lpush(c + (_width * 2) * (y - 1));
+ _stack->push(c + (_width * 2) * (y - 1));
newspanUp = 0;
}
} else {
@@ -300,7 +280,7 @@
if (isOkFillHere(c, y + 1)) {
if (newspanDown) {
- lpush(c + (_width * 2) * (y + 1));
+ _stack->push(c + (_width * 2) * (y + 1));
newspanDown = 0;
}
} else {
@@ -310,22 +290,23 @@
}
void PictureMgr::agiFill(unsigned int x, unsigned int y) {
- lpush(x + (_width * 2) * y);
+ uint16 c;
+ _stack->push(x + (_width * 2) * y);
for (;;) {
- uint16 c = lpop();
-
- /* Exit if stack is empty */
- if (c == 0xffff)
+ // Exit if stack is empty
+ if (_stack->empty())
break;
+ c = _stack->pop();
+
x = c % (_width * 2);
y = c / (_width * 2);
fillScanline(x, y);
}
- stackPtr = 0;
+ _stack->clear();
}
/**************************************************************************
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list