Example

Fader in/out effect

7

Jeanmilost 2022-03-27 20:42

Hello everyone,

Here is a small SDK I use for my own projects, which provides a small fade in/out transition effect, typically to switch between 2 screens. I used it for example in my Trapped! game (https://lowresnx.inutilis.com/topic.php?id=2126) to change to the next room after the player enters in a door.

The core of this tiny SDK is a color blender function I adapted from my c++ code. The idea behind is very simple: you divide your source and destination colors in RGB components, and for each component, you apply the following formula:
Cd = Cs + ((Cd - Cs) * blend_offset)
Where blend_offset is a value between 0.0 and 1.0, Cs is the source component, and Cd is the destination component. As LowResNX provides only 4 tones for each component, Cs and Cd are values between 0 and 3.

Note that contrary to many 8 bit systems, a such effect is possible with LowResNX because the colors aren’t just referenced by an index in a palette, instead they can be divided in RGB component, and a component may be set independently of each other, due to the manner they are handled in the memory.

And voila 😎 I hope this code may serve for everyone. Feel free to use it!

Fader In Out.nx | Open in app
2022-03-27 20:42

Timo 2022-03-27 21:18

There are a few 8-bit systems with dynamic RGB palettes: Game Boy Color, Game Gear, Master System, PC Engine (?)


Timo 2022-03-27 21:19 (Edited)

I changed this to "Example" (Programming example, code snippet, subprogram library)


Jeanmilost 2022-03-29 01:03

@Timo yep, you’re right. It’s because I never tried to code on these consoles, only on computers like the Amstrad or the C64, on which the colors were based on an index. On these systems a such effect was not really easy to reach. That's what I was trying to say 🙂


Log in to reply.