English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 28 March 2021, 21:29   #1
leonard
Registered User
 
leonard's Avatar
 
Join Date: Apr 2013
Location: paris
Posts: 133
Normal horizontal line drawing issue

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?
Attached Thumbnails
Click image for larger version

Name:	hlines.png
Views:	117
Size:	12.4 KB
ID:	71459  
leonard is offline  
Old 28 March 2021, 22:03   #2
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
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...
a/b is offline  
Old 28 March 2021, 22:07   #3
leonard
Registered User
 
leonard's Avatar
 
Join Date: Apr 2013
Location: paris
Posts: 133
Quote:
Originally Posted by a/b View Post
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 )
leonard is offline  
Old 29 March 2021, 12:08   #4
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
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]

Last edited by ross; 29 March 2021 at 12:56.
ross is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Blitter Line reverse drawing question sandruzzo Coders. Asm / Hardware 9 20 February 2021 05:52
Puzzling: Blitter line drawing faster on second execution Yragael Coders. Asm / Hardware 10 02 June 2019 22:52
Blitter line-drawing mode? E-Penguin Coders. Blitz Basic 2 13 April 2019 21:37
Blitter line drawing: nothing happens Crank Coders. General 21 25 April 2018 21:43
Drawing a line... Lonewolf10 Coders. Tutorials 24 06 September 2011 00:46

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 16:31.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.12067 seconds with 16 queries