24 January 2020, 12:02 | #1 |
Registered User
Join Date: Oct 2008
Location: Finland
Posts: 643
|
Fade between palettes
Any good ideas (ready made routines etc.) how to fade between two palettes in BB2? I'm using the display library.
Do I need to take the long route and lerp the R,G and B values separately for every colour? |
24 January 2020, 14:44 | #2 |
Registered User
Join Date: Feb 2019
Location: uk
Posts: 106
|
funnily enough I asked exactly the same thing earlier today on the FB group ....heres what I got
Use fadepalette Something like this for fade in (not sure if code is 100% correct) for i = 0 to 50 fadepalette srcpalette, destpalette,i / 50 displaypalette copperlist, destpalette vwait next |
24 January 2020, 16:07 | #3 | |
Registered User
Join Date: Oct 2008
Location: Finland
Posts: 643
|
Quote:
|
|
30 January 2020, 22:01 | #4 |
Registered User
Join Date: Jan 2014
Location: Belgrade / Serbia
Age: 41
Posts: 1,004
|
funnily enough I just needed this, and only long routes come to mind...
Anyone found any elegant way? For me it would even be sufficient if fade palette could be restricted not to change all colors but range(like 0-7)... |
31 January 2020, 12:10 | #5 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,369
|
I'm sure it's something that could be done simply enough with a loop, an array of target values and some quick type variables and calculations. Not particularly elegant or efficient, but simple. It's not that much bigger a deal to create a function that would do it arbitrarily for certain pens and to a single point between the palettes, such that you could perform one step every x frames, for example.
Gah, if only I had the time... |
31 January 2020, 13:25 | #6 |
Registered User
Join Date: Jan 2014
Location: Belgrade / Serbia
Age: 41
Posts: 1,004
|
I just tried that and AGARed/Blue/Green wont give values - no object found...
What should I peek ($dff182...) |
31 January 2020, 14:17 | #7 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,369
|
Hmmm, the AGA* functions will only return values in Amiga mode as far as I remember, since the palette functions of the Display Library are rolled into the Coplist itself, and the commands leverage the OS colour functions to read the required registers. Commodore at the time didn't really want people banging the hadrware for AGA stuff, so didn't document a lot of the mechanisms used.
Accessing registers on AGA machines is more complex unfortunately, which is probably why the Display Library doesn't support them. ECS-style registers are maintained for compatibility, which gives you the upper four bits of the of the first 32 registers ($DFF180-$DFF1BE). To access the other registers and nybbles, you need to use BPLCON3 ($DFF106), which uses certain bits to bank select the extra data. Details are here, but here's the key stuff: Bit 9 (LOCT): Set to 0 first to read/write the high bits of the colour register, then set to 1 to read/write the low bits of the colour register using the same $DFF180-$DFF1BE range of 16-bit registers. Bits 13-15 (BANK0-2): Set to a value between %000 and %111 to select one of 8 banks of 32 pens to address using the same $DFF180-$DFF1BE range of registers. %000 is pens 0-31 like ECS, %001 is pens 32-63, and so on all the way to %111 which is pens 224-255. All other bits should be masked off, and you must deal with the higher bits of the palette register first, then the lower bits. Otherwise, the chipset will emulate ECS and mirror the upper and lower nybbles. To be honest, it might be simpler to directly access the Blitz palette structure (some useful info here, and read and write your values from/to the struct instead, before using DisplayPalette to effect any changes. Last edited by Daedalus; 31 January 2020 at 23:50. |
31 January 2020, 23:44 | #8 |
Registered User
Join Date: Jan 2014
Location: Belgrade / Serbia
Age: 41
Posts: 1,004
|
ah seems like a lot to digest.. tnx, I'll probably take the second route
|
31 January 2020, 23:59 | #9 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,369
|
Actually, looking back at some of my own code, there is a 3rd party library for dealing with palette objects, so while you don't have direct access to the colour registers in the chipset, it might be simpler than directly accessing the struct. It's the RIGfx Library, and is included with the fuller installations of Blitz 2.1 and AmiBlitz 3. If you have that library set up (it might already be included in your Deflibs depending on your setup), the commands you need are:
PaletteInfo <palletnumber> This tells Blitz which palette object number to examine. PalRed(pen) PalGreen(pen) PalBlue(pen) Will then return the ECS-style values of that palette entry, or AGAPalRed(pen) AGAPalGreen(pen) AGAPalBlue(pen) Will return the AGA values of that palette entry. So, you'll need to keep separate palette objects for your current and target palettes, but once nothing else changes the colours (e.g. copper effects, directly accessing the registers), you should have valid values for your current colours in the current palette object. |
01 February 2020, 10:00 | #10 |
Registered User
Join Date: Jan 2014
Location: Belgrade / Serbia
Age: 41
Posts: 1,004
|
Great! I have it. Thanks for the tip.
|
01 February 2020, 14:18 | #11 |
Registered User
Join Date: Oct 2008
Location: Finland
Posts: 643
|
Thank you for the help Daedalus! Will try something out.
|
01 February 2020, 17:42 | #12 |
Registered User
Join Date: Jan 2014
Location: Belgrade / Serbia
Age: 41
Posts: 1,004
|
worked a treat for me.
I'm fading progresivly one playfield from light/pale to full color. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Help With Palettes | Havie | Coders. Blitz Basic | 8 | 04 July 2021 00:08 |
Blink vs Fade | emufan | Coders. C/C++ | 4 | 06 August 2017 15:25 |
Simulating a fade-out on startup | MethodGit | Coders. General | 9 | 08 January 2014 13:30 |
Fade 2 black cheat/bug | DeAdLy_cOoKiE | Nostalgia & memories | 2 | 02 July 2005 12:17 |
Fade to Black - PC | Galahad/FLT | Retrogaming General Discussion | 12 | 25 July 2002 18:15 |
|
|