0 Members and 2 Guests are viewing this topic.
:.FLOOD:Buff(768)→GDB1:15→A .Coordinates of "paint bucket":15→B:0→S→D→C .Screen buffer size, data buffer size and counting var:PUS(A,B) .Add the first pixel to stack:While S+D . as long there's sth in the buffers:C++:POP() .Get a pixel:!If pxl-Test(P,Q) .Test if it's off:Pxl-On(P,Q) .if yes, turn it on:P?PUS(P-1,Q) .Put pixels around it on the stack:P-95?PUS(P+1,Q):Q-63?PUS(P,Q+1):Q?PUS(P,Q-1):End:C^64??DispGraph .Only display every 64 time; not needed:ReturnIf getKey(15):End:DispGraph:Return::Lbl PUS .Push algorithm:ReturnIf pxl-Test(r1,r2) .only push if the pixel is white:If D-357 .if stack isn't full yet:r1→{D*2+L1} .add to stack:r2→{D*2+1+L1}:D++ .increment stack pointer:sub(CHKr,r1,r2) .check if pixel is black on the back buffer, if yes, remove it there:Else!If pxl-Test(r1,r2,GDB1) .if stack is full, make sure that the pixel isn't in memory yet:Pxl-On(r1,r2,GDB1) .turn it on on the back buffer:S++ .increment buffer size:End:Return::Lbl POP .Pop algorithm:If D .if there's something on the stack:D-- .decremt stack pointer:{D*2+L1}→P .get the coordinates from the stack:{D*2+1+L1}→Q:CHK(P,Q) .check if pixel is black on the back buffer, if yes, remove it there:Else .if stack empty:For(Q,0,63 .go on searching the back buffer (slow...):For(P,0,95:If pxl-Test(P,Q,GDB1) .if you got a pixel:Pxl-Off(P,Q,GDB1) .turn it off:S-- .decrement the buffer size:Return .return to main:End:End:End:End:Return::Lbl CHK .check algorithm:If pxl-Test(r1,r2,GDB1) .check if pixel is black on the back buffer:Pxl-Off(r1,r2,GDB1 .if yes, remove it there:S-- .decrement the buffer size:End:Return