Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Vanilla

Reply
 
Thread Tools Display Modes
Old January 22, 2022, 23:42   #1
smbhax
Adept
 
Join Date: Oct 2021
Location: WA
Posts: 211
smbhax is on a distinguished road
Can get a nice dark brown text color in Zangband, but not in Angband

Was messing with a Curses build of Zangband in an xterm256 Cygwin terminal and noticed that when I compiled it with the colors from a color scheme I'd cooked up in Angband's color editor popped into its src/variable.c color table

Code:
	{0x00, 0x00, 0x00, 0x00},	/* TERM_DARK */
	{0x00, 0xDD, 0xDC, 0xAD},	/* TERM_WHITE */
	{0x00, 0x84, 0x57, 0x2C},	/* TERM_SLATE */
	{0x00, 0xFF, 0x80, 0x00},	/* TERM_ORANGE */
	{0x00, 0xC0, 0x00, 0x00},	/* TERM_RED */
	{0x00, 0x00, 0x80, 0x40},	/* TERM_GREEN */
	{0x00, 0x00, 0x40, 0xFF},	/* TERM_BLUE */
	{0x00, 0x80, 0x40, 0x00},	/* TERM_UMBER */
	{0x00, 0x5E, 0x3D, 0x06},	/* TERM_L_DARK */
	{0x00, 0xE7, 0xC3, 0x43},	/* TERM_L_WHITE */
	{0x00, 0xFF, 0x00, 0xFF},	/* TERM_VIOLET */
	{0x00, 0xFF, 0xFF, 0x00},	/* TERM_YELLOW */
	{0x00, 0xFF, 0x40, 0x40},	/* TERM_L_RED */
	{0x00, 0x00, 0xFF, 0x00},	/* TERM_L_GREEN */
	{0x00, 0x00, 0xD6, 0xDF},	/* TERM_L_BLUE */
	{0x00, 0xC0, 0x80, 0x40}	/* TERM_L_UMBER */
the colors came out much richer than in Angband. Even if I similarly compile them into Angband's src/z-color.c color table, whereas they come out in these nice dark browns in Zangband



they come out in much less saturated browns in Angband



And messing with them in Angband's color editor, I just plain can't get it to give me a nice rich brown color: it jumps between rather icky dark green-brown, or weirdly dark yellow brown, and so forth.

There seems to be some kind of severe color rounding-off going on in Angband. I wonder if this is absolutely necessary? Ie, would it be possible to have, in Angband, what appears to be possible in Zangband, namely access to full 24-bit color values, without them being approximated to some much more limited palette instead?
__________________
My roguelike gameplay videos
smbhax is offline   Reply With Quote
Old January 23, 2022, 00:18   #2
Nick
Vanilla maintainer
 
Nick's Avatar
 
Join Date: Apr 2007
Location: Canberra, Australia
Age: 56
Posts: 9,320
Donated: $60
Nick will become famous soon enoughNick will become famous soon enough
The get_color() function in z-color.c has a comment:
Code:
 * TODO: Honour the attribute for the term (full color, mono, 16 color) but
 * ensure that e.g. the lighter version of yellow becomes white in a 16 color
 * term, but light yellow in a full colour term.
which may be relevant. I note too that the curses port doesn't use gamma correction (where x11 and Windows do), but it doesn't in Z either.

Worth noting also that I know next to nothing about colors
__________________
One for the Dark Lord on his dark throne
In the Land of Mordor where the Shadows lie.
Nick is offline   Reply With Quote
Old January 23, 2022, 00:43   #3
Pete Mack
Prophet
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 6,670
Donated: $40
Pete Mack is on a distinguished road
What nick said. Depending on the screen, i sometimes set TERM_BLUE to royal blue for visibility. Blue on black or vice versa is notoriously hard to perceive.
Pete Mack is offline   Reply With Quote
Old January 23, 2022, 02:05   #4
smbhax
Adept
 
