English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 04 February 2021, 01:09   #1
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,893
AGA Sprite Palette

Help!

So I know that if I use AGA sprites with a dual playfield screen I can use 16+16 colours for the dual screens and as far as I know I can use a different 16 colours for the sprite palette but have no idea how to point the sprites to the correct palette?

I'm guessing it's something to do with Displaycontrols?

Thanks.
Havie is offline  
Old 04 February 2021, 05:18   #2
Cobe
Registered User
 
Join Date: Jan 2014
Location: Belgrade / Serbia
Age: 41
Posts: 999
Yup, I had the same question few years ago
http://eab.abime.net/showpost.php?p=...&postcount=129
Cobe is offline  
Old 04 February 2021, 09:50   #3
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
BPLCON4 is used to select the colour banks used for sprites. Bits 0-3 select the 16-colour bank for odd numbered sprite channels & 16-colour sprites, and bits 4-7 set the bank for even numbered sprite channels. By default, they're both set to bank 1 (to match ECS), so the register will look like %00010001. Bank 2 is colours 32-47, bank 3 is 48-63 and so on.

Last edited by Daedalus; 04 February 2021 at 12:30.
Daedalus is offline  
Old 04 February 2021, 15:32   #4
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,893
Quote:
Originally Posted by Daedalus View Post
BPLCON4 is used to select the colour banks used for sprites. Bits 0-3 select the 16-colour bank for odd numbered sprite channels & 16-colour sprites, and bits 4-7 set the bank for even numbered sprite channels. By default, they're both set to bank 1 (to match ECS), so the register will look like %00010001. Bank 2 is colours 32-47, bank 3 is 48-63 and so on.
Thanks.

Are you saying I can have separate palettes for odd and even sprites - I thought they'd need to share the same palette?

And just to be clear, if I do:

Displaycontrols 0,0,0,%00100010

I will set the sprites to use palette entries 32-47?

Would I need to set up an initial 64 colour palette through the Initcopperlist?

And finally - how do you know this stuff? It's not clear in the manual and I couldn't find it on the Internet!
Havie is offline  
Old 04 February 2021, 15:33   #5
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,893
Quote:
Originally Posted by Cobe View Post
Yup, I had the same question few years ago
http://eab.abime.net/showpost.php?p=...&postcount=129
Yeah - found this but thought it was more to do with DP mode rather than sprites!

I have just about got a handle on most Amiga programming stuff now but palettes are surprisingly complex!
Havie is offline  
Old 04 February 2021, 15:59   #6
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Quote:
Originally Posted by Havie View Post
Are you saying I can have separate palettes for odd and even sprites - I thought they'd need to share the same palette?
It depends on the setup. If you combine sprites to make 15-colour sprites, then they'll share the same palette (the one for odd sprite numbers). And OCS/ECS sprites always share the same palette from 16-31. But 3-colour sprites on AGA can use two separate banks for even and odd channels, with the result that every single sprite can use a different three colours.

Quote:
And just to be clear, if I do:

Displaycontrols 0,0,0,%00100010

I will set the sprites to use palette entries 32-47?
Well, that's the idea, yes... But it's sadly a little more complicated than that. When you use DisplayControls command, the values for BPLCON2 and BPLCON4 are XORed with their default values. So to apply the value you want, you need to XOR it with the default so that it gets XORed back. For example:

Code:
Displaycontrols 0, 0, $c00, Xor($11, %00100010)
$11 is the default value listed in the manual (more on that below), and is the equivalent of the OCS/ECS mode, %00010001. You might find the hex values easier to think about - $22 is bank 2 for even and odd, for example, and $3F is bank 3 for even, bank 15 for odd.

Bizarrely, it appears that BPLCON3 values are directly applied instead of being XORed, so you might find you need to include the default as shown too.

Quote:
Would I need to set up an initial 64 colour palette through the Initcopperlist?
Yes, you need to set the copperlist to have a 64-colour palette and your palette objects need to be large enough too. I'm not sure if 48 can be used, but it might be possible too, saving a few bytes of chip RAM

Quote:
And finally - how do you know this stuff? It's not clear in the manual and I couldn't find it on the Internet!
It's a secret Yeah, the manual isn't that great. It does mention this is how it works, but neglects to give an example showing how to actually deal with the XOR thing, or that BPLCON3 doesn't appear to have this applied. The table from the manual also gives the bit function names of each of the registers, but doesn't give you anything other than "colour offset for even sprites" or something like that, which doesn't really tell you everything. I've explained it in a little more detail on AmigaCoding.com, but it still needs some more detail and examples.

