17 April 2018, 20:38 | #1 |
Registered User
Join Date: Mar 2018
Location: Prague
Posts: 35
|
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. |
17 April 2018, 20:50 | #2 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,865
|
First question that springs to mind (without checking the code): is blitter DMA enabled?
|
17 April 2018, 22:38 | #3 |
Registered User
Join Date: Mar 2018
Location: Prague
Posts: 35
|
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? |
17 April 2018, 22:44 | #4 |
Registered User
Join Date: Mar 2018
Location: Prague
Posts: 35
|
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). |
17 April 2018, 22:52 | #5 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,684
|
Looks like the low byte of BLTCON0 (the minterm) is empty? One normal value is $fa.
|
17 April 2018, 23:05 | #6 |
Registered User
Join Date: Mar 2018
Location: Prague
Posts: 35
|
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). |
18 April 2018, 13:11 | #7 | |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,643
|
Quote:
|
|
18 April 2018, 19:27 | #8 |
Registered User
Join Date: Dec 2017
Location: Denmark
Posts: 179
|
This might be of interest
[ Show youtube player ] With asm source here: https://github.com/niklasekstrom/blitter-subpixel-line |
18 April 2018, 20:06 | #9 |
Registered User
Join Date: Mar 2018
Location: Prague
Posts: 35
|
@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 |
20 April 2018, 21:11 | #10 |
Registered User
Join Date: Mar 2018
Location: Prague
Posts: 35
|
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? |
20 April 2018, 21:17 | #11 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,865
|
There is no built-in hardware support for clipping lines. Go and code your clipping routine.
|
20 April 2018, 23:49 | #12 |
Registered User
Join Date: Mar 2018
Location: Prague
Posts: 35
|
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) |
21 April 2018, 07:31 | #13 |
Registered User
Join Date: Dec 2017
Location: Denmark
Posts: 179
|
|
21 April 2018, 12:26 | #14 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,865
|
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.
|
21 April 2018, 18:01 | #15 |
Registered User
Join Date: Dec 2017
Location: Denmark
Posts: 179
|
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.
|
22 April 2018, 20:09 | #16 | |
Registered User
Join Date: Mar 2018
Location: Prague
Posts: 35
|
Quote:
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. |
|
25 April 2018, 14:50 | #17 | |
Registered User
Join Date: Apr 2018
Location: Stockholm / Sweden
Posts: 129
|
Quote:
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! |
|
25 April 2018, 15:21 | #18 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,498
|
Quote:
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. |
|
25 April 2018, 19:51 | #19 | |
Registered User
Join Date: Apr 2018
Location: Stockholm / Sweden
Posts: 129
|
Quote:
I'm not Scali. |
|
25 April 2018, 20:45 | #20 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,865
|
|
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 |
|
|