// Copyright 1998 Acorn Computers Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "h.palgen.udpalette"
#include "display.h"

palhdr_t&
palhdr_t::operator =(const palhdr_t& p_tab)
{
  int i;
  version = p_tab.version;
  pal256  = p_tab.pal256;
  for (i = 0; i < 5; i++){
  	small_ht[i] = p_tab.small_ht[i];
  	large_ht[i] = p_tab.large_ht[i];
  }
  caltables = p_tab.caltables;
  invpal    = p_tab.invpal;
  ucr 	    = p_tab.ucr;
  reproinfo = p_tab.reproinfo;

  return *this;
}

void
calib_table::copy_calib(const calib_t& c_tab)
{
  tab.calib.ediff_density = c_tab.ediff_density;

  tab.calib.red_adj_my = c_tab.red_adj_my;
  tab.calib.green_adj_cy = c_tab.green_adj_cy;
  tab.calib.blue_adj_cm = c_tab.blue_adj_cm;

  tab.calib.bright[0] = c_tab.bright[0];
  tab.calib.bright[1] = c_tab.bright[1];
  tab.calib.contrast = c_tab.contrast;

  tab.calib.gamma[0] = c_tab.gamma[0];
  tab.calib.gamma[1] = c_tab.gamma[1];
  tab.calib.gamma[2] = c_tab.gamma[2];
  tab.calib.gamma[3] = c_tab.gamma[3];

  tab.calib.deplete1ink[0] = c_tab.deplete1ink[0];
  tab.calib.deplete1ink[1] = c_tab.deplete1ink[1];
  tab.calib.deplete1ink[2] = c_tab.deplete1ink[2];
  tab.calib.deplete1ink[3] = c_tab.deplete1ink[3];
  tab.calib.deplete2ink = c_tab.deplete2ink;
  tab.calib.deplete3ink = c_tab.deplete3ink;

  tab.calib.k_gcr[0] = c_tab.k_gcr[0];
  tab.calib.k_gcr[1] = c_tab.k_gcr[1];
  tab.calib.k_gen[0] = c_tab.k_gen[0];
  tab.calib.k_gen[1] = c_tab.k_gen[1];
  tab.calib.k_mnz = c_tab.k_mnz;
}

calib_table&
calib_table::operator =(const calib_table& t_tab)
{
  TRACE("copying the table");
  char buffer[1024];
  int i;
  tab.ediff_density = t_tab.tab.ediff_density;
  tab.calib = t_tab.tab.calib;

  for (i=0; i<256;i++){
  	tab.cyanED[i] 		= t_tab.tab.cyanED[i];
   	tab.magentaED[i] 	= t_tab.tab.magentaED[i];
   	tab.yellowED[i] 	= t_tab.tab.yellowED[i];
   	tab.cyanHT[i] 		= t_tab.tab.cyanHT[i];
   	tab.magentaHT[i] 	= t_tab.tab.magentaHT[i];
   	tab.yellowHT[i]		= t_tab.tab.yellowHT[i];
  	tab.greyED[i] 		= t_tab.tab.greyED[i];
   	tab.greyHT[i] 		= t_tab.tab.greyHT[i];
    	tab.kGCR_kgen[i] 	= t_tab.tab.kGCR_kgen[i];
   	tab.Cmin_M_Y[i] 	= t_tab.tab.Cmin_M_Y[i];
   	tab.Mmin_C_Y[i] 	= t_tab.tab.Mmin_C_Y[i];
   	tab.Ymin_C_M[i] 	= t_tab.tab.Ymin_C_M[i];
  }
   for (i=256;i<512;i++){
   	tab.kGCR_kgen[i] 	= t_tab.tab.kGCR_kgen[i];
   	tab.Cmin_M_Y[i] 	= t_tab.tab.Cmin_M_Y[i];
   	tab.Mmin_C_Y[i] 	= t_tab.tab.Mmin_C_Y[i];
   	tab.Ymin_C_M[i] 	= t_tab.tab.Ymin_C_M[i];
   }
  debug_calib(&tab.calib, buffer);
  TRACE("%s",buffer);
  return *this;
}

void
calib_table::set_default_calib(void)
{
  copy_calib(default_ca);
}
