06 November 2019, 12:48 | #1 |
Registered User
Join Date: Jun 2019
Location: Saltdean, United Kingdom
Posts: 146
|
Coplists and Colours
Hello all.
I'm pulling my hair out trying to get BlitzBasic 2.1 to display all the colours I'm using in my bitmap. I'm setting up a copper list using the following: Code:
BitMap #BITMAP_BACKGROUND,320,256,32 BitMap #BITMAP_FOREGROUND,320,256,32 LoadPalette #PALETTE_MAIN,"ADH2:Images/Game/colour_test.iff" AGAPalRGB #PALETTE_MAIN,0,0,0,0 ;force colour 0 from magenta to black LoadBitmap #BITMAP_BACKGROUND,"ADH2:Images/Game/colour_test.iff" LoadBitmap #BITMAP_FOREGROUND,"ADH2:Images/Game/colour_test.iff" COPPERLISTYPE.l=$08 ;bitplanes COPPERLISTYPE+$10 ;smooth-scrolling COPPERLISTYPE+$20 ;dual-playfield COPPERLISTYPE+$1000 ;fetch mode 1 COPPERLISTYPE+$10000 ;AGA colours InitCopList #COPPERLIST_MAIN,44,256,COPPERLISTYPE,8,32,0 VWait 100 BLITZ DisplayPalette #COPPERLIST_MAIN,#PALETTE_MAIN CreateDisplay #COPPERLIST_MAIN While Joyb(0)=0DisplayBitmap #COPPERLIST_MAIN,#BITMAP_FOREGROUND,100,0,#BITMAP_BACKGROUND,0,0 VWaitWend I'm basically trying to create a scrolling background with a static foreground. But the background bitmap only ever shows a total of eight colours - colours 8-15. The foreground bitmap shows sixteen, colours 0-15. Is there something fundamentally wrong with my code above? Does each playfield need its own palette? Or do I not understand how playfields and bitmaps use the palette? Thanks for any assistance, Paul Last edited by amipal; 06 November 2019 at 20:01. |
06 November 2019, 13:13 | #2 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,377
|
How playfields and palettes work is a little confusing on AGA, because by default, the AGA chipset acts like the OCS/ECS for compatibility with software written for OCS/ECS. Under OCS and ECS, the foreground and background can show a maximum of 8 colours each. They're allocated as 0-7 for the foreground and 8-15 for the background.
By default, AGA uses the same registers, but allows more colours. That means that the banks of colours overlap, so colours 0-15 are used for the foreground, and colours 8-23 are used for the background. Older software works just fine with this as a result, and the AGA chipset introduces new functions for moving the second bank around, which allows the background to use other sets of 16 colours. The registers that control the background palette location can be controlled by the DisplayControl command, which adjusts three special registers - BPLCON2, BPLCON3 and BPLCON4. In particular, BPLCON3 is the one that contains some bits to move the palette around - bits 10, 11 and 12 allow you to set a 3-bit value corresponding to the second playfield's palette position within the 256 colour registers. From memory, setting these bits to 001 (bit 10 = 1, bits 11 & 12 = 0) will give you second playfield values at 16-31. You should bear in mind that the rest of the contents of the three registers should be preserved - the default values are given in the Blitz manual page for DisplayControl. |
07 November 2019, 13:22 | #3 | |
Registered User
Join Date: Jun 2019
Location: Saltdean, United Kingdom
Posts: 146
|
Quote:
I'm not entirely sure how I'd implement DisplayControl into my code above. I think I'll need to have a tinker. Otherwise I may investigate other ways to display my "menu" overlay. |
|
07 November 2019, 13:41 | #4 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,377
|
DisplayControls basically just sets the three 16-bit registers to the given values, with the added complexity that the values given for BPLCON2 and BPLCON4 are XOR'ed with the default values. But that means that if you don't need to mess with them, just use 0 and set BPLCON3 to whatever you need. Have a good read of the page on those registers in the Blitz manual.
As a starting point, BPLCON3 defaults as $C00, which is bits 10 and 11 set, all others cleared. (My apologies - this default value means my suggestion of 001 from above was incorrect - 1 needs to be added to the default of 011, which will give you 100). So try setting it to $1000 (or %0001000000000000) instead: Code:
DisplayControls myCopList, 0, $1000, 0 |
07 November 2019, 14:02 | #5 |
Registered User
Join Date: Nov 2015
Location: Vaasa, Finland
Posts: 525
|
Here are DisplayControls values that I have used in my own dual PF programs. I don't know how "right" these values are, but they seem to work OK:
DisplayControls #CoplistID, 0, $1c00, $23 The "$1c00" puts back Playfield colors to 16-31 and the "$23" puts sprite colors to 32-47. This gives you a "real" AGA dual playfield, where you have 16+16 colors, plus a third 16 color set for the sprites, so you'll have 48 colors in total. Just remember to increase the InitCopList color amount to 48 too. Also the first value of DisplayControls, which is now "0", controls where sprites are shown in the playfields. If set to 0, sprites are shown in front of both playfields. But you can set it to "$0004" to put sprites between the two playfields, or to $220 to put sprites behind both playfields. --- Also one thing that I noticed in your code, at these lines: Code:
BitMap #BITMAP_BACKGROUND,320,256,32 BitMap #BITMAP_FOREGROUND,320,256,32 |
10 November 2019, 00:19 | #6 |
Registered User
Join Date: Jun 2019
Location: Saltdean, United Kingdom
Posts: 146
|
Thanks you for your help, chaps. I've now managed to create a 16+16 colour dual-playfield, with a mouse-scrolled background and static "menu" foreground.
I initially had some issues with certain colours flashing on the background, but this was cured by a combination of redoing my palette (background was still choosing foreground colours) and also because I had two entries for the DisplayControls line - oops! I'll post some images once I transfer the SD card that's in my A1200 over to my Mac. :edit Actually, one quick question - since foreground and background only use 16 colours each, I suppose I could drop them from 5-bitplanes to 4-bitplanes? Last edited by amipal; 10 November 2019 at 00:31. |
10 November 2019, 17:15 | #7 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,377
|
Good stuff!
Yep, they'll only use 4 bitplanes for each playfield - after all, there can only be up to 8 bitplanes in total. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Displaying multiple CopLists at once | Graham Humphrey | Coders. Blitz Basic | 4 | 12 May 2017 11:12 |
Something about the colours | Maren | support.WinUAE | 17 | 21 March 2010 12:16 |
wb colours | source | support.Apps | 4 | 31 December 2009 20:00 |
how many colours has the | petza | Amiga scene | 21 | 17 August 2006 11:26 |
Workbench Colours | Djay | support.Apps | 9 | 06 September 2002 14:27 |
|
|