From 48d0185ea4f8d9ad97c06334e84485bfada7a58c Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Fri, 23 Aug 2024 20:49:26 +0200 Subject: [PATCH] increase flood fill stack size a bit --- compiler/res/prog8lib/cx16/gfx2.p8 | 2 +- compiler/res/prog8lib/cx16/monogfx.p8 | 2 +- compiler/res/prog8lib/virtual/monogfx.p8 | 12 ++++-------- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/compiler/res/prog8lib/cx16/gfx2.p8 b/compiler/res/prog8lib/cx16/gfx2.p8 index 486e87002..2eaa50d2e 100644 --- a/compiler/res/prog8lib/cx16/gfx2.p8 +++ b/compiler/res/prog8lib/cx16/gfx2.p8 @@ -632,7 +632,7 @@ gfx2 { ; Non-recursive scanline flood fill. ; based loosely on code found here https://www.codeproject.com/Articles/6017/QuickFill-An-efficient-flood-fill-algorithm ; with the fixes applied to the seedfill_4 routine as mentioned in the comments. - const ubyte MAXDEPTH = 64 + const ubyte MAXDEPTH = 100 word @zp xx = x as word word @zp yy = y as word word[MAXDEPTH] @split @shared stack_xl diff --git a/compiler/res/prog8lib/cx16/monogfx.p8 b/compiler/res/prog8lib/cx16/monogfx.p8 index 61167294b..5b84c44b6 100644 --- a/compiler/res/prog8lib/cx16/monogfx.p8 +++ b/compiler/res/prog8lib/cx16/monogfx.p8 @@ -708,7 +708,7 @@ invert: ; Non-recursive scanline flood fill. ; based loosely on code found here https://www.codeproject.com/Articles/6017/QuickFill-An-efficient-flood-fill-algorithm ; with the fixes applied to the seedfill_4 routine as mentioned in the comments. - const ubyte MAXDEPTH = 64 + const ubyte MAXDEPTH = 100 word @zp xx = x as word word @zp yy = y as word word[MAXDEPTH] @split @shared stack_xl diff --git a/compiler/res/prog8lib/virtual/monogfx.p8 b/compiler/res/prog8lib/virtual/monogfx.p8 index dd229d798..60bb6f5be 100644 --- a/compiler/res/prog8lib/virtual/monogfx.p8 +++ b/compiler/res/prog8lib/virtual/monogfx.p8 @@ -377,7 +377,7 @@ monogfx { ; Non-recursive scanline flood fill. ; based loosely on code found here https://www.codeproject.com/Articles/6017/QuickFill-An-efficient-flood-fill-algorithm ; with the fixes applied to the seedfill_4 routine as mentioned in the comments. - const ubyte MAXDEPTH = 64 + const ubyte MAXDEPTH = 100 word @zp xx = x as word word @zp yy = y as word word[MAXDEPTH] @split @shared stack_xl @@ -423,11 +423,10 @@ monogfx { while xx >= 0 { if pget(xx as uword, yy as uword) as ubyte != cx16.r11L break + plot(xx as uword, yy as uword, cx16.r10L as bool) xx-- } - if x1!=xx - horizontal_line(xx as uword+1, yy as uword, x1-xx as uword, cx16.r10L as bool) - else + if x1==xx goto skip left = xx + 1 @@ -436,15 +435,12 @@ monogfx { xx = x1 + 1 do { - cx16.r9 = xx as uword while xx <= width-1 { if pget(xx as uword, yy as uword) as ubyte != cx16.r11L break + plot(xx as uword, yy as uword, cx16.r10L as bool) xx++ } - if cx16.r9!=xx - horizontal_line(cx16.r9, yy as uword, (xx as uword)-cx16.r9, cx16.r10L as bool) - push_stack(left, xx - 1, yy, dy) if xx > x2 + 1 push_stack(x2 + 1, xx - 1, yy, -dy)