Disabler / DPL
Fill the closed area on the screen
Today you will learn about such
Things like shading. Immediately, I note that we do not fill up
landfills and stuff, but just closed area on the screen, and
the region may be limited as a unit, and zero points. Will fill
solid color, ie, without texture (the texture of the casting
will be discussed below).
The algorithm is simple to fill and disgrace
however, works pretty fast.
Thus, suppose we have a closed area
on the screen (Fig. 1) and a point within this region with the
coordinates X and Y.
■ ■ ■ ■ ■ ■ ■ ■ ■
■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■
■ ■ ■ ■ ■ ■
■ ■ (X, Y) ■ ■ ■
■ ■
■ ■ ■ ■ ■ ■
■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■
■ ■ ■ ■ ■ ■ ■ ■ ■
Figure 1
We need two buffer sizes of 1024
bytes each (512 points). And now for
order:
1. In buffer # 1 coordinate our
point (X, Y) and store the number of positions of the points
(in our case - 1).
2. Take a point from buffer # 1 and put
zero points around it in buffer # 2 and simultaneously make
them isolated. And so on until not process all the points of
buffer # 1 (Fig. 2).
■ ■ ■ ■ ■ ■ ■ ■ ■
■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■
■ ■ ■ ■ ■ ■ ■
■ ■ ■ ■ ■ ■ ■
■ ■ ■
■ ■ ■ ■ ■ ■
■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■
■ ■ ■ ■ ■ ■ ■ ■ ■
Figure 2
3. Take a point from buffer # 2 and put
zero points around it in buffer # 1 and simultaneously make
them isolated. Repeat for all points of the buffer # 2 (Fig. 3).
■ ■ ■ ■ ■ ■ ■ ■ ■
■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■
■ ■ ■ ■ ■ ■ ■ ■ ■
■ ■ ■ ■ ■ ■ ■ ■ ■
■ ■ ■ ■ ■
■ ■ ■ ■ ■ ■ ■
■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■
■ ■ ■ ■ ■ ■ ■ ■ ■
Fig.3
4. Go to step 2.
The algorithm is completed if
in one of the buffers will not appear any
point.
Fill texture
Fill texture is different from
solid fill virtually anything except
one - need a buffer size # 3
6144 bytes.
Here we go:
1. Copy the screen buffer # 3
2. Fill it with solid-filled area on the
screen.
Process the byte at the screen:
3. Berem byte screen (scr), we add
to xor with the bytes from the buffer # 3. Thus we get a mask
on which to superimpose the texture (mask).
4. Berem byte current address
screen and select the lowest three bits (and 7
or and% 00000111) - is offset of the texture (textur).
5. Take the B textur, invert, and mask making, and xor scr,
then we put it in place scr.
6. Increase address by one and go to step 3. And so 6,144
times.
P. S: Put point on the screen can be as follows:
; (C) 1996 Disabler / DPL
; A, C - Coordinates
point call 8880
add a, a
add a, a
add a, a
ld b, a
ld a, # fe
sub b
ld ($ +4), a
set 0, (hl)
ret
P. P. S: The annex is ishodnyaki realizing all the above
algorithms.
See You, May Be!
Disabler 25.Feb '2000