English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 17 April 2018, 20:38   #1
Crank
Registered User

 
Join Date: Mar 2018
Location: Prague
Posts: 31
Blitter line drawing: nothing happens

I'm stuck with getting the Blitter to draw a simple line. I'm not sure what I'm doing wrong for not getting anything visible. Here's the C code:

while (!(REG_DMACON_R & (1 << 6))); // Wait for blitter to be ready

const unsigned int dx = 40;
const unsigned int dy = 20;
const unsigned int x1 = 7;

REG_BLTADAT_W = 0x8000;
REG_BLTBDAT_W = 0xFFFF; // Solid line
REG_BLTAFWM_W = 0xFFFFFFFF;

REG_BLTAMOD_W = 4*(dy - dx);
REG_BLTBMOD_W = 4*dy;
REG_BLTCMOD_W = 320/8; // Width of bitplane (bytes)
REG_BLTDMOD_W = 320/8; // Width of bitplane (bytes)

REG_BLTAPTH_W = 4*dy - 2*dx;
REG_BLTCPTH_W = bitplane_0_address + (32*320/8); // First word (16bit) where the drawing starts
REG_BLTDPTH_W = bitplane_0_address + (32*320/8); // First word (16bit) where the drawing starts

REG_BLTCON0_W = ((x1 & 0x0F) << 12) |
((1 << 8) | (1 << 9) | (1 << 11)); // SRCA/SRCC/SRDD

REG_BLTCON1_W = 1 | // Line mode
(0 << 2); // Octant number: bits 2-4

REG_BLTSIZE_W = ((dx + 1) << 6) | 2;

// ----------------

And here are the register definitions, just in case:

#define REG_BPL1PT_W *((volatile unsigned int*) 0xDFF0E0)
#define REG_BPL2PT_W *((volatile unsigned int*) 0xDFF0E4)

#define REG_BLTCON_W *((volatile unsigned int*) 0xDFF040)
#define REG_BLTCON0_W *((volatile unsigned short*) 0xDFF040)
#define REG_BLTCON1_W *((volatile unsigned short*) 0xDFF042)

#define REG_BLTAFWM_W *((volatile unsigned int*) 0xDFF044)

#define REG_BLTAPTH_W *((volatile unsigned int*) 0xDFF050)
#define REG_BLTBPTH_W *((volatile unsigned int*) 0xDFF04C)
#define REG_BLTCPTH_W *((volatile unsigned int*) 0xDFF048)
#define REG_BLTDPTH_W *((volatile unsigned int*) 0xDFF054)

#define REG_BLTAMOD_W *((volatile unsigned short*) 0xDFF064)
#define REG_BLTBMOD_W *((volatile unsigned short*) 0xDFF062)
#define REG_BLTCMOD_W *((volatile unsigned short*) 0xDFF060)
#define REG_BLTDMOD_W *((volatile unsigned short*) 0xDFF066)

#define REG_BLTSIZE_W *((volatile unsigned short*) 0xDFF058)

#define REG_BLTADAT_W *((volatile unsigned short*) 0xDFF074)
#define REG_BLTBDAT_W *((volatile unsigned short*) 0xDFF072)
#define REG_BLTCDAT_W *((volatile unsigned short*) 0xDFF070)

#define REG_BLTAFWM_W *((volatile unsigned int*) 0xDFF044)

// ----------------

What am I doing wrong? I've tried all 8 possible value choices for the octant but nothing is visible on the screen.
Crank is offline  
Old 17 April 2018, 20:50   #2
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,238
First question that springs to mind (without checking the code): is blitter DMA enabled?
StingRay is offline  
Old 17 April 2018, 22:38   #3
Crank
Registered User

 
Join Date: Mar 2018
Location: Prague
Posts: 31
Hmm, I have a feeling that it is not. Now I have to check how to enable it.

But then again, if I'm able to use blitter to clear rectangular areas, does this mean the DMA is on?
Crank is offline  
Old 17 April 2018, 22:44   #4
Crank
Registered User

 
Join Date: Mar 2018
Location: Prague
Posts: 31
Aha!

