im looking for a colour fill routine
im looking for a colour fill routine
all the other routines just fill in one colour, i.e white. i need to be able to change the fill color form basic. any ideas? i would prefer a tap file if thats ok...
i started programming the spectrum when i was 8 :-
1 plot rnd*255,rnd*175
2 goto 1
http://zxspeccy.great-site.net/
1 plot rnd*255,rnd*175
2 goto 1
http://zxspeccy.great-site.net/
Re: im looking for a colour fill routine
If you have a routine it might be easier to modify that to suit (possibly)
Assuming its a piece of code doing the 'filling' (probably an LDIR or suchlike) and you want to change it from Basic then in most cases the easy way would be to use a POKE or two to change the fill byte colour.
Would need to see the routine / link of it etc to see if its suitable to do this or not.
Assuming its a piece of code doing the 'filling' (probably an LDIR or suchlike) and you want to change it from Basic then in most cases the easy way would be to use a POKE or two to change the fill byte colour.
Would need to see the routine / link of it etc to see if its suitable to do this or not.
Re: im looking for a colour fill routine
here
https://spectrumcomputing.co.uk/entry/2 ... ll_Routine
and heres another
https://spectrumcomputing.co.uk/entry/2 ... ll_Routine
and heres another
Code: Select all
; scanline fill by John Metcalf
; call with d=x-coord, e=y-coord
; set end marker
fill:
ld l,255
push hl
; calculate bit position of pixel
nextrun:
ld a,d
and 7
inc a
ld b,a
ld a,1
bitpos:
rrca
djnz bitpos
ld c,b
ld b,a
; move left until hitting a set pixel or the screen edge
seekleft:
ld a,d
or a
jr z,goright
dec d
rlc b
call scrpos
jr nz,seekleft
; move right until hitting a set pixel or the screen edge,
; setting pixels as we go. Check rows above and below and
; save their coordinates to fill later if necessary
seekright:
rrc b
inc d
jr z,rightedge
goright:
call scrpos
jr z,rightedge
ld (hl),a
inc e
call checkadj
dec e
dec e
call checkadj
inc e
jr seekright
; check to see if there's another row waiting to be filled
rightedge:
pop de
ld a,e
inc a
jr nz,nextrun
ret
; calculate the pixel address and whether or not it's set
scrpos:
ld a,e
and 248
rra
scf
rra
rra
ld l,a
xor e
and 248
xor e
ld h,a
ld a,l
xor d
and 7
xor d
rrca
rrca
rrca
ld l,a
ld a,b
or (hl)
cp (hl)
ret
; check and save the coordinates of an adjacent row
checkadj:
sla c
ld a,e
cp 192
ret nc
call scrpos+1
ret z
inc c
bit 2,c
ret nz
pop hl
push de
jp (hl)
i started programming the spectrum when i was 8 :-
1 plot rnd*255,rnd*175
2 goto 1
http://zxspeccy.great-site.net/
1 plot rnd*255,rnd*175
2 goto 1
http://zxspeccy.great-site.net/
Re: im looking for a colour fill routine
"Colour" fill on a Spectrum is a messy, complicated business and you probably need to more accurately specify what you want. The attribute system means it isn't necessarily as simple as doing a standard fill routine because (depending on the specification) you may need to switch between filling in INK or PAPER pixels as you transition between characters. Also you may (or may not) need to check bounding conditions based not only on the state of a pixel bit but also what colour that translates to - e.g. if there is an area of Red PAPER next to and area of Red INK and I try to fill it with Green, do both areas end up Green? Are they both INK, both PAPER or a combination of the two...
Re: im looking for a colour fill routine
ok, thank you.AndyC wrote: ↑Tue Jul 27, 2021 11:03 pm "Colour" fill on a Spectrum is a messy, complicated business and you probably need to more accurately specify what you want. The attribute system means it isn't necessarily as simple as doing a standard fill routine because (depending on the specification) you may need to switch between filling in INK or PAPER pixels as you transition between characters. Also you may (or may not) need to check bounding conditions based not only on the state of a pixel bit but also what colour that translates to - e.g. if there is an area of Red PAPER next to and area of Red INK and I try to fill it with Green, do both areas end up Green? Are they both INK, both PAPER or a combination of the two...
i started programming the spectrum when i was 8 :-
1 plot rnd*255,rnd*175
2 goto 1
http://zxspeccy.great-site.net/
1 plot rnd*255,rnd*175
2 goto 1
http://zxspeccy.great-site.net/
- WhatHoSnorkers
- Manic Miner
- Posts: 264
- Joined: Tue Dec 10, 2019 3:22 pm
Re: im looking for a colour fill routine
there's a nice routine called "region fill" in "40 Best Machine Code Routines for the ZX Spectrum" by Hardman and Hewson. You get the bytes in, poke te x and y co-ordinates into the printer buffer and then call it. It will fill the area with INK pixels.
As other folks have said, this may not necessarily get you what you want. Say you have a black screen, white ink, representing outer space.
You want to draw a magenta circle (easy!) and then fill it in using the routine. It will do it, but depending on the size of the circle you'll need to either PLOT INK 3 a few times, or POKE the attribute bytes as the attribute bytes are not updated by the routine.
As other folks have said, this may not necessarily get you what you want. Say you have a black screen, white ink, representing outer space.
You want to draw a magenta circle (easy!) and then fill it in using the routine. It will do it, but depending on the size of the circle you'll need to either PLOT INK 3 a few times, or POKE the attribute bytes as the attribute bytes are not updated by the routine.
I have a little YouTube channel of nonsense
https://www.youtube.com/c/JamesOGradyWhatHoSnorkers
https://www.youtube.com/c/JamesOGradyWhatHoSnorkers
Re: im looking for a colour fill routine
This flood fill routine is all you'll ever need. I can confirm it works flawlessly.WhatHoSnorkers wrote: ↑Fri Aug 06, 2021 8:34 pm there's a nice routine called "region fill" in "40 Best Machine Code Routines for the ZX Spectrum" by Hardman and Hewson. You get the bytes in, poke te x and y co-ordinates into the printer buffer and then call it. It will fill the area with INK pixels.
Spectribution: Dr. Jim's Sinclair computing pages.
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
- WhatHoSnorkers
- Manic Miner
- Posts: 264
- Joined: Tue Dec 10, 2019 3:22 pm
Re: im looking for a colour fill routine
I did these flags using the fill routine. set the ink and paper colour, draw three circles. fill.
set the ink and paper colour. draw four stars. fill.
I have a little YouTube channel of nonsense
https://www.youtube.com/c/JamesOGradyWhatHoSnorkers
https://www.youtube.com/c/JamesOGradyWhatHoSnorkers
-
- Microbot
- Posts: 194
- Joined: Mon Oct 08, 2018 3:36 am
Re: im looking for a colour fill routine
Most fill subroutines are not practical as they are recursive depth first fills. Filling an area could take the entire memory of the machine to complete. The scan line fill by John Metcalf mentioned here is better as long as a true flood fill is not required as it could leave unfilled areas depending on whether the shape is convex or not.
I wrote this one many years ago ( https://spectrumcomputing.co.uk/entry/2 ... Flood_Fill ) after seeing Chris Pile's lightning fast filler in YS (I think?). I still remember his name all these years later because of how fast that thing ran. Chris Pile's was also not practical since it could possibly use a large chunk of the memory when filling but the speed impressed. His idea was to fill whole bytes instead of a pixel at a time. My version did the same but changed the algorithm to breadth first so memory requirement was only around 300 bytes for arbitrary fill regions. The version in the link above does a pattern fill instead of a solid fill and the cost is reduced speed (but it's still way faster than pixel at a time fillers) and increased memory requirement to about 900 bytes. Changing the code to apply colour is straightforward but as this thread is old, I'm only going to mention these things rather than do actual work
I wrote this one many years ago ( https://spectrumcomputing.co.uk/entry/2 ... Flood_Fill ) after seeing Chris Pile's lightning fast filler in YS (I think?). I still remember his name all these years later because of how fast that thing ran. Chris Pile's was also not practical since it could possibly use a large chunk of the memory when filling but the speed impressed. His idea was to fill whole bytes instead of a pixel at a time. My version did the same but changed the algorithm to breadth first so memory requirement was only around 300 bytes for arbitrary fill regions. The version in the link above does a pattern fill instead of a solid fill and the cost is reduced speed (but it's still way faster than pixel at a time fillers) and increased memory requirement to about 900 bytes. Changing the code to apply colour is straightforward but as this thread is old, I'm only going to mention these things rather than do actual work
- Einar Saukas
- Bugaboo
- Posts: 3219
- Joined: Wed Nov 15, 2017 2:48 pm
Re: im looking for a colour fill routine
Do you still have the solid fill version with lower memory requirement? It would be nice to add it to this entry too.
And perhaps instructions in PDF format. Nobody uses DOC anymore
And perhaps instructions in PDF format. Nobody uses DOC anymore
Re: im looking for a colour fill routine
Ahem.Einar Saukas wrote: ↑Wed Sep 01, 2021 2:38 pm
And perhaps instructions in PDF format. Nobody uses DOC anymore
Doc can be opened and edited/converted to any format, PDF... not so much!
Re: im looking for a colour fill routine
True ... most people probaly use DOCX these days
Website: Tardis Remakes / Mostly remakes of Arcade and ZX Spectrum games.
My games for the Spectrum: Dingo, The Speccies, The Speccies 2, Vallation & Sqij.
Twitter: Sokurah
My games for the Spectrum: Dingo, The Speccies, The Speccies 2, Vallation & Sqij.
Twitter: Sokurah
Re: im looking for a colour fill routine
ODT all the way here.
The only DOC files I've dealt with recently were Quill files on the QL.
The only DOC files I've dealt with recently were Quill files on the QL.
Spectribution: Dr. Jim's Sinclair computing pages.
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
- rastersoft
- Microbot
- Posts: 151
- Joined: Mon Feb 22, 2021 3:55 pm
Re: im looking for a colour fill routine
That remembers me that, in Spanish, the letters "ODT" are spelled much like as the Spanish translation of "F*** you"
It's the nerd version of "Eau D'Ete", an eau de cologne that started being announced some Christmas ago that, when pronounced in Spanish, also sounded like that... I can imagine the marketing people going crazy: "but... but... can we at least CHANGE the name here, in Spain? People will think that it's a present for a break up!"
(yes, pure off-topic, but...)
-
- Microbot
- Posts: 194
- Joined: Mon Oct 08, 2018 3:36 am
Re: im looking for a colour fill routine
The source code is in fragments in the doc. I spent a few mins on it:Einar Saukas wrote: ↑Wed Sep 01, 2021 2:38 pm Do you still have the solid fill version with lower memory requirement? It would be nice to add it to this entry too.
And perhaps instructions in PDF format. Nobody uses DOC anymore
https://drive.google.com/file/d/0B6XhJJ ... TH7AK6hGiw
PDF in there and the tap file is updated to contain all the listings. fig-5 is the behaved black fill. fig-4 is the misbehaved but very fast black fill.
- Einar Saukas
- Bugaboo
- Posts: 3219
- Joined: Wed Nov 15, 2017 2:48 pm
Re: im looking for a colour fill routine
Thank you!!!