colourtran 9.95 KB
Newer Older
Neil Turton's avatar
Neil Turton committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/* Copyright 1996 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.
 */
15 16 17 18 19 20 21 22 23 24 25 26 27 28
/************************************************************************/
/*  Acorn Computers Ltd, 1992.                                         */
/*                                                                      */
/* This file forms part of an unsupported source release of RISC_OSLib. */
/*                                                                      */
/* It may be freely used to create executable images for saleable       */
/* products but cannot be sold in source form or as an object library   */
/* without the prior written consent of Acorn Computers Ltd.            */
/*                                                                      */
/* If this file is re-distributed (even if modified) it should retain   */
/* this copyright notice.                                               */
/*                                                                      */
/************************************************************************/

Neil Turton's avatar
Neil Turton committed
29 30 31
/*
 * Title:  colourtran.c
 * Purpose: C interface to the ColourTrans SWIs
32 33
 * History: IDJ: 05-Feb-92: prepared for source release
 *
Neil Turton's avatar
Neil Turton committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
 */

#include <stddef.h>
#include "colourtran.h"
#include "os.h"
#include "wimp.h"

/* -------------------- ColourTrans SWIs -------------------------- */

#define ColourTrans_SelectTable                     0x00040740
#define ColourTrans_SelectGCOLTable                 0x00040741
#define ColourTrans_ReturnGCOL                      0x00040742
#define ColourTrans_SetGCOL                         0x00040743
#define ColourTrans_ReturnColourNumber              0x00040744
#define ColourTrans_ReturnGCOLForMode               0x00040745
#define ColourTrans_ReturnColourNumberForMode       0x00040746
#define ColourTrans_ReturnOppGCOL                   0x00040747
#define ColourTrans_SetOppGCOL                      0x00040748
#define ColourTrans_ReturnOppColourNumber           0x00040749
#define ColourTrans_ReturnOppGCOLForMode            0x0004074a
#define ColourTrans_ReturnOppColourNumberForMode    0x0004074b
#define ColourTrans_GCOLToColourNumber              0x0004074c
#define ColourTrans_ColourNumberToGCOL              0x0004074d
#define ColourTrans_ReturnFontColours               0x0004074e
#define ColourTrans_SetFontColours                  0x0004074f
#define ColourTrans_InvalidateCache                 0x00040750
#define ColourTrans_SetCalibration                  0x00040751
#define ColourTrans_ReadCalibration                 0x00040752
#define ColourTrans_ConvertDeviceColour             0x00040753
#define ColourTrans_ConvertDevicePalette            0x00040754
#define ColourTrans_ConvertRGBToCIE                 0x00040755
#define ColourTrans_ConvertCIEToRGB                 0x00040756

#pragma -s1

os_error *colourtran_select_table (int source_mode,
                                   wimp_paletteword *source_palette,
                                   int dest_mode,
                                   wimp_paletteword *dest_palette,
                                   void *buffer)
{
  os_regset r;
  os_error*e;

  r.r[0] = source_mode;
  r.r[1] = (int)source_palette;
  r.r[2] = dest_mode;
  r.r[3] = (int)dest_palette;
  r.r[4] = (int)buffer;

  e = os_swix(ColourTrans_SelectTable, &r);

  return(e);
}

#ifndef UROM
os_error *colourtran_select_GCOLtable (int source_mode,
                                       wimp_paletteword *source_palette,
                                       int dest_mode,
                                       wimp_paletteword *dest_palette,
                                       void *buffer)
{
  os_regset r;
  os_error *e;

  r.r[0] = source_mode;
  r.r[1] = (int)source_palette;
  r.r[2] = dest_mode;
  r.r[3] = (int)dest_palette;
  r.r[4] = (int)buffer;

  e = os_swix(ColourTrans_SelectGCOLTable, &r);

  return(e);
}
#endif

#ifndef UROM
os_error *colourtran_returnGCOL (wimp_paletteword entry, int *gcol)
{
  os_regset r;
  os_error *e;

  r.r[0] = entry.word;

  e = os_swix(ColourTrans_ReturnGCOL, &r);

  if (e == 0)
    *gcol = r.r[0];

  return(e);
}
#endif

os_error *colourtran_setGCOL (wimp_paletteword entry, int fore_back,
                              int gcol_in, int *gcol_out)
{
  os_regset r;
  os_error *e;

  r.r[0] = entry.word;
  r.r[3] = fore_back & 0x000fffff;
  r.r[4] = gcol_in & 0x000fffff;

  e = os_swix(ColourTrans_SetGCOL, &r);

  if (e == 0)
    *gcol_out = r.r[0];

  return(e);
}

#ifndef UROM
os_error *colourtran_return_colournumber (wimp_paletteword entry, int *col)
{
  os_regset r;
  os_error *e;

  r.r[0] = entry.word;

  e = os_swix(ColourTrans_ReturnColourNumber, &r);

  if (e == 0)
    *col = r.r[0];

  return(e);
}
#endif


os_error *colourtran_return_GCOLformode (wimp_paletteword entry,
                                           int dest_mode,
                                           wimp_paletteword *dest_palette,
                                           int *gcol)
{
  os_regset r;
  os_error *e;

  r.r[0] = entry.word;
  r.r[1] = dest_mode;
  r.r[2] = (int)dest_palette;

  e = os_swix(ColourTrans_ReturnGCOLForMode, &r);

  if (e == 0)
    *gcol = r.r[0];

  return(e);
}


