English Amiga Board


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

 
 
Thread Tools
Old 24 January 2020, 12:02   #1
MickGyver
Registered User

MickGyver's Avatar
 
Join Date: Oct 2008
Location: Finland
Posts: 556
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?
MickGyver is offline  
Old 24 January 2020, 14:44   #2
timeslip1974
Registered User
 
Join Date: Feb 2019
Location: uk
Posts: 67
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
timeslip1974 is offline  
Old 24 January 2020, 16:07   #3
MickGyver
Registered User

MickGyver's Avatar
 
Join Date: Oct 2008
Location: Finland
Posts: 556
Quote:
Originally Posted by timeslip1974 View Post
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
Thanks for the answer! I saw that question and though I could use the same function, but looking at the fadepalette function it seems to be able to only fade to/from black. I want to fade between the colours of two different palettes. In my case I would want to fade between "day" and "night" palettes.
MickGyver is offline  
Old 30 January 2020, 22:01   #4
Cobe
Registered User

 
Join Date: Jan 2014
Location: Belgrade / Serbia
Age: 37
Posts: 749
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)...
Cobe is offline  
Old 31 January 2020, 12:10   #5
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 4,686
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...
Daedalus is offline  
Old 31 January 2020, 13:25   #6
Cobe
Registered User

 
Join Date: Jan 2014
Location: Belgrade / Serbia
Age: 37
Posts: 749
I just tried that and AGARed/Blue/Green wont give values - no object found...
What should I peek ($dff182...)
Cobe is offline  
Old 31 January 2020, 14:17   #7
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 4,686
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.
Daedalus is offline  
Old 31 January 2020, 23:44   #8
Cobe
Registered User

 
Join Date: Jan 2014
Location: Belgrade / Serbia
Age: 37
Posts: 749
ah seems like a lot to digest.. tnx, I'll probably take the second route
Cobe is offline  
Old 31 January 2020, 23:59   #9
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 4,686
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.
Daedalus is offline  
Old 01 February 2020, 10:00   #10
Cobe
Registered User

 
Join Date: Jan 2014
Location: Belgrade / Serbia
Age: 37
Posts: 749
Great! I have it. Thanks for the tip.
Cobe is offline  
Old 01 February 2020, 14:18   #11
MickGyver
Registered User

MickGyver's Avatar
 
Join Date: Oct 2008
Location: Finland
Posts: 556
Thank you for the help Daedalus! Will try something out.
MickGyver is offline  
Old 01 February 2020, 17:42   #12
Cobe
Registered User

 
Join Date: Jan 2014
Location: Belgrade / Serbia
Age: 37
Posts: 749
worked a treat for me.
I'm fading progresivly one playfield from light/pale to full color.
Cobe 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
Help With Palettes Havie Coders. Blitz Basic 4 28 August 2018 00:09
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

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:24.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Page generated in 0.11955 seconds with 16 queries