English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   Coders. Asm / Hardware (https://eab.abime.net/forumdisplay.php?f=112)
-   -   Normal horizontal line drawing issue (https://eab.abime.net/showthread.php?t=106410)

leonard 28 March 2021 21:29

Normal horizontal line drawing issue
 
1 Attachment(s)
Hi!

I have no issue drawing line with blitter in order to do blitter polygon fill later.

But now I want to draw normal lines. I patched the BLTCON0 & BLTCON1 to set "bset" instead of "xor" and also to draw all pixels ( and not only one per scanline ). Everything is working well, except for horizonal lines!
Look at screenshot, when drawing horizontal lines of a standard cube, the lines are drawn like "vertical"??!!

Any idea?

a/b 28 March 2021 22:03

Wrong octant when y1 == y2? Should be fine if you handle zero delta the same way as positive delta. So maybe just a case of a simple bpl/bgt/bge change...

leonard 28 March 2021 22:07

Quote:

Originally Posted by a/b (Post 1473706)
Wrong octant when y1 == y2? Should be fine if you handle zero delta the same way as positive delta. So maybe just a case of a simple bpl/bgt/bge change...

the thing is the original line rout I used obviously has early out when y0 == y1 ( that's normal for polygon filling ). So I guess the octant selection for y0==y1 of this rout has never been tested :( ( and I never really get how amiga octant are working :) )

ross 29 March 2021 12:08

Code:

(x1,y1)(x2,y2)
dx=|x1-x2|
dy=|y1-y2|

 \  |  /
  \6 | 7/
 5 \ | / 8
    \|/ 
 ----X----
    /|\ 
 4 / | \ 1
  /3 | 2\
 /  |  \

Octant (based on line start):

1-|SUD=1  2-|SUD=0  3-|SUD=0  4-|SUD=1
  |SUL=0    |SUL=0    |SUL=1    |SUL=0
  |AUL=0    |AUL=0    |AUL=0    |AUL=1

5-|SUD=1  6-|SUD=0  7-|SUD=0  8-|SUD=1
  |SUL=1    |SUL=1    |SUL=0    |SUL=1
  |AUL=1    |AUL=1    |AUL=1    |AUL=0

100 : y1< y2, x1< x2, dx>=dy
000 : y1< y2, x1< x2, dx< dy
010 : y1< y2, x1>=x2, dx< dy
101 : y1< y2, x1>=x2, dx>=dy
111 : y1>=y2, x1>=x2, dx>=dy
011 : y1>=y2, x1>=x2, dx< dy
001 : y1>=y2, x1< x2, dx< dy
110 : y1>=y2, x1< x2, dx>=dy

Now you can check and optimize it ;)


You will find discordant notations about the octant numbering almost everywhere.
I opted for the 'natural' one for y increasing downwards (therefore in a clockwise direction, it is practically mirrored on x with respect to the Cartesian one).

EDIT: when the point straddles two octants, you can choose any; I put condition (>=), but using (<=) instead of (<) could be fine too [I should try it]


All times are GMT +2. The time now is 10:54.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.05192 seconds with 11 queries