If I fill the screen with white color and see what the line drawing routine does, I get the two black boxes (see the attached image).
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2018-04-17 at 22.42.30.png
Views:	68
Size:	62.2 KB
ID:	57900  
Crank is offline  
Old 17 April 2018, 22:52   #5
Photon
Moderator

Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 4,765
Looks like the low byte of BLTCON0 (the minterm) is empty? One normal value is $fa.
Photon is offline  
Old 17 April 2018, 23:05   #6
Crank
Registered User

 
Join Date: Mar 2018
Location: Prague
Posts: 31
Hey, now it works! Thanks!

My next stop is to check if there is a way to draw the line with subpixel accuracy. I think this is possible, based on some website which showed that subpixel accuracy is possible when doing polygon filling (used blitter for line drawing IIRC).
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2018-04-17 at 23.00.38.png
Views:	100
Size:	82.4 KB
ID:	57901  
Crank is offline  
Old 18 April 2018, 13:11   #7
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 943
Quote:
Originally Posted by Crank View Post
Hey, now it works! Thanks!

My next stop is to check if there is a way to draw the line with subpixel accuracy. I think this is possible, based on some website which showed that subpixel accuracy is possible when doing polygon filling (used blitter for line drawing IIRC).
This? https://scalibq.wordpress.com/2011/1...t-real-part-5/
hooverphonique is offline  
Old 18 April 2018, 19:27   #8
LaBodilsen
Registered User

 
Join Date: Dec 2017
Location: Gandrup / Denmark
Posts: 91
This might be of interest
[ Show youtube player ]

With asm source here:
https://github.com/niklasekstrom/blitter-subpixel-line
LaBodilsen is offline  
Old 18 April 2018, 20:06   #9
Crank
Registered User

 
Join Date: Mar 2018
Location: Prague
Posts: 31
@hooverphonique:
Yes, that was the page

@LaBodilsen:
Nice, thanks! I gotta read that carefully.

I'll report back here if/when I get something working
Crank is offline  
Old 20 April 2018, 21:11   #10
Crank
Registered User

 
Join Date: Mar 2018
Location: Prague
Posts: 31
BTW:
Is there some fast way to clip the lines to screen borders using hardware or do I need to just calculate the clip locations myself?
Crank is offline  
Old 20 April 2018, 21:17   #11
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,238
There is no built-in hardware support for clipping lines. Go and code your clipping routine.
StingRay is offline  
Old 20 April 2018, 23:49   #12
Crank
Registered User

 
Join Date: Mar 2018
Location: Prague
Posts: 31
OK, I will

(attached is an image of a buggy version, I was going to ask about the bug but realized I had a buggy "wait for blitter to finish" routine)
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2018-04-20 at 23.38.07.png
Views:	74
Size:	81.1 KB
ID:	57938  
Crank is offline  
Old 21 April 2018, 07:31   #13
LaBodilsen
Registered User

 
Join Date: Dec 2017
Location: Gandrup / Denmark
Posts: 91
Quote:
Originally Posted by StingRay View Post
There is no built-in hardware support for clipping lines. Go and code your clipping routine.
That is something i never got around to myself.

Any hints on how to approach this, with limited math skils (goes as far as rotating a point and pythagoras).
LaBodilsen is offline  
Old 21 April 2018, 12:26   #14
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,238
One hint: Cohen-Sutherland. It's a pretty straightforward clipping algorithm which can be easily implemented. Shouldn't take more than an afternoon of work to have a completely working 68k asm version.
StingRay is offline  
Old 21 April 2018, 18:01   #15
LaBodilsen
Registered User

 
Join Date: Dec 2017
Location: Gandrup / Denmark
Posts: 91
Quote:
Originally Posted by StingRay View Post
One hint: Cohen-Sutherland. It's a pretty straightforward clipping algorithm which can be easily implemented. Shouldn't take more than an afternoon of work to have a completely working 68k asm version.
I was afraid you where gonna say that. I have looked at it before, but it never clicked with me, however i just found an example in C in the wikipage, which makes it a little more clear. So i might give it a go now.
LaBodilsen is offline  
Old 22 April 2018, 20:09   #16
Crank
Registered User

 
Join Date: Mar 2018
Location: Prague
Posts: 31
Quote:
Originally Posted by LaBodilsen View Post
I was afraid you where gonna say that. I have looked at it before, but it never clicked with me, however i just found an example in C in the wikipage, which makes it a little more clear. So i might give it a go now.
Think of it like this:

