19 March 2022, 11:08 | #1 |
Registered User
Join Date: Feb 2022
Location: Athens, Greece
Posts: 41
|
Help with blitter descending mode.
Hi,
I am stuck with how to program the blitter to blit in descending mode. I want to blit a 16x16 bitmap from coordinates X=0,Y=200 to coordinates X=1,Y=220, without a mask. I am correctly setting the bltxpt pointers to the last word of the respective areas, as per the hardware reference manual. I am reversing the shift value, since, in descending mode, the shift is to the left. The blit width is correctly calculated to 2 words. However, despite the above, the blit does not come out right: https://imgbb.com/6rkRf7S I've followed the advice of user roondar (many thanks) in the other thread(https://eab.abime.net/showthread.php?t=109910), but still no good result. Here is the blit function (this is an asm forum section, so I am not asking for corrections on my C code, I am only putting this here for reference; my question is about the blitter operation in descending mode): https://pastebin.com/eiAeXVgm Thanks in advance... Last edited by axilmar; 19 March 2022 at 15:13. |
19 March 2022, 12:03 | #2 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,039
|
X from 0 to 1 is right shift by 1. Typo or ...?
Shift value should be the same if you are shifting by 1 pixel (regardless of direction). |
19 March 2022, 15:15 | #3 | |
Registered User
Join Date: Feb 2022
Location: Athens, Greece
Posts: 41
|
Quote:
The hardware reference manual says shifts are reversed in descending mode, but the blit is not correct with either 1 or 15 as a value (it's not correct for any shift value). |
|
19 March 2022, 16:19 | #4 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,408
|
Yeah, sorry for not having more tips. I did use descending mode before, but I never actually tried shifting data alongside doing so. Hence I never had to work with masks/shifts in descending mode so I don't really know the caveats.
Generally I've just not really needed to use it. |
19 March 2022, 16:20 | #5 |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
To me it looks like your output rectangle isn't in the right place, it looks like it's a word to the right, and then it looks like you're shifting one to the right, but without anywhere for the pixels to go to on the right hand side, so they're wrapping around.
You're losing the top row in the result, I think the calculation for start_y_offshouldn't have a -1 in it. I also question this Code:
const WORD shift = force_desc ? (16 - lshift) : lshift; lshifthas values 0..15, then won't shifttake values 1..16? Could you output all the values you put into the blitter registers for us? Last edited by deimos; 19 March 2022 at 16:51. |
19 March 2022, 20:20 | #6 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
I haven't followed the previous thread but I see no reason why code like this shouldn't work:
Code:
lea ((320/8)*(200+15),a0),a1 lea ((320/8)*(220+15)+2,a0),a2 move.l #$f9f00002,($40,a6) move.l #$ffff0000,($44,a6) move.l a1,($50,a6) move.l a2,($54,a6) move.l #((320-32)/8)<<16+(320-32)/8,($64,a6) move.w #16<<6+2,($58,a6) The descending mode works in a completely opposite way to the ascending mode so in this case the shift must be 15 and include one more word for the fetch, the mask must exclude the second word read and an incremented destination pointer used. That's all PS: if you want I can create a raw executable to test the code. |
20 March 2022, 10:14 | #7 | |
Registered User
Join Date: Feb 2022
Location: Athens, Greece
Posts: 41
|
Quote:
Regarding 16-lshift, you may be correct, it may be 15-lshift. So, if I put 15 - lshift, and try to blit, the blitter values are these, for bitplane 0: bltcon0 = 59338 bltcon1 = 57346 bltbmod = 196 bltcmod = 196 bltdmod = 196 bltafwm = 0 bltalwm = 65535 bltadat = 65535 bltbpt = 0x1f8ea bltcpt = 0x2088a bltdpt = 0x2088a bltsize = 1026 The start of the source image, which is also the screen, and also the destination in this example (because I am trying to blit one part of a bitmap onto itself), is 0x150f0. The result image is this (top row is missing, the image is shifted to the left 14 pixels, the first part of the image that is blitted contains the 2 rightmost image columns, the second part of the image that is blitted contains the 14 left most image columns): https://ibb.co/LJfZQcc The shift value in this case is 14, because x = 1 (shift = 15 - lshift, lshift = 1). Which does not look correct to me, I believe that when x = 1, the shift value for descending mode shall be 15. |
|
20 March 2022, 10:20 | #8 | |
Registered User
Join Date: Feb 2022
Location: Athens, Greece
Posts: 41
|
Quote:
Incrementing the destination ptr by 2 bytes (i.e. 1 word) has the effect of simply displacing the distorted image horizontally by 16 pixels. |
|
20 March 2022, 10:25 | #9 | |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
Quote:
Your blitcon values of 0xE7CA and 0xE002 are a bit different to Ross' of 0xF9F0 and 0x0002. You could try those values, and if it magically works then we know we need to work on your calculations of them. Last edited by deimos; 20 March 2022 at 10:34. |
|
20 March 2022, 10:34 | #10 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
Quote:
Background filled with a pattern so you can view the exact blitter effect for this specific setup. LMB start the blit, another to exit. |
|
20 March 2022, 11:30 | #11 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
Quote:
"I want to blit a 16x16 bitmap from coordinates X=0,Y=200 to coordinates X=1,Y=220, without a mask." So: minterm to do a bare copy, to the right by 1 pixel (16-1 in descending plus extra word and mask) and AD channel enabled +DESC bit. EDIT: I'am now looking at the values used by the user and there are many things wrong As he is using a generic formula with a cookie-cut where the mask is in channel A, he used only the source pointer in B, but channel B does not have a usable mask. In addition, channel C is also active (which does not make sense in this case). Basically is a full cookie-cut blit, with a constant A channel and a wasted active C channel.. What exactly would you like to do? Keep the background too? Last edited by ross; 20 March 2022 at 11:51. |
|
20 March 2022, 12:09 | #12 | |
Registered User
Join Date: Feb 2022
Location: Athens, Greece
Posts: 41
|
Quote:
First, I interpreted the values from the asm code you posted above: Code:
move.l #$f9f00002,($40,a6) //bltcon0/bltcon1;0xf9f0/0x0002; shift = 15/blitreverse move.l #$ffff0000,($44,a6) //bltafwm/bltalwm; 0xffff/0x0000 move.l a1,($50,a6) //bltapt; screen base + (320/8)*(200+15) move.l a2,($54,a6) //bltdpt; screen base + (320/8)*(220+15)+2 move.l #((320-32)/8)<<16+(320-32)/8,($64,a6) //bltamod/bltdmod; 36/36 move.w #16<<6+2,($58,a6) //bltsize; height = 16/width = 2(words) Code:
custom->bltcon0 = (15 << ASHIFTSHIFT) | SRCB | SRCC | DEST | 0xCA; custom->bltcon1 = (15 << BSHIFTSHIFT) | BLITREVERSE; custom->bltbmod = 200-4; custom->bltcmod = 200-4; custom->bltdmod = 200-4; custom->bltafwm = 0xffff; custom->bltalwm = 0x0002; custom->bltadat = 0xFFFF; custom->bltbpt = src->bitplanes[i] + (320/8*5)*(200+15); custom->bltcpt = src->bitplanes[i] + (320/8*5)*(220+15)+2; custom->bltdpt = src->bitplanes[i] + (320/8*5)*(220+15)+2; custom->bltsize = (16<<6)+2; https://ibb.co/6N9jQFV MANY MANY MANY thanks!!!!!!! Now I have to find wtf does my original code do....;-) |
|
20 March 2022, 12:13 | #13 | |
Registered User
Join Date: Feb 2022
Location: Athens, Greece
Posts: 41
|
Quote:
But anyway, thanks for noticing it. For my first Amiga program, I am doing well (I think) (:-)). |
|
20 March 2022, 12:20 | #14 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
|
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 problems | deimos | Coders. General | 23 | 10 October 2019 10:10 |
Blitter line-drawing mode? | E-Penguin | Coders. Blitz Basic | 2 | 13 April 2019 21:37 |
Blitter: clean-up line drawing and fill mode idle cycles. | ross | Coders. Asm / Hardware | 9 | 12 May 2018 22:32 |
Blitter line mode examples? | LuigiThirty | Coders. Asm / Hardware | 4 | 17 August 2017 08:26 |
Line mode blitter | absence | Coders. General | 4 | 25 September 2009 20:50 |
|
|