Skip to content

Commit

Permalink
find_special_colors is not platform specific
Browse files Browse the repository at this point in the history
  • Loading branch information
LegalizeAdulthood committed Feb 29, 2024
1 parent 2122b18 commit 2ebf7fd
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 151 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ add_library(libid

common/find_file.cpp headers/find_file.h
common/find_path.cpp headers/find_path.h
common/find_special_colors.cpp headers/find_special_colors.h
common/fractint.cpp
common/framain2.cpp headers/framain2.h
headers/get_ifs_token.h
Expand Down Expand Up @@ -288,6 +289,7 @@ source_group("Source Files/common/plumbing" FILES
source_group("Header Files/common/ui" FILES
headers/find_file.h
headers/find_path.h
headers/find_special_colors.h
headers/fractint.h
headers/framain2.h
headers/get_ifs_token.h
Expand All @@ -311,6 +313,7 @@ source_group("Header Files/common/ui" FILES
source_group("Source Files/common/ui" FILES
common/find_file.cpp
common/find_path.cpp
common/find_special_colors.cpp
common/fractint.cpp
common/framain2.cpp
common/get_key_no_help.cpp
Expand Down
1 change: 1 addition & 0 deletions common/calcfrac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "cmplx.h"
#include "diskvid.h"
#include "drivers.h"
#include "find_special_colors.h"
#include "fpu087.h"
#include "fracsubr.h"
#include "fractalp.h"
Expand Down
1 change: 1 addition & 0 deletions common/editpal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "calcfrac.h"
#include "cmdfiles.h"
#include "drivers.h"
#include "find_special_colors.h"
#include "get_key_no_help.h"
#include "id_data.h"
#include "memory.h"
Expand Down
79 changes: 79 additions & 0 deletions common/find_special_colors.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#include "find_special_colors.h"

#include "port.h"

#include "id_data.h"
#include "rotate.h"

int g_color_dark = 0; // darkest color in palette
int g_color_bright = 0; // brightest color in palette
int g_color_medium = 0; /* nearest to medbright grey in palette
Zoom-Box values (2K x 2K screens max) */

//*************** Function find_special_colors ********************
//
// Find the darkest and brightest colors in palette, and a medium
// color which is reasonably bright and reasonably grey.
//
void find_special_colors()
{
int maxb = 0;
int minb = 9999;
int med = 0;
int maxgun, mingun;

g_color_dark = 0;
g_color_medium = 7;
g_color_bright = 15;

if (g_colors == 2)
{
g_color_medium = 1;
g_color_bright = 1;
return;
}

if (!g_got_real_dac)
return;

for (int i = 0; i < g_colors; i++)
{
const int brt = (int) g_dac_box[i][0] + (int) g_dac_box[i][1] + (int) g_dac_box[i][2];
if (brt > maxb)
{
maxb = brt;
g_color_bright = i;
}
if (brt < minb)
{
minb = brt;
g_color_dark = i;
}
if (brt < 150 && brt > 80)
{
mingun = (int) g_dac_box[i][0];
maxgun = mingun;
if ((int) g_dac_box[i][1] > (int) g_dac_box[i][0])
{
maxgun = (int) g_dac_box[i][1];
}
else
{
mingun = (int) g_dac_box[i][1];
}
if ((int) g_dac_box[i][2] > maxgun)
{
maxgun = (int) g_dac_box[i][2];
}
if ((int) g_dac_box[i][2] < mingun)
{
mingun = (int) g_dac_box[i][2];
}
if (brt - (maxgun - mingun) / 2 > med)
{
g_color_medium = i;
med = brt - (maxgun - mingun) / 2;
}
}
}
}
1 change: 1 addition & 0 deletions common/framain2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "editpal.h"
#include "encoder.h"
#include "evolve.h"
#include "find_special_colors.h"
#include "fracsubr.h"
#include "fractalp.h"
#include "fractype.h"
Expand Down
1 change: 1 addition & 0 deletions common/loadfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "encoder.h"
#include "evolve.h"
#include "find_file.h"
#include "find_special_colors.h"
#include "fracsubr.h"
#include "fractalp.h"
#include "fractype.h"
Expand Down
1 change: 1 addition & 0 deletions common/realdos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "drivers.h"
#include "editpal.h"
#include "find_path.h"
#include "find_special_colors.h"
#include "fractalp.h"
#include "fractype.h"
#include "get_key_no_help.h"
Expand Down
1 change: 1 addition & 0 deletions common/stereo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "decoder.h"
#include "drivers.h"
#include "encoder.h"
#include "find_special_colors.h"
#include "gifview.h"
#include "helpdefs.h"
#include "id_data.h"
Expand Down
7 changes: 7 additions & 0 deletions headers/find_special_colors.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

extern int g_color_dark; // darkest color in palette
extern int g_color_bright; // brightest color in palette
extern int g_color_medium; // nearest to medbright grey in palette Zoom-Box values (2K x 2K screens max)

void find_special_colors();
1 change: 0 additions & 1 deletion headers/prototyp.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
extern void spindac(int dir, int inc);
extern void put_line(int row, int startcol, int stopcol, BYTE const *pixels);
extern void get_line(int row, int startcol, int stopcol, BYTE *pixels);
extern void find_special_colors();
extern long readticker();
extern int get_sound_params();
extern void setnullvideo();
Expand Down
75 changes: 0 additions & 75 deletions unix/video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ void (*lineread)(int y, int x, int lastx, BYTE *pixels); // read-a-line
int videoflag = 0; // special "your-own-video" flag

void (*swapsetup)() = nullptr; // setfortext/graphics setup routine
int g_color_dark = 0; // darkest color in palette
int g_color_bright = 0; // brightest color in palette
int g_color_medium = 0; /* nearest to medbright grey in palette
Zoom-Box values (2K x 2K screens max) */
int g_row_count = 0; // row-counter for decoder and out_line
int video_type = 0; /* actual video adapter type:
0 = type not yet determined
Expand Down Expand Up @@ -538,77 +534,6 @@ SetupShadowVideo()
return 0;
}

/*
; *************** Function find_special_colors ********************
; Find the darkest and brightest colors in palette, and a medium
; color which is reasonably bright and reasonably grey.
*/
void
find_special_colors()
{
int maxb = 0;
int minb = 9999;
int med = 0;
int maxgun, mingun;
int brt;

g_color_dark = 0;
g_color_medium = 7;
g_color_bright = 15;

if (g_colors == 2)
{
g_color_medium = 1;
g_color_bright = 1;
return;
}

if (!(g_got_real_dac || g_fake_lut))
return;

for (int i = 0; i < g_colors; i++)
{
brt = (int) g_dac_box[i][0] + (int) g_dac_box[i][1] + (int) g_dac_box[i][2];
if (brt > maxb)
{
maxb = brt;
g_color_bright = i;
}
if (brt < minb)
{
minb = brt;
g_color_dark = i;
}
if (brt < 150 && brt > 80)
{
mingun = (int) g_dac_box[i][0];
maxgun = mingun;
if ((int) g_dac_box[i][1] > (int) g_dac_box[i][0])
{
maxgun = (int) g_dac_box[i][1];
}
else
{
mingun = (int) g_dac_box[i][1];
}
if ((int) g_dac_box[i][2] > maxgun)
{
maxgun = (int) g_dac_box[i][2];
}
if ((int) g_dac_box[i][2] < mingun)
{
mingun = (int) g_dac_box[i][2];
}
if (brt - (maxgun - mingun) / 2 > med)
{
g_color_medium = i;
med = brt - (maxgun - mingun) / 2;
}
}
}
}

/*
; *************** Functions get_a_char, put_a_char ********************
Expand Down
75 changes: 0 additions & 75 deletions win32/os_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,8 @@ enum fractint_event
};

// Global variables (yuck!)
int g_color_dark = 0; // darkest color in palette
int g_color_bright = 0; // brightest color in palette
int g_color_medium = 0; /* nearest to medbright grey in palette
Zoom-Box values (2K x 2K screens max) */
int dacnorm = 0;
int g_dac_count = 0;
bool fake_lut = false;
int g_fm_attack = 0;
int g_fm_decay = 0;
int g_fm_release = 0;
Expand Down Expand Up @@ -171,76 +166,6 @@ long stackavail()
return WIN32_STACK_SIZE - (long)(((char *) g_tos) - &junk);
}

/*
; *************** Function find_special_colors ********************
; Find the darkest and brightest colors in palette, and a medium
; color which is reasonably bright and reasonably grey.
*/
void
find_special_colors()
{
int maxb = 0;
int minb = 9999;
int med = 0;
int maxgun, mingun;

g_color_dark = 0;
g_color_medium = 7;
g_color_bright = 15;

if (g_colors == 2)
{
g_color_medium = 1;
g_color_bright = 1;
return;
}

if (!(g_got_real_dac || fake_lut))
return;

for (int i = 0; i < g_colors; i++)
{
const int brt = (int) g_dac_box[i][0] + (int) g_dac_box[i][1] + (int) g_dac_box[i][2];
if (brt > maxb)
{
maxb = brt;
g_color_bright = i;
}
if (brt < minb)
{
minb = brt;
g_color_dark = i;
}
if (brt < 150 && brt > 80)
{
mingun = (int) g_dac_box[i][0];
maxgun = mingun;
if ((int) g_dac_box[i][1] > (int) g_dac_box[i][0])
{
maxgun = (int) g_dac_box[i][1];
}
else
{
mingun = (int) g_dac_box[i][1];
}
if ((int) g_dac_box[i][2] > maxgun)
{
maxgun = (int) g_dac_box[i][2];
}
if ((int) g_dac_box[i][2] < mingun)
{
mingun = (int) g_dac_box[i][2];
}
if (brt - (maxgun - mingun) / 2 > med)
{
g_color_medium = i;
med = brt - (maxgun - mingun) / 2;
}
}
}
}

int get_sound_params()
{
// TODO
Expand Down

0 comments on commit 2ebf7fd

Please sign in to comment.