Still, at this level we're dealing with the Amiga hardware directly and not so much with Blitz, so thankfully there are other resources for these details. One such site is amiga-dev.wikidot.com, which covers all the registers in the Amiga Hardware Manual, as well AGA registers that aren't covered in the Hardware Manual. On this page in particular it has some details of the BPLCON4 register, and the hardware page lists all the custom registers with information on each. It's a great website to have bookmarked!

Last edited by Daedalus; 04 February 2021 at 16:05.
Daedalus is offline  
Old 06 February 2021, 11:36   #7
slademania
Registered User
 
slademania's Avatar
 
Join Date: Oct 2019
Location: Spain
Posts: 23
Hi Havie,
In my game projects (that uses the DPF displays) I normally used the following
statement : Displayadjust Copnum, 0, $1c00, $00ee
where "Copnum" is the number of the copperlist initializated with the "InitCoplist" command and this gives me the following color palette:

Foreground playfield -> colours 0 to 15
Background playfield -> colours 16 to 31
Sprite color palette -> colours 240 to 255

I recognize that this command is a bit complicated to handle. I have been playing
with different values ??in bplcon3 and bplcon4 (following the documents on AGA
registers) and I have had quite strange results
slademania is offline  
Old 06 February 2021, 14:40   #8
Cobe
Registered User
 
Join Date: Jan 2014
Location: Belgrade / Serbia
Age: 41
Posts: 999
Quote:
Originally Posted by Havie View Post
Yeah - found this but thought it was more to do with DP mode rather than sprites!

I have just about got a handle on most Amiga programming stuff now but palettes are surprisingly complex!
Ah yes..
Looking at some other my code
Displayadjust Copnum, 0, $1c00, $0033
Would be for 16/16 dpf split and sprite colors from 32 to 48
Cobe is offline  
Old 06 February 2021, 17:44   #9
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Quote:
Originally Posted by slademania View Post
statement : Displayadjust Copnum, 0, $1c00, $00ee
where "Copnum" is the number of the copperlist initializated with the "InitCoplist" command and this gives me the following color palette:

Foreground playfield -> colours 0 to 15
Background playfield -> colours 16 to 31
Sprite color palette -> colours 240 to 255

I recognize that this command is a bit complicated to handle. I have been playing
with different values ??in bplcon3 and bplcon4 (following the documents on AGA
registers) and I have had quite strange results
If you don't XOR the values for BPLCON4, you'll get very strange results. $ee for sprite bank 15 works because it's XORed with the default of $11, resulting in $ff (bank 15 for both even and odd sprites).

Quote:
Originally Posted by Cobe View Post
Ah yes..
Looking at some other my code
Displayadjust Copnum, 0, $1c00, $0033
Would be for 16/16 dpf split and sprite colors from 32 to 48
And the same here - XOR $33 with $11 and you get $22 - bank 2, which is 32-47.
Daedalus is offline  
Old 06 February 2021, 20:00   #10
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,893
Thanks guys - will implement in my SF2 demo code!
Havie is offline  
Old 07 February 2021, 01:52   #11
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,893
Thanks to all your help, I got it working. You guys are stars!

http://eab.abime.net/showpost.php?p=...&postcount=398
Havie is offline  
Old 07 February 2021, 17:55   #12
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,893
Now added an additional background that shows floor effect better:

https://eab.abime.net/zone/Streetfigher2test.adf

You can also chose background with 1 or 2 buttons.

Would like to add a few more moves and get Chunli animated too just too see!
Havie 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
[blitz] InitCopList, dual playfield, AGA - palette question peceha Coders. Blitz Basic 2 15 November 2020 10:33
issue with getting palette for sprite... xboxown Coders. AMOS 2 17 February 2019 14:32
AGA Sprite + Dual Playfield Limits Marle Coders. Blitz Basic 14 12 January 2019 14:14
AGA Palette... how to implement Steve Coders. Asm / Hardware 23 25 November 2018 22:26
Brian the Lion AGA - 1.6.0 sprite not displayed Ian support.WinUAE 2 20 July 2009 11:49

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 05:59.

Top

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