English Amiga Board


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

 
 
Thread Tools
Old 14 June 2020, 07:52   #1
Muzza
Registered User
 
Muzza's Avatar
 
Join Date: Sep 2019
Location: Sydney
Posts: 357
Strange bitplanes/copper alignment problem

Hi,

I have a fairly standard vertical scrolling routine where I use the copper to adjust the bitplanes pointer back to the top of the bitmap at the required scanline. It works like this:

1. Wait Until Line N-1
2. Set BPL1MOD & BPL2MOD (modulo trick to fix the Low Word of the new bitplanes address)
3. Wait Until Line N
4. Set BPL1PTH through BPL8PTH (High words of new bitplanes address)
5. Reset BPL1MOD & BPL2MODback to their normal values.
6. End Copper

Note that this is using AGA, and setting all 8 bitplanes. Also it occurs both on a real A1200 and in an emulator.

I've had this running for months without problem, but recently discovered that it goes wrong when the memory address of the bitplanes is allocated at certain positions in chip ram.
For example, if the bitplanes are allocated at 0xDF404 it works, but if they are at 0xDF944, it fails. When it fails it looks like the copper is failing to set some of the higher bitplane addresses correctly, and I get corruption after the copper split.
I get the same pattern if the bitplanes are allocated at 0xCF404 vs 0xCF944 and 0x2F404 vs 0x2F944 and so on. (first address good, second address bad)

I thought perhaps it was an alignment problem, but aligning the bitplanes pointer to various values makes no difference. I have plugged in loads of addresses to try and find a pattern and gone over my copper code a thousand times. The only reliable (I think) fix I have found is to do this when allocating the chip ram:
bitplanesPtr = bitplanesPtr & 0xfffff0ff
(obviously I have to alloc extra memory to do this adjustment)

This doesn't make any sense to me, and it has been driving me mad the last few days, so I'm hoping someone with more hardware/copper experience can shed some light or give some ideas?
Thanks for reading.
Muzza is offline  
Old 14 June 2020, 11:10   #2
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,335
Looks like race condition between copper and display.
It is possible that BPL1MOD and BPL2MOD are somehow added after some high words of bitplane addresses have been set.

Anyway, it's clear the problem is linked to carry propagation from low word to high word.

Why isn't the modulo enough to fix the address ?
If the difference is never bigger than 32k (a single plane should be smaller than this), then you don't need to touch the high word at all.
meynaf is offline  
Old 14 June 2020, 12:04   #3
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,479
fmode
=?
ross is offline  
Old 14 June 2020, 12:09   #4
Muzza
Registered User
 
Muzza's Avatar
 
Join Date: Sep 2019
Location: Sydney
Posts: 357
Fmode is zero.
Bitmap is interleaved which is why I need the high word.
Muzza is offline  
Old 14 June 2020, 12:23   #5
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,479
Can you post a WinUAE savestate with a non-working example?

On AGA there is some weirdness with high FMODE fetches/alignment/MODULO, but not for FMODE=0 (that I know of..).
See: http://eab.abime.net/showthread.php?t=94943
ross is offline  
Old 14 June 2020, 13:52   #6
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,335
Using 8 bitplanes with fmode=0 is gonna eat all chipmem bandwidth. Probably not the right thing to do.
meynaf is offline  
Old 15 June 2020, 04:37   #7
Muzza
Registered User
 
Muzza's Avatar
 
Join Date: Sep 2019
Location: Sydney
Posts: 357
Thanks for the responses. I investigated various thing based on the above, and have found the problem to be a simple calculation error. My scrolling code was based on the aminet 'ScrollingTrick' examples, and it looks like the bug came from there.

After the copper split, the ScrollingTricks code does this to set the high words of the bitplane addresses.

Code:
	pl = (ULONG)ScreenBitmap->Planes[0] +  planeaddx;

	wp = CopPLANE2_1H;	

	for(i = 0;i < BLOCKSDEPTH;i++)
	{
		wp[1] = (WORD)(pl >> 16);

		pl += BITMAPBYTESPERROW * BLOCKSDEPTH;
		wp += 2;
	}
It advances the bitplane pointer by BITMAPBYTESPERROW * BLOCKSDEPTH where BITMAPBYTESPERROW is BitmapWidth/8 and BLOCKSDEPTH is the number of bitplanes.

It should actually advance by BITMAPBYTESPERROW, because the bitmap is interleaved.

When the number of bitplanes is only 5, and the bitmap is allocated at certain addresses, the error does not show, as the high word of the calculation comes out correct, even when the rest of it is wrong.

As I upped the bitplanes to 8, and moved the bitmap pointer, the bug showed itself. Can't believe how long it took me to find it, but at least it is an easy fix!
Muzza 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
Strange behavior when using blit queue in copper list losso Coders. Asm / Hardware 39 02 February 2018 08:24
Copper Wait Problem sandruzzo support.WinUAE 13 18 May 2016 21:54
Copper Wait Problem sandruzzo Coders. Asm / Hardware 2 17 May 2016 10:30
Copper effect problem Steve support.WinUAE 3 25 June 2011 14:05
Using the Copper to mangle the bitplanes. Andy_C Coders. General 7 16 March 2011 12:58

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 17:25.

Top

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