Log In  

Cart [#32320#] | Code | 2016-11-08 | License: CC4-BY-NC-SA | Embed

A simple demo program that contains a function to dim the palette (By swapping the colors around, sort of like the fade out effect in Jelpi).
If this is far overcomplicated, please tell me.
Z: Show palette only (Fullscreen palette)
X: Show demo scene (Minimize palette)
Left: Brightest (Normal colors)
Right: Med-bright
Up: Med-dark
Down: Darkest

The "Darkest" option isn't pure black or even just before pure black, but if you are so inclined you can likely easily add some more settings if you need them.

Use the function in any of your games or projects, if you feel like using it. The demo graphics are from games I've made (And one I'm currently making, which inspired me to make this), so I ask that you don't use the demo graphics.

I'm sure this isn't the absolute end-all be-all for this, you could probably tweak and improve this one vastly, but it's basic enough. My most major concern is the size of the function, which I vaguely think I could shrink somehow.

P#32321 2016-11-07 22:12 ( Edited 2017-09-17 08:44)


(I know this was almost a year ago)

I found this useful, and wanted to share my shorter version... probably long simple to you, but I'm just messing around :)

function setpal(x)
 for c=1,16 do

basically, use a lookup table for each brightness level, rather than a big if/else tree...

P#44230 2017-09-16 01:16 ( Edited 2017-09-16 05:16)
:: Felice

Another option, if you're willing to use some of your cart data instead of source code, is to put your palette in, say, sprite ram and then simply memcpy() it direct to the pseudo-memory-registers that pal() sets up at 0x5f00..0x5f0f.

You don't have to use sprite mem, mind you, but it's handy because you can see your colors in the editor. You just have to remember that each entry in the 0x5f0n registers is a full byte, so it's two pixels in the sprite editor. You need to leave every second pixel black. Alternatively, you can mark transparent colors by setting those black pixels dark blue instead, since palt() marks transparent colors by setting the upper nybble to 1.

Also, if you need to reset the palette to default 0-15, just call pal() with no arguments. It's really fast.

Edit: here, I redid the original cart with this method to better illustrate, since I know I suck at explaining things:

Cart [#44239#] | Code | 2017-09-16 | License: CC4-BY-NC-SA | Embed

P#44238 2017-09-16 11:25 ( Edited 2017-09-16 16:00)

this is pretty sweet... I know it's old, but I'm new around here lol

P#44241 2017-09-16 12:16 ( Edited 2017-09-16 16:16)

Wow, I didn't expect to see people respond to this post this long afterward. Anyway, both of your suggestions (as in accidental's and Felice's) are way better than what I was trying to do. Thanks, now I don't have to worry about eating up every last token just to dim the screen!

P#44254 2017-09-16 21:46 ( Edited 2017-09-17 01:46)
:: Felice

Someone I knew once said something along these lines:

"You know, you'd think our favorite thing as programmers would be creating code, but every programmer I know actually prefers deleting it."

I like that concept. :)

P#44263 2017-09-17 04:44 ( Edited 2017-09-17 08:44)

[Please log in to post a comment]

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-09-19 13:37 | 0.024s | 4194k | Q:40