Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team
ThorstenOtto wrote:The real fun starts with polygons like this:
Screenshot_20181012_023354.png
Zamuel_a wrote:How is the XOR filler done? Sounds interessting to try it out with the blitter? But I can't see how it can automatically draw a line? It seems like all that will happen is that black pixels turn white (0 to 1) and the opposite. Nothing else.
ThorstenOtto wrote:The real fun starts with polygons like this:
you copy a full bitplane on itself in xor mode with blitter with destadr = sourceadr + line size (160 bytes for instance). what it does is to make the horizontal borders of the outline working as a toggle fill / do not fill
Code: Select all
void line(int x1, int y1, int x2, int y2)
{
float dydx;
float y;
int x;
dydx = (float)(y2 - y1) / (float)(x2 - x1);
y = y1;
for (x = x1; x <= x2; x++)
{
Plot(x, (int)y, 255 ^ GetPixel(x, (int)y));
y += dydx;
}
}
void XORfill()
{
int x, y;
BYTE color1, color2, final_color;
line(10, 10, 250, 100);
line(150, 150, 250, 100);
line(80, 250, 150, 150);
line(10, 10, 80, 250);
for (y = 0; y < 300; y++)
{
for (x = 0; x < 320; x++)
{
color1 = testGetPixel(x, y);
color2 = testGetPixel(x, y-1);
final_color = color1^color2;
Plot(x, y, final_color);
}
}
}
Code: Select all
trace:
lea -pitch.w,a2 *
sub.w d2,d0 * d0: width
beq.s return * if dx = 0 => do nothing
neg.w d0 *
sub.w d3,d1 * d1: height
beq h_line * if dy = 0 => hline
blt.s trace_ok *
lea pitch.w,a2 * if dy negative => invert address increment
neg.w d1 * abs (dy)
trace_ok:
neg.w d1 *
lea pitchmul(pc),a1 * compute start address : a0 += y2 * pitch
add.w d3,d3 *
move.w (a1,d3.w),d3 *
; add.w d3,d3 * (pitch / 2) * 2
add.w d3,a0
cmp.w d0,d1 * Compare dx & dy
; blt.s horizontal * => dx > dy => horizontal routine
bgt vertical * => dy > dx => vertical routine
beq d45 * => equal => 45° routine
Users browsing this forum: rudis and 5 guests