diff options
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/cmd4.c | 70 | ||||
-rw-r--r-- | src/externs.h | 9 | ||||
-rw-r--r-- | src/maid-x11.c | 39 | ||||
-rw-r--r-- | src/main-gtk2.c | 160 | ||||
-rw-r--r-- | src/main-win.c | 60 | ||||
-rw-r--r-- | src/util.c | 101 | ||||
-rw-r--r-- | src/variable.c | 11 |
8 files changed, 0 insertions, 451 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 660008e0..c93bebd6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,6 @@ IF(CMAKE_COMPILER_IS_GNUCC) ENDIF() # Add definitions. -ADD_DEFINITIONS(-DSUPPORT_GAMMA) ADD_DEFINITIONS(-DUSE_PRECISE_CMOVIE) # @@ -2586,9 +2586,6 @@ void do_cmd_colors(void) prt("(1) Load a user pref file", 4, 5); prt("(2) Dump colors", 5, 5); prt("(3) Modify colors", 6, 5); -# ifdef SUPPORT_GAMMA - prt("(4) Gamma correction", 7, 5); -# endif /* SUPPORT_GAMMA */ /* Prompt */ prt("Command: ", 8, 0); @@ -2757,73 +2754,6 @@ void do_cmd_colors(void) } } -# ifdef SUPPORT_GAMMA - - /* Gamma correction */ - else if (i == '4') - { - int gamma; - - /* Prompt */ - prt("Command: Gamma correction", 8, 0); - - /* gamma_val isn't set - assume 1.0 */ - if (gamma_val == 0) gamma = 10; - - /* It's set - convert to usual notation (times 10) */ - else gamma = 2560 / gamma_val; - - /* Hack -- query until done */ - while (1) - { - /* Clear */ - clear_from(10); - - /* Exhibit the normal colors */ - for (i = 0; i < 16; i++) - { - /* Exhibit all colors */ - Term_putstr(i*4, 22, -1, i, format("%3d", i)); - } - - /* Describe the gamma */ - Term_putstr(5, 10, -1, TERM_WHITE, - format("Gamma = %d.%d", gamma / 10, gamma % 10)); - - /* Prompt */ - Term_putstr(0, 12, -1, TERM_WHITE, "Command (g/G): "); - - /* Get a command */ - i = inkey(); - - /* All done */ - if (i == ESCAPE) break; - - /* Analyze */ - if (i == 'g') gamma = (byte)(gamma + 1); - else if (i == 'G') gamma = (byte)(gamma - 1); - else continue; - - /* Force limits ([1.0, 2.5]) */ - if (gamma < 10) gamma = 10; - if (gamma > 25) gamma = 25; - - /* Hack - 1.0 means no correction */ - if (gamma == 10) gamma_val = 0; - - /* otherwise, calculate gamma_val */ - else gamma_val = 2560 / gamma; - - /* Hack -- react to changes */ - Term_xtra(TERM_XTRA_REACT, 0); - - /* Hack -- redraw */ - Term_redraw(); - } - } - -# endif /* SUPPORT_GAMMA */ - /* Unknown option */ else { diff --git a/src/externs.h b/src/externs.h index f7f97b79..f5def42d 100644 --- a/src/externs.h +++ b/src/externs.h @@ -1702,15 +1702,6 @@ extern int stricmp(cptr a, cptr b); extern int usleep(huge usecs); #endif -#ifdef SUPPORT_GAMMA -/* util.c */ -extern void build_gamma_table(int gamma); -extern byte gamma_table[256]; - -/* variable.c */ -extern u16b gamma_val; -#endif - #ifdef MACINTOSH /* main-mac.c */ /* extern void main(void); */ diff --git a/src/maid-x11.c b/src/maid-x11.c index 2cdb9da6..86df2119 100644 --- a/src/maid-x11.c +++ b/src/maid-x11.c @@ -63,11 +63,6 @@ ((unsigned)(keysym) >= 0xFF00) -#ifdef SUPPORT_GAMMA -static bool_ gamma_table_ready = FALSE; -#endif /* SUPPORT_GAMMA */ - - /* * Hack -- Convert an RGB value to an X11 Pixel, or die. */ @@ -79,40 +74,6 @@ static unsigned long create_pixel(Display *dpy, byte red, byte green, byte blue) XColor xcolour; -#ifdef SUPPORT_GAMMA - static u16b old_gamma_val = 0; - - - /* React to change in the gamma value */ - if (gamma_val != old_gamma_val) - { - /* Temporarily inactivate the gamma table */ - gamma_table_ready = FALSE; - - /* Only need to build the table if gamma exists */ - if (gamma_val) - { - /* Rebuild the table */ - build_gamma_table(gamma_val); - - /* We can use gamma_table[] now */ - gamma_table_ready = TRUE; - } - - /* Remember the gamma value */ - old_gamma_val = gamma_val; - } - - /* Hack -- Gamma Correction */ - if (gamma_table_ready) - { - red = gamma_table[red]; - green = gamma_table[green]; - blue = gamma_table[blue]; - } - -#endif /* SUPPORT_GAMMA */ - /* Build the color */ xcolour.red = red * 255 + red; diff --git a/src/main-gtk2.c b/src/main-gtk2.c index 86404429..4830638a 100644 --- a/src/main-gtk2.c +++ b/src/main-gtk2.c @@ -52,9 +52,6 @@ * ZAngband has its own enhanced main-gtk.c as mentioned above, and * you *should* use it :-) * - * ANG291_COMPAT does not include Angband 2.9.x's gamma correction code. - * If you like to use SUPPORT_GAMMA, copy the code bracketed - * inside of #ifdef SUPPORT_GAMMA in util.c of Angband 2.9.1 or greater. */ #define TOME @@ -62,7 +59,6 @@ # define ANG293_COMPAT /* Requires V2.9.3 compatibility code */ # define ANG291_COMPAT /* Requires V2.9.1 compatibility code */ # define ANG281_RESET_VISUALS /* The old style reset_visuals() */ -# define INTERACTIVE_GAMMA /* Supports interactive gamma correction */ # define SAVEFILE_SCREEN /* New/Open integrated into the game */ # define USE_DOUBLE_TILES /* Mogami's bigtile patch */ #endif /* TOME */ @@ -381,118 +377,6 @@ static vptr hook_ralloc(huge size) /**** Low level routines - colours and graphics ****/ -#ifdef SUPPORT_GAMMA - -/* - * When set to TRUE, indicates that we can use gamma_table - */ -static bool_ gamma_table_ready = FALSE; - - -# ifdef INTERACTIVE_GAMMA - -/* - * Initialise the gamma-correction table for current gamma_val - * - interactive version - */ -static void setup_gamma_table(void) -{ - static u16b old_gamma_val = 0; - - /* Don't have to rebuild the table */ - if (gamma_val == old_gamma_val) return; - - /* Temporarily inactivate the table */ - gamma_table_ready = FALSE; - - /* Validate gamma_val */ - if ((gamma_val <= 0) || (gamma_val >= 256)) - { - /* Reset */ - old_gamma_val = gamma_val = 0; - - /* Leave it inactive */ - return; - } - - /* (Re)build the gamma table */ - build_gamma_table(gamma_val); - - /* Remember the gamma value used */ - old_gamma_val = gamma_val; - - /* Activate the table */ - gamma_table_ready = TRUE; -} - -# else /* INTERACTIVE_GAMMA */ - -/* - * Initialise the gamma-correction table if environment variable - * ANGBAND_X11_GAMMA is set and contains a meaningful value - * - * Restored for cross-variant compatibility - */ -static void setup_gamma_table(void) -{ - cptr tmp; - int gamma_val; - - - /* The table's already set up */ - if (gamma_table_ready) return; - - /* - * XXX XXX It's documented nowhere, but ANGBAND_X11_GAMMA is - * 256 * (1 / gamma), rounded to integer. A recommended value - * is 183, which is an approximation of the Macintosh hardware - * gamma of 1.4. - * - * gamma ANGBAND_X11_GAMMA - * ----- ----------------- - * 1.2 213 - * 1.25 205 - * 1.3 197 - * 1.35 190 - * 1.4 183 - * 1.45 177 - * 1.5 171 - * 1.6 160 - * 1.7 151 - * ... - * - * XXX XXX The environment variable, or better, - * the interact with colours command should allow users - * to specify gamma values (or gamma value * 100). - */ - tmp = getenv("ANGBAND_X11_GAMMA"); - - /* Nothing to do */ - if (tmp == NULL) return; - - /* Extract the value */ - gamma_val = atoi(tmp); - - /* - * Only need to build the table if gamma exists and set to - * a meaningful value. - * - * XXX It may be a good idea to prevent use of very high gamma values, - * say, greater than 2.5, which is gamma of normal CRT display IIRC. - */ - if ((gamma_val <= 0) || (gamma_val >= 256)) return; - - /* Build the gamma correction table */ - build_gamma_table(gamma_val); - - /* The table is properly set up */ - gamma_table_ready = TRUE; -} - -# endif /* INTERACTIVE_GAMMA */ - -#endif /* SUPPORT_GAMMA */ - /* * Remeber RGB values for sixteen Angband colours, in a format @@ -509,13 +393,6 @@ static void init_colours(void) int i; -#ifdef SUPPORT_GAMMA - - /* (Re)build gamma table if necessary */ - setup_gamma_table(); - -#endif /* SUPPORT_GAMMA */ - /* Process each colour */ for (i = 0; i < 16; i++) { @@ -526,18 +403,6 @@ static void init_colours(void) green = angband_color_table[i][2]; blue = angband_color_table[i][3]; -#ifdef SUPPORT_GAMMA - - /* Hack -- Gamma Correction */ - if (gamma_table_ready) - { - red = gamma_table[red]; - green = gamma_table[green]; - blue = gamma_table[blue]; - } - -#endif /* SUPPORT_GAMMA */ - /* Remember a GdkRGB value, that is 0xRRGGBB */ angband_colours[i] = (red << 16) | (green << 8) | blue; } @@ -1044,18 +909,6 @@ static void put_rgb_scan( g = (scan[xi].green + adj) / div; b = (scan[xi].blue + adj) / div; -#ifdef SUPPORT_GAMMA - - /* Apply gamma correction if requested and available */ - if (gamma_table_ready) - { - r = gamma_table[r]; - g = gamma_table[g]; - b = gamma_table[b]; - } - -#endif /* SUPPORT_GAMMA */ - /* Make a (virtual) 24-bit pixel */ pix = (r << 16) | (g << 8) | (b); @@ -1312,19 +1165,6 @@ static void copy_pixels( /* Copy to the image */ for (i = 0; i < wid; i++) { -#ifdef SUPPORT_GAMMA - - if (gamma_table_ready) - { - *dst++ = gamma_table[src[3 * xoffsets[i]]]; - *dst++ = gamma_table[src[3 * xoffsets[i] + 1]]; - *dst++ = gamma_table[src[3 * xoffsets[i] + 2]]; - - continue; - } - -#endif /* SUPPORT_GAMMA */ - *dst++ = src[3 * xoffsets[i]]; *dst++ = src[3 * xoffsets[i] + 1]; *dst++ = src[3 * xoffsets[i] + 2]; diff --git a/src/main-win.c b/src/main-win.c index 7cbebcf2..92a2a775 100644 --- a/src/main-win.c +++ b/src/main-win.c @@ -992,12 +992,6 @@ static void save_prefs(void) strcpy(buf, arg_sound ? "1" : "0"); WritePrivateProfileString("Angband", "Sound", buf, ini_file); -#ifdef SUPPORT_GAMMA - /* Save the "gamma_val" */ - sprintf(buf, "%d", gamma_val); - WritePrivateProfileString("Angband", "GammaVal", buf, ini_file); -#endif /* SUPPORT_GAMMA */ - /* Save window prefs */ for (i = 0; i < MAX_TERM_DATA; ++i) { @@ -1064,11 +1058,6 @@ static void load_prefs(void) /* Extract the "arg_sound" flag */ arg_sound = (GetPrivateProfileInt("Angband", "Sound", 0, ini_file) != 0); -#ifdef SUPPORT_GAMMA - /* Extract the "gamma_val" */ - gamma_val = GetPrivateProfileInt("Angband", "GammaVal", 0, ini_file); -#endif /* SUPPORT_GAMMA */ - /* Load window prefs */ for (i = 0; i < MAX_TERM_DATA; ++i) { @@ -1574,16 +1563,6 @@ static errr Term_user_win(int n) } -#ifdef SUPPORT_GAMMA - -/* - * When set to TRUE, indicates that we can use gamma_table - */ -static bool_ gamma_table_ready = FALSE; - -#endif /* SUPPORT_GAMMA */ - - /* * React to global changes */ @@ -1612,33 +1591,6 @@ static errr Term_xtra_win_react(void) bool_ change = FALSE; -#ifdef SUPPORT_GAMMA - - static u16b old_gamma_val = 0; - - - /* React to change in the gamma value */ - if (gamma_val != old_gamma_val) - { - /* Temporarily inactivate the gamma table */ - gamma_table_ready = FALSE; - - /* Only need to build the table if gamma exists */ - if (gamma_val) - { - /* Rebuild the table */ - build_gamma_table(gamma_val); - - /* Activate the table */ - gamma_table_ready = TRUE; - } - - /* Remember the gamma value used */ - old_gamma_val = gamma_val; - } - -#endif /* SUPPORT_GAMMA */ - /* Save the default colors */ for (i = 0; i < 256; i++) { @@ -1647,18 +1599,6 @@ static errr Term_xtra_win_react(void) gv = angband_color_table[i][2]; bv = angband_color_table[i][3]; -#ifdef SUPPORT_GAMMA - - /* Hack - Gamma correction */ - if (gamma_table_ready) - { - rv = gamma_table[rv]; - gv = gamma_table[gv]; - bv = gamma_table[bv]; - } - -#endif /* SUPPORT_GAMMA */ - /* Extract a full color code */ code = PALETTERGB(rv, gv, bv); @@ -4239,107 +4239,6 @@ cptr get_player_race_name(int pr, int ps) return (buf); } -#ifdef SUPPORT_GAMMA - -/* Table of gamma values */ -byte gamma_table[256]; - -/* Table of ln(x / 256) * 256 for x going from 0 -> 255 */ -static const s16b gamma_helper[256] = -{ - 0, -1420, -1242, -1138, -1065, -1007, -961, -921, -887, -857, -830, - -806, -783, -762, -744, -726, -710, -694, -679, -666, -652, -640, - -628, -617, -606, -596, -586, -576, -567, -577, -549, -541, -532, - -525, -517, -509, -502, -495, -488, -482, -475, -469, -463, -457, - -451, -455, -439, -434, -429, -423, -418, -413, -408, -403, -398, - -394, -389, -385, -380, -376, -371, -367, -363, -359, -355, -351, - -347, -343, -339, -336, -332, -328, -325, -321, -318, -314, -311, - -308, -304, -301, -298, -295, -291, -288, -285, -282, -279, -276, - -273, -271, -268, -265, -262, -259, -257, -254, -251, -248, -246, - -243, -241, -238, -236, -233, -231, -228, -226, -223, -221, -219, - -216, -214, -212, -209, -207, -205, -203, -200, -198, -196, -194, - -192, -190, -188, -186, -184, -182, -180, -178, -176, -174, -172, - -170, -168, -166, -164, -162, -160, -158, -156, -155, -153, -151, - -149, -147, -146, -144, -142, -140, -139, -137, -135, -134, -132, - -130, -128, -127, -125, -124, -122, -120, -119, -117, -116, -114, - -112, -111, -109, -108, -106, -105, -103, -102, -100, -99, -97, -96, - -95, -93, -92, -90, -89, -87, -86, -85, -83, -82, -80, -79, -78, - -76, -75, -74, -72, -71, -70, -68, -67, -66, -65, -63, -62, -61, - -59, -58, -57, -56, -54, -53, -52, -51, -50, -48, -47, -46, -45, - -44, -42, -41, -40, -39, -38, -37, -35, -34, -33, -32, -31, -30, - -29, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, - -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1 -}; - - -/* - * Build the gamma table so that floating point isn't needed. - * - * Note gamma goes from 0->256. The old value of 100 is now 128. - */ -void build_gamma_table(int gamma) -{ - int i, n; - - /* - * value is the current sum. - * diff is the new term to add to the series. - */ - long value, diff; - - /* Hack - convergence is bad in these cases. */ - gamma_table[0] = 0; - gamma_table[255] = 255; - - for (i = 1; i < 255; i++) - { - /* - * Initialise the Taylor series - * - * value and diff have been scaled by 256 - */ - n = 1; - value = 256 * 256; - diff = ((long)gamma_helper[i]) * (gamma - 256); - - while (diff) - { - value += diff; - n++; - - /* - * Use the following identiy to calculate the gamma table. - * exp(x) = 1 + x + x^2/2 + x^3/(2*3) + x^4/(2*3*4) +... - * - * n is the current term number. - * - * The gamma_helper array contains a table of - * ln(x/256) * 256 - * This is used because a^b = exp(b*ln(a)) - * - * In this case: - * a is i / 256 - * b is gamma. - * - * Note that everything is scaled by 256 for accuracy, - * plus another factor of 256 for the final result to - * be from 0-255. Thus gamma_helper[] * gamma must be - * divided by 256*256 each itteration, to get back to - * the original power series. - */ - diff = (((diff / 256) * gamma_helper[i]) * (gamma - 256)) / (256 * n); - } - - /* - * Store the value in the table so that the - * floating point pow function isn't needed. - */ - gamma_table[i] = ((long)(value / 256) * i) / 256; - } -} - -#endif /* SUPPORT_GAMMA */ - /* * Ask to select an item in a list */ diff --git a/src/variable.c b/src/variable.c index 2757d2f6..0eb0fadf 100644 --- a/src/variable.c +++ b/src/variable.c @@ -604,17 +604,6 @@ byte angband_color_table[256][4] = }; -#ifdef SUPPORT_GAMMA - -/* - * Gamma correction - gamma_val == (int)(256 / gamma) - * The value of 0 means no gamma correction (== 1.0) - */ -u16b gamma_val; - -#endif /* SUPPORT_GAMMA */ - - /* * Standard sound names */ |