1. Take one of the four screen borders and test if line vertices are on different sides of that border. If they are, clip the line.

2. Repeat #1 with the clipped line using the next screen border.

Once you've done it with all four screen borders, you're done.

Cohen-Sutherland algorithm optimises the number of borders you actually need to test/clip against.
Crank is offline  
Old 25 April 2018, 14:50   #17
Niklas
Registered User

 
Join Date: Apr 2018
Location: Stockholm / Sweden
Posts: 47
Quote:
Originally Posted by Crank View Post
Hey, now it works! Thanks!

My next stop is to check if there is a way to draw the line with subpixel accuracy. I think this is possible, based on some website which showed that subpixel accuracy is possible when doing polygon filling (used blitter for line drawing IIRC).
Hi, I have the repository https://github.com/niklasekstrom/blitter-subpixel-line that was mentioned above.

I just updated it with the document "Sub-pixel accurate rasterization of polygons using the Amiga blitter.pdf" that describes how to calculate the values that the blitter should be programmed with in order to do sub-pixel accurate rasterization. It builds on the document "Drawing lines using the Amiga blitter.pdf" so you probably have to read both documents to understand what is going on, but as you have already gotten line drawing using the blitter to work you will probably understand most things quickly.

I'm happy to answer any questions!
Niklas is offline  
Old 25 April 2018, 15:21   #18
ross
Per aspera ad astra

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 49
Posts: 1,993
Quote:
Originally Posted by Niklas View Post
Hi, I have the repository https://github.com/niklasekstrom/blitter-subpixel-line that was mentioned above.

I just updated it with the document "Sub-pixel accurate rasterization of polygons using the Amiga blitter.pdf" that describes how to calculate the values that the blitter should be programmed with in order to do sub-pixel accurate rasterization. It builds on the document "Drawing lines using the Amiga blitter.pdf" so you probably have to read both documents to understand what is going on, but as you have already gotten line drawing using the blitter to work you will probably understand most things quickly.

I'm happy to answer any questions!
Hi Niklas and välkommen

Your documents are a good read, thanks!

[EDIT]
Are you the ex-user Scali?
http://eab.abime.net/showthread.php?t=62607

Last edited by ross; 25 April 2018 at 15:36.
ross is offline  
Old 25 April 2018, 19:51   #19
Niklas
Registered User

 
Join Date: Apr 2018
Location: Stockholm / Sweden
Posts: 47
Quote:
Originally Posted by ross View Post
Hi Niklas and välkommen

Your documents are a good read, thanks!

[EDIT]
Are you the ex-user Scali?
http://eab.abime.net/showthread.php?t=62607
Hi, and thanks

I'm not Scali.
Niklas is offline  
Old 25 April 2018, 20:45   #20
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,238
Quote:
Originally Posted by ross View Post
Are you the ex-user Scali?
Scali is located in Neverlands , not in Sweden.
StingRay 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 mode examples? LuigiThirty Coders. Asm / Hardware 4 17 August 2017 08:26
Fast Blitter Line Clipping 71M Coders. Asm / Hardware 2 03 March 2014 22:33
Clipping line for blitter fill leonard Coders. Asm / Hardware 12 27 April 2013 12:03
Drawing a line... Lonewolf10 Coders. Tutorials 24 06 September 2011 00:46
Line mode blitter absence Coders. General 4 25 September 2009 20:50

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 10:36.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Page generated in 0.08958 seconds with 14 queries