Join Date: Oct 2021
Location: WA
Posts: 211
smbhax is on a distinguished road
Quote:
Originally Posted by Nick View Post
The get_color() function in z-color.c has a comment:
Code:
 * TODO: Honour the attribute for the term (full color, mono, 16 color) but
 * ensure that e.g. the lighter version of yellow becomes white in a 16 color
 * term, but light yellow in a full colour term.
which may be relevant. I note too that the curses port doesn't use gamma correction (where x11 and Windows do), but it doesn't in Z either.

Worth noting also that I know next to nothing about colors
Quote:
Originally Posted by Pete Mack View Post
What nick said. Depending on the screen, i sometimes set TERM_BLUE to royal blue for visibility. Blue on black or vice versa is notoriously hard to perceive.
The colors behave much differently in a 16-color xterm console--the editor doesn't work at all, but you can get exact 24-bit color values by setting them in your console emulator's options--so I think this is a different thing. For instance, in an xterm256 console, a very dark color like 0x19 0x19 0x19 comes out straight black in the Angband color editor--so this is actually significantly worse in that regard.
__________________
My roguelike gameplay videos
smbhax is offline   Reply With Quote
Old January 23, 2022, 03:41   #5
backwardsEric
Swordsman
 
Join Date: Aug 2019
Posts: 275
backwardsEric is on a distinguished road
Angband's main-gcu.c isn't using curses' init_color() to override the default color table; Zangband's is. That's likely the main cause.

As a side effect of that, Angband's main-gcu.c is, for the 256 color case, dividing the full range for each color component (0 - 255) into 6 bins but the first and last of those bins cover about one half of the range that the others do. Changing scale_color() to be

Code:
static int scale_color(int i, int j, int scale) {
        return (angband_color_table[i][j] * scale) / 256;
}
would give each bin roughly equal weight.

Last edited by backwardsEric; January 23, 2022 at 03:41. Reason: fix typo in Zangband
backwardsEric is offline   Reply With Quote
Old January 23, 2022, 03:46   #6
smbhax
Adept
 
Join Date: Oct 2021
Location: WA
Posts: 211
smbhax is on a distinguished road
(^ Didn't see backwardsEric's reply before I posted this.)

Angband's src/main-gcu.c has this section

Code:
static int scale_color(int i, int j, int scale) {
	return (angband_color_table[i][j] * (scale - 1) + 127) / 255;
}

static int create_color(int i, int scale) {
	int r = scale_color(i, 1, scale);
	int g = scale_color(i, 2, scale);
	int b = scale_color(i, 3, scale);
	int rgb = 16 + scale * scale * r + scale * g + b;

	/* In the case of white and black we need to use the ANSI colors */
	if (r == g && g == b) {
		if (b == 0) rgb = 0;
		if (b == scale) rgb = 15;
	}

	return rgb;
}


/**
 * Adjust the color tables if there's more than 16 available.
 */
static void handle_extended_color_tables(void) {
#ifdef A_COLOR
	if (COLORS == 256 || COLORS == 88) {
		/* If we have more than 16 colors, find the best matches. These numbers
		 * correspond to xterm/rxvt's builtin color numbers--they do not
		 * correspond to curses' constants OR with curses' color pairs.
		 *
		 * XTerm has 216 (6*6*6) RGB colors, with each RGB setting 0-5.
		 * RXVT has 64 (4*4*4) RGB colors, with each RGB setting 0-3.
		 *
		 * Both also have the basic 16 ANSI colors, plus some extra grayscale
		 * colors which we do not use.
		 */
		int i;
		int scale = COLORS == 256 ? 6 : 4;

		bg_color = create_color(COLOUR_DARK, scale);
		for (i = 0; i < BASIC_COLORS; i++) {
			int fg = create_color(i, scale);
			int isbold = bold_extended ? A_BRIGHT : A_NORMAL;
			init_pair(i + 1, fg, bg_color);
			colortable[i] = COLOR_PAIR(i + 1) | isbold;
			init_pair(BASIC_COLORS + i, fg, fg);
			same_colortable[i] = COLOR_PAIR(BASIC_COLORS + i) | isbold;
		}

		for (i = 0; i < term_count; ++i) {
			if (data[i].win) {
				wbkgdset(data[i].win, ' ' |
					colortable[COLOUR_DARK]);
			}
		}
		if (data[0].win) {
			/*
			 * Adjust the background color on the standard screen
			 * as well so separators between the terminals have
			 * the same background as the rest.
			 */
			chtype term0_bkg = getbkgd(data[0].win);

			if (getbkgd(stdscr) != term0_bkg) {
				wbkgd(stdscr, term0_bkg);
				wrefresh(stdscr);
			}
		}
	}
#endif
}
Zangband has this in about the same place:

Code:
static errr Term_xtra_gcu_react(void)
{
#ifdef A_COLOR

	int i;

	/* Cannot handle color redefinition */
	if (!can_fix_color) return (0);

	/* Set the colors */
	for (i = 0; i < 16; i++)
	{
		/* Set one color (note scaling) */
		init_color(i, angband_color_table[i][1] * 1000 / 255,
		              angband_color_table[i][2] * 1000 / 255,
		              angband_color_table[i][3] * 1000 / 255);
	}

#endif

	/* Success */
	return (0);
}
So it looks like there's a lot of color scaling going on that wasn't in Zangband. There are no doubt good reasons for it, but it does seem to be making it hard to get true colors in Angband's terminal.
__________________
My roguelike gameplay videos

Last edited by smbhax; January 23, 2022 at 03:58.
smbhax is offline   Reply With Quote
Old January 23, 2022, 05:26   #7
smbhax
Adept
 
Join Date: Oct 2021
Location: WA
Posts: 211
smbhax is on a distinguished road
Quote:
Originally Posted by backwardsEric View Post
Angband's main-gcu.c isn't using curses' init_color() to override the default color table; Zangband's is. That's likely the main cause.

As a side effect of that, Angband's main-gcu.c is, for the 256 color case, dividing the full range for each color component (0 - 255) into 6 bins but the first and last of those bins cover about one half of the range that the others do. Changing scale_color() to be

Code:
static int scale_color(int i, int j, int scale) {
        return (angband_color_table[i][j] * scale) / 256;
}
would give each bin roughly equal weight.
I tried that but wasn't able to notice a difference in the colors available.
__________________
My roguelike gameplay videos

Last edited by smbhax; January 23, 2022 at 06:00.
smbhax is offline   Reply With Quote
Old January 23, 2022, 06:00   #8
smbhax
Adept
 
Join Date: Oct 2021
Location: WA
Posts: 211
smbhax is on a distinguished road
Out of curiosity, I tried swapping the three color-handling sections from Zangband's main-gcu.c into Angband's...which got me Angband reduced to 16 colors, which doesn't work too well with modern Angband. ; ) Ah well.
__________________
My roguelike gameplay videos
smbhax is offline   Reply With Quote
Old January 23, 2022, 07:38   #9
Bill Peterson
Adept
 
Join Date: Jul 2007
Location: Flyover country
Posts: 158
Bill Peterson is on a distinguished road
Send a message via AIM to Bill Peterson
Using the Windows version I find that umber text is virtually illegible. I switch it light umber.
Bill Peterson is offline   Reply With Quote
Old January 23, 2022, 08:39   #10
smbhax
Adept
 
Join Date: Oct 2021
Location: WA
Posts: 211
smbhax is on a distinguished road
Quote:
Originally Posted by Bill Peterson View Post
Using the Windows version I find that umber text is virtually illegible. I switch it light umber.
Yeah recall text doesn't usually use Umber in Vanilla as far as I've seen, so it caught me a bit by surprise in Zangband.
__________________
My roguelike gameplay videos
smbhax is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Monster Experience Points Color Too Dark Egavactip Vanilla 0 October 17, 2020 18:44
Adding color rooms to Angband droof Vanilla 63 April 8, 2020 10:07
[Poschengband 7.0.0] Any way to change the text color? Qyx Variants 5 August 31, 2017 22:43
Angband color rooms t4nk Development 3 December 10, 2016 01:36
[npp 0.5.4] text color issue ghengiz Development 17 March 4, 2012 22:53


All times are GMT +1. The time now is 06:47.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, vBulletin Solutions Inc.