Skip to content

Commit

Permalink
Replace Integer With Strong Enum g_save_dac
Browse files Browse the repository at this point in the history
The business with SaveDAC::NEXT_TIME is a little confusing.
It might be outdated and unnecessary, but for now it remains.
  • Loading branch information
LegalizeAdulthood committed Feb 23, 2025
1 parent 949d23a commit 1dec31c
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
8 changes: 4 additions & 4 deletions libid/fractals/jb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,23 @@ bool julibrot_setup()

if (g_julibrot_3d_mode == Julibrot3DMode::RED_BLUE)
{
g_save_dac = 0;
g_save_dac = SaveDAC::NO;
map_name = g_glasses1_map.c_str();
}
else
{
map_name = g_altern_map_file.c_str();
}
if (g_save_dac != 1)
if (g_save_dac != SaveDAC::YES)
{
if (validate_luts(map_name))
{
return false;
}
spin_dac(0, 1); // load it, but don't spin
if (g_save_dac == 2)
if (g_save_dac == SaveDAC::NEXT_TIME)
{
g_save_dac = 1;
g_save_dac = SaveDAC::YES;
}
}
return true;
Expand Down
9 changes: 8 additions & 1 deletion libid/include/engine/id_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ enum class Resaves
FINAL = 2,
};

enum class SaveDAC
{
NO = 0,
YES = 1,
NEXT_TIME = 2,
};

enum class HelpLabels;

extern int g_adapter; // index into g_video_table[]
Expand Down Expand Up @@ -80,7 +87,7 @@ extern double g_plot_my2;
extern double g_params[];
extern double g_potential_params[];
extern Resaves g_resave_flag;
extern int g_save_dac;
extern SaveDAC g_save_dac;
extern int g_save_system;
extern double g_save_x_3rd;
extern double g_save_x_max;
Expand Down
8 changes: 4 additions & 4 deletions libid/ui/framain2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ MainState big_while_loop(MainContext &context)
g_video_entry.y_dots = g_logical_screen_y_dots;
}

if (g_save_dac || g_colors_preloaded)
if (g_save_dac != SaveDAC::NO || g_colors_preloaded)
{
std::memcpy(g_dac_box, g_old_dac_box, 256*3); // restore the DAC
spin_dac(0, 1);
Expand Down Expand Up @@ -455,13 +455,13 @@ MainState big_while_loop(MainContext &context)
g_logical_screen_y_size_dots = g_logical_screen_y_dots - 1;
}
// assume we save next time (except jb)
g_save_dac = (g_save_dac == 0) ? 2 : 1;
g_save_dac = g_save_dac == SaveDAC::NO ? SaveDAC::NEXT_TIME : SaveDAC::YES;

if (g_show_file == ShowFile::LOAD_IMAGE)
{
// loading an image
g_out_line_cleanup = nullptr; // outln routine can set this
if (g_display_3d != Display3DMode::NONE) // set up 3D decoding
g_out_line_cleanup = nullptr; // outln routine can set this
if (g_display_3d != Display3DMode::NONE) // set up 3D decoding
{
g_out_line = call_line3d;
}
Expand Down
9 changes: 1 addition & 8 deletions libid/ui/history.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,14 +850,7 @@ void restore_history_info(int i)
}
}
spin_dac(0, 1);
if (g_fractal_type == FractalType::JULIBROT)
{
g_save_dac = 0;
}
else
{
g_save_dac = 1;
}
g_save_dac = g_fractal_type == FractalType::JULIBROT ? SaveDAC::NO : SaveDAC::YES;
switch (g_fractal_type)
{
case FractalType::FORMULA:
Expand Down
8 changes: 4 additions & 4 deletions libid/ui/id_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ double g_save_y_min{}, g_save_y_max{}; //
double g_save_x_3rd{}, g_save_y_3rd{}; // displayed screen corners
double g_plot_mx1{}, g_plot_mx2{}; //
double g_plot_my1{}, g_plot_my2{}; // real->screen multipliers
CalcStatus g_calc_status{CalcStatus::NO_FRACTAL}; //
CalcStatus g_calc_status{CalcStatus::NO_FRACTAL}; //
long g_calc_time{}; //
int g_save_dac{}; // save-the-Video DAC flag
SaveDAC g_save_dac{}; // save-the-Video DAC flag
bool g_browsing{}; // browse mode flag
std::string g_file_name_stack[16]{}; // array of file names used while browsing
int g_filename_stack_index{}; //
Expand Down Expand Up @@ -178,7 +178,7 @@ static void main_restart(const int argc, const char *const argv[], MainContext &
driver_create_window();
std::memcpy(g_old_dac_box, g_dac_box, 256 * 3); // save in case colors= present
driver_set_for_text(); // switch to text mode
g_save_dac = 0; // don't save the VGA DAC
g_save_dac = SaveDAC::NO; // don't save the VGA DAC

cmd_files(argc, argv); // process the command-line
do_pause(0); // pause for error msg if not batch
Expand Down Expand Up @@ -294,7 +294,7 @@ static bool main_restore_start(MainContext &context)
context.resume = true;
return true;
}
g_save_dac = 0; // don't save the VGA DAC
g_save_dac = SaveDAC::NO; // don't save the VGA DAC
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions libid/ui/main_menu_switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ static MainState execute_commands(MainContext &context)
g_adapter = g_init_mode;
g_init_mode = -1;
i |= +CmdArgFlags::FRACTAL_PARAM;
g_save_dac = 0;
g_save_dac = SaveDAC::NO;
}
else if (g_colors_preloaded)
{
Expand All @@ -572,7 +572,7 @@ static MainState execute_commands(MainContext &context)
}
else if (i & +CmdArgFlags::RESET) // reset was specified
{
g_save_dac = 0;
g_save_dac = SaveDAC::NO;
}
if (i & +CmdArgFlags::YES_3D)
{
Expand Down
4 changes: 2 additions & 2 deletions libid/ui/menu_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ MainState request_fractal_type(MainContext &context)
if (const int type = get_fract_type(); type >= 0)
{
driver_discard_screen();
g_save_dac = 0;
g_save_dac = SaveDAC::NO;
g_magnitude_calc = true;
g_use_old_periodicity = false;
g_bad_outside = false;
Expand Down Expand Up @@ -187,7 +187,7 @@ MainState requested_video_fn(MainContext &context)
g_adapter = k;
if (g_video_table[g_adapter].colors != g_colors)
{
g_save_dac = 0;
g_save_dac = SaveDAC::NO;
}
g_calc_status = CalcStatus::PARAMS_CHANGED;
context.more_keys = false;
Expand Down

0 comments on commit 1dec31c

Please sign in to comment.