Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

TIC-80

Fantasy computer for making, playing and sharing tiny games. · By Nesbox

Changing color palette in game?

A topic by bearknuckles created Sep 23, 2017 Views: 2,544 Replies: 4
Viewing posts 1 to 4

hey, crazy idea I had.

Anybody got any ideas for how to change the color palette in game?

Like logging the desired RGB values in a table, then changing a single palette slot when certain things happens. Like making your character turn gradually greener the longer they've been poisoned.


The uses seem pretty huge. What do you guys think?

(1 edit)

Did a little bit of research... Looks like you could use the"poke" command to write data directly to the RAM address : 03FC0. Which is where the palette data is.

I don't really understand RAM that well, but i would guess it contains the the RBG values in order from 0-15. So maybe you could save the colors as a table of numbers, update it when necessary, and write the whole table to RAM periodically. I'll have to mess around with it some but the code might look something like this:

Color ={
 1st=RGB#forBlack,
 2nd=RGB#forRed,
 3rd=RGB#forBlue,
 etc...............
 --all the way to 16
 }
--if the players skin color is in slot 5 for example...
if p.poisoned==true then
 Color.5th=RGB#forGreen
end
update_colors() --user defined function to write the "Color" table to RAM

You may find this cart very useful by @MonstersGoBoom

https://tic.computer/play?cart=157

Wow... This looks like exactly what I'm looking for! I'm going to have to read through the code seven or twelve times to fully understand it, but it's already answered some questions I had. 


The cart does run pretty slow, but maybe if you're not rewriting the RAM so much it don't take such s performance hit?

Thanks for the reply!

Found something HUUUGE!

I was browsing the GitHub wiki page and found something in the code snippets!

https://github.com/nesbox/TIC-80/wiki/code-examples-and-snippets#pal-function

It's a little function that does exactly what I was talking about! It takes the color index, and the RGB values for the desired color, and modifies the palette. I imported it into one of my scripts and had it running in seconds!! Just leaving this link for anyone interested.