os_error *colourtran_return_colourformode (wimp_paletteword entry,
                                           int dest_mode,
                                           wimp_paletteword *dest_palette,
                                           int *col)
{
  os_regset r;
  os_error *e;

  r.r[0] = entry.word;
  r.r[1] = dest_mode;
  r.r[2] = (int)dest_palette;

  e = os_swix(ColourTrans_ReturnColourNumberForMode, &r);

  if (e == 0)
    *col = r.r[0];

  return(e);
}

#ifndef UROM
os_error *colourtran_return_OppGCOL (wimp_paletteword entry, int *gcol)
{
  os_regset r;
  os_error *e;

  r.r[0] = entry.word;

  e = os_swix(ColourTrans_ReturnOppGCOL, &r);

  if (e == 0)
    *gcol = r.r[0];

  return(e);
}
#endif

#ifndef UROM
os_error *colourtran_setOppGCOL (wimp_paletteword entry, int fore_back,
                                int gcol_in, int *gcol_out)
{
  os_regset r;
  os_error *e;

  r.r[0] = entry.word;
  r.r[3] = fore_back & 0x000fffff;
  r.r[4] = gcol_in & 0x000fffff;

  e = os_swix(ColourTrans_SetOppGCOL, &r);

  if (e == 0)
    *gcol_out = r.r[0];

  return(e);
}
#endif

#ifndef UROM
os_error *colourtran_return_Oppcolournumber (wimp_paletteword entry,
                                            int *col)
{
  os_regset r;
  os_error *e;

  r.r[0] = entry.word;

  e = os_swix(ColourTrans_ReturnOppColourNumber, &r);

  if (e == 0)
    *col = r.r[0];

  return(e);
}
#endif

#ifndef UROM
os_error *colourtran_return_OppGCOLformode (wimp_paletteword entry,
                                            int dest_mode,
                                            wimp_paletteword *dest_palette,
                                            int *gcol)
{
  os_regset r;
  os_error *e;

  r.r[0] = entry.word;
  r.r[1] = dest_mode;
  r.r[2] = (int)dest_palette;

  e = os_swix(ColourTrans_ReturnOppGCOLForMode, &r);

  if (e == 0)
    *gcol = r.r[0];

  return(e);
}
#endif

#ifndef UROM
os_error *colourtran_return_Oppcolourformode (wimp_paletteword entry,
                                              int dest_mode,
                                              wimp_paletteword *dest_palette,
                                              int *col)
{
  os_regset r;
  os_error *e;

  r.r[0] = entry.word;
  r.r[1] = dest_mode;
  r.r[2] = (int)dest_palette;

  e = os_swix(ColourTrans_ReturnOppColourNumberForMode, &r);

  if (e == 0)
    *col = r.r[0];

  return(e);
}
#endif


#ifndef UROM
os_error *colourtran_GCOL_tocolournumber (int gcol, int *col)
{
  os_regset r;
  os_error *e;

  r.r[0] = gcol;

  e = os_swix(ColourTrans_GCOLToColourNumber, &r);

  if (e == 0)
    *col = r.r[0];

  return(e);
}
#endif

#ifndef UROM
Robert Sprowson's avatar
Robert Sprowson committed
323
os_error *colourtran_colournumbertoGCOL (int col, int *gcol)
Neil Turton's avatar
Neil Turton committed
324 325 326 327
{
  os_regset r;
  os_error *e;

Robert Sprowson's avatar
Robert Sprowson committed
328
  r.r[0] = col;
Neil Turton's avatar
Neil Turton committed
329 330 331 332

  e = os_swix(ColourTrans_ColourNumberToGCOL, &r);

  if (e == 0)
Robert Sprowson's avatar
Robert Sprowson committed
333
    *gcol = r.r[0];
Neil Turton's avatar
Neil Turton committed
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420

  return(e);
}
#endif

#ifndef UROM
os_error *colourtran_returnfontcolours (font *handle,
                                        wimp_paletteword *backgnd,
                                        wimp_paletteword *foregnd,
                                        int *max_offset)
{
  os_regset r;
  os_error *e;

  r.r[0] = (int)*handle;
  r.r[1] = backgnd->word;
  r.r[2] = foregnd->word;
  r.r[3] = (int)*max_offset;

  e = os_swix(ColourTrans_ReturnFontColours, &r);

  if (e == 0)
  {
    *handle = r.r[0];
    backgnd->word = r.r[1];
    foregnd->word = r.r[2];
    *max_offset = r.r[3];
  }

  return(e);
}
#endif

os_error *colourtran_setfontcolours (font *handle,
                                     wimp_paletteword *backgnd,
                                     wimp_paletteword *foregnd,
                                     int *max_offset)
{
  os_regset r;
  os_error *e;

  r.r[0] = (int)*handle;
  r.r[1] = backgnd->word;
  r.r[2] = foregnd->word;
  r.r[3] = (int)*max_offset;

  e = os_swix(ColourTrans_SetFontColours, &r);

  if (e == 0)
  {
    *handle = r.r[0];
    backgnd->word = r.r[1];
    foregnd->word = r.r[2];
    *max_offset = r.r[3];
  }

  return(e);
}

#ifndef UROM
os_error *colourtran_invalidate_cache (void)
{
  os_regset r;

  return(os_swix(ColourTrans_InvalidateCache, &r));
}
#endif

os_error *colourtran_convert_device_colour (wimp_paletteword device, wimp_paletteword *rgb)
{
  os_regset r;
  os_error *e;

  r.r[1] = device.word;
  r.r[3] = 0;

  e = os_swix(ColourTrans_ConvertDeviceColour, &r);

  if (e == 0)
    (*rgb).word = r.r[2];

  return e;
}

#pragma -s0

/* end colourtran.c */