Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
Data Structures | Macros | Functions | Variables
getami.c File Reference
#include <stdio.h>
#include <intuition/intuition.h>
#include <libraries/dos.h>
#include <exec/types.h>
#include <exec/memory.h>
#include <graphics/gfxbase.h>
#include <graphics/view.h>
#include <iff.h>
#include <rle.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
Include dependency graph for getami.c:

Go to the source code of this file.

Data Structures

struct  cuse
 

Macros

#define MIN(x, y)   ((x) < (y) ? (x) : (y))
 
#define ABS(x)   ((x) >= 0 ? (x) : -(x))
 
#define MAX(x, y)   ((x) > (y) ? (x) : (y))
 
#define index(r, g, b)   ((((r) >> 4) << 8) | (((g) >> 4) << 4) | ((b) >> 4))
 
#define rdist(a, b)   ((ABS (((cusage[a].i >> 8) & 0xf) - ((cusage[b].i >> 8) & 0xf))) * 30)
 
#define gdist(a, b)   ((ABS (((cusage[a].i >> 4) & 0xf) - ((cusage[b].i >> 4) & 0xf))) * 59)
 
#define bdist(a, b)   ((ABS ((cusage[a].i & 0xf) - (cusage[b].i & 0xf))) * 11)
 
#define mapx(x)   (x + offsetx)
 
#define mapy(y)   (sh - (y) - 1 - offsety)
 
#define fmapy(y)   (y + offsety)
 
#define inside(x, y)   ((x) >= 0 && (y) >= 0 && (x) < sw && (y) < sh)
 
#define EXACT(x)   (x)
 
#define RED(x)   ((2 << 4) | x)
 
#define GREEN(x)   ((3 << 4) | x)
 
#define BLUE(x)   ((1 << 4) | x)
 
#define SQ(x)   (SQtmp = (x), SQtmp * SQtmp)
 
#define MAX_X   362
 
#define MAX_Y_NTSC   241
 
#define MAX_Y_PAL   283
 
#define BASENAME(x)
 
#define MENUITEMS   3
 
#define FREQW   148
 
#define FREQH   28
 
#define _abort   CXBRK
 
#define OptSetAPen1(rp, col)   curcol1 = (col); if(curcol1) SetAPen((rp), curcol1)
 
#define OptSetAPen2(rp, col)   curcol2 = (col); if(curcol2) SetAPen((rp), curcol2)
 
#define OptSetAPen3(rp, col)   curcol3 = (col); if(curcol3) SetAPen((rp), curcol3)
 
#define OptWritePixel1(rp, x, y)   if(curcol1) WritePixel((rp), (x), (y))
 
#define OptWritePixel2(rp, x, y)   if(curcol2) WritePixel((rp), (x), (y))
 
#define OptWritePixel3(rp, x, y)   if(curcol3) WritePixel((rp), (x), (y))
 

Functions

struct Window * OpenWindow ()
 
struct ScreenOpenScreen ()
 
struct Library * OpenLibrary ()
 
char * mktemp (char *)
 
rle_pixel ** buildmap ()
 
UBYTE handleIDCMP (void)
 
void main (int, char **)
 
int compare (struct cuse *, struct cuse *)
 
int find_most_used (void)
 
int display_rle (void)
 
void show_rgb (void)
 
int CXBRK (void)
 
void AdjustScreen (register struct Screen *, int *, int *)
 
void save (void)
 
void FixColors (void)
 
void ResetColors (void)
 
int CalcWidth (int)
 
int CalcHAMWidth (int)
 
int CalcHeight (int, int)
 
 if (tfd)
 
 if (w1)
 
 if (w2)
 
 if (w3)
 
 if (s1)
 

Variables

struct GfxBase * GfxBase = ((void *)0)
 
struct IntuitionBase * IntuitionBase = ((void *)0)
 
struct Library * IFFBase = ((void *)0)
 
static struct NewScreen screen
 
static struct Image img
 
static struct Gadget CloseGadget
 
static struct NewWindow window
 
static struct cuse cusage [4096]
 
static struct Window * w1 = ((void *)0)
 
static struct Window * w2 = ((void *)0)
 
static struct Window * w3 = ((void *)0)
 
static struct RastPort * rp1 = ((void *)0)
 
static struct RastPort * rp2 = ((void *)0)
 
static struct RastPort * rp3 = ((void *)0)
 
static struct Screens1 = ((void *)0)
 
static struct Screens2 = ((void *)0)
 
static struct Screens3 = ((void *)0)
 
static struct ViewPort * vp1 = ((void *)0)
 
static struct ViewPort * vp2 = ((void *)0)
 
static struct ViewPort * vp3 = ((void *)0)
 
static rle_pixelsl [3]
 
static rle_pixel ** cmap
 
static unsigned int R [32]
 
static unsigned int G [32]
 
static unsigned int B [32]
 
static char * tfile
 
static char * infile = ((void *)0)
 
static FILE * ifd = ((void *)0)
 
static FILE * tfd = ((void *)0)
 
static int width
 
static int height
 
static int depth
 
static int nused
 
static int sw
 
static int sh
 
static int sd
 
static int isham
 
static int offsetx
 
static int offsety
 
static int bw =0
 
static int threescreens =0
 
static int havereq =0
 
static int havemenu =0
 
static int flip =0
 
static int forceham =0
 
static USHORT * Ptr = ((void *)0)
 
static USHORT RenderPtr []
 
static int SQtmp
 
static struct IntuiText txt []
 
static struct MenuItem actions []
 
static struct Menu menu
 
static char fnam [80] = {'\0'}
 
static char ufnam [80] = {'\0'}
 
static struct StringInfo fgadinfo
 
static struct IntuiText ftxt
 
static SHORT fbcoord [] = {1, 1, 146, 1, 146, 26, 1, 26, 1, 1}
 
static struct Border fbord
 
static struct Gadget fgad
 
static struct Requester freq
 
int curcol1
 
int curcol2
 
int curcol3
 
static int x
 
static int y
 
static unsigned char r
 
static unsigned char g
 
static unsigned char b
 
 int
 

Macro Definition Documentation

#define _abort   CXBRK

Definition at line 208 of file getami.c.

#define ABS (   x)    ((x) >= 0 ? (x) : -(x))

Definition at line 35 of file getami.c.

#define BASENAME (   x)
Value:
(strrchr((x),'/') ? strrchr((x),'/')+1 : \
(strrchr((x),':') ? strrchr((x),':')+1 : (x)))
static int x
Definition: getami.c:691

Definition at line 58 of file getami.c.

#define bdist (   a,
  b 
)    ((ABS ((cusage[a].i & 0xf) - (cusage[b].i & 0xf))) * 11)

Definition at line 42 of file getami.c.

#define BLUE (   x)    ((1 << 4) | x)

Definition at line 51 of file getami.c.

#define EXACT (   x)    (x)

Definition at line 48 of file getami.c.

#define fmapy (   y)    (y + offsety)

Definition at line 46 of file getami.c.

#define FREQH   28

Definition at line 190 of file getami.c.

#define FREQW   148

Definition at line 189 of file getami.c.

#define gdist (   a,
  b 
)    ((ABS (((cusage[a].i >> 4) & 0xf) - ((cusage[b].i >> 4) & 0xf))) * 59)

Definition at line 40 of file getami.c.

#define GREEN (   x)    ((3 << 4) | x)

Definition at line 50 of file getami.c.

#define index (   r,
  g,
  b 
)    ((((r) >> 4) << 8) | (((g) >> 4) << 4) | ((b) >> 4))

Definition at line 37 of file getami.c.

#define inside (   x,
  y 
)    ((x) >= 0 && (y) >= 0 && (x) < sw && (y) < sh)

Definition at line 47 of file getami.c.

#define mapx (   x)    (x + offsetx)

Definition at line 44 of file getami.c.

#define mapy (   y)    (sh - (y) - 1 - offsety)

Definition at line 45 of file getami.c.

#define MAX (   x,
  y 
)    ((x) > (y) ? (x) : (y))

Definition at line 36 of file getami.c.

#define MAX_X   362

Definition at line 54 of file getami.c.

#define MAX_Y_NTSC   241

Definition at line 55 of file getami.c.

#define MAX_Y_PAL   283

Definition at line 56 of file getami.c.

#define MENUITEMS   3

Definition at line 143 of file getami.c.

#define MIN (   x,
  y 
)    ((x) < (y) ? (x) : (y))

Definition at line 34 of file getami.c.

#define OptSetAPen1 (   rp,
  col 
)    curcol1 = (col); if(curcol1) SetAPen((rp), curcol1)

Definition at line 220 of file getami.c.

#define OptSetAPen2 (   rp,
  col 
)    curcol2 = (col); if(curcol2) SetAPen((rp), curcol2)

Definition at line 221 of file getami.c.

#define OptSetAPen3 (   rp,
  col 
)    curcol3 = (col); if(curcol3) SetAPen((rp), curcol3)

Definition at line 222 of file getami.c.

#define OptWritePixel1 (   rp,
  x,
  y 
)    if(curcol1) WritePixel((rp), (x), (y))

Definition at line 224 of file getami.c.

#define OptWritePixel2 (   rp,
  x,
  y 
)    if(curcol2) WritePixel((rp), (x), (y))

Definition at line 225 of file getami.c.

#define OptWritePixel3 (   rp,
  x,
  y 
)    if(curcol3) WritePixel((rp), (x), (y))

Definition at line 226 of file getami.c.

#define rdist (   a,
  b 
)    ((ABS (((cusage[a].i >> 8) & 0xf) - ((cusage[b].i >> 8) & 0xf))) * 30)

Definition at line 38 of file getami.c.

#define RED (   x)    ((2 << 4) | x)

Definition at line 49 of file getami.c.

#define SQ (   x)    (SQtmp = (x), SQtmp * SQtmp)

Definition at line 52 of file getami.c.

Function Documentation

void AdjustScreen ( register struct Screen ,
int ,
int  
)

Definition at line 12 of file AdjustScreen.c.

13 {
14  int c640, c320, r400, r200, w, h, max_x, max_y;
15  struct Preferences prefs;
16  extern struct GfxBase *GfxBase;
17 
18  GetPrefs(&prefs, sizeof(prefs));
19  c640 = 640 + prefs.ColumnSizeChange;
20  c320 = c640 / 2;
21  r200 = 200 + prefs.RowSizeChange;
22  r400 = r200 * 2;
23 
24  max_y = (GfxBase->DisplayFlags & PAL) ? MAX_Y_PAL : MAX_Y_NTSC;
25  if (screen->ViewPort.Modes & LACE){
26  max_y *= 2;
27  }
28  max_x = MAX_X;
29  if (screen->ViewPort.Modes & HIRES){
30  max_x *= 2;
31  }
32  if (screen->ViewPort.DWidth <= max_x) {
33  w = screen->ViewPort.DWidth;
34  }else{
35  w = max_x;
36  }
37  if (screen->ViewPort.DHeight <= max_y) {
38  h = screen->ViewPort.DHeight;
39  }else{
40  h = max_y;
41  }
42 
43  if (screen->ViewPort.Modes & HIRES){
44  if (w > c640) {
45  screen->ViewPort.DxOffset += (c640 - w) / 2;
46  }
47  *dx = screen->ViewPort.DxOffset / 2;
48  }else{
49  if (w > c320) {
50  screen->ViewPort.DxOffset += (c320 - w) / 2;
51  }
52  *dx = screen->ViewPort.DxOffset;
53  }
54  if (screen->ViewPort.Modes & LACE){
55  if (h > r400) {
56  screen->ViewPort.DyOffset += (r400 - h) / 2;
57  }
58  *dy = screen->ViewPort.DyOffset / 2;
59  }else{
60  if (h > r200) {
61  screen->ViewPort.DyOffset += (r200 - h) / 2;
62  }
63  *dy = screen->ViewPort.DyOffset;
64  }
65 
66  RemakeDisplay();
67 }
struct GfxBase * GfxBase
Definition: getami.c:61
static struct NewScreen screen
Definition: getami.c:67
#define MAX_X
Definition: AdjustScreen.c:7
#define MAX_Y_PAL
Definition: AdjustScreen.c:9
int max_y
Definition: unslice.c:42
#define MAX_Y_NTSC
Definition: AdjustScreen.c:8
rle_pixel** buildmap ( )
int CalcHAMWidth ( int  width)

Definition at line 1054 of file getami.c.

1055 {
1056  if (width <= 320) return 320;
1057  return width;
1058 }
static int width
Definition: getami.c:101
int CalcHeight ( int  height,
int  pal 
)

Definition at line 1061 of file getami.c.

1062 {
1063  if (pal) {
1064  if (height <= 256) return 256;
1065  if (height <= MAX_Y_PAL) return height;
1066  if (height <= 512) return 512;
1067  return height;
1068  }else{
1069  if (height <= 200) return 200;
1070  if (height <= MAX_Y_NTSC) return height;
1071  if (height <= 400) return 400;
1072  return height;
1073  }
1074 }
#define MAX_Y_NTSC
Definition: getami.c:55
static int height
Definition: getami.c:101
#define MAX_Y_PAL
Definition: getami.c:56
int CalcWidth ( int  width)

Definition at line 1045 of file getami.c.

1046 {
1047  if (width <= 320) return 320;
1048  if (width <= MAX_X) return width;
1049  if (width <= 640) return 640;
1050  return width;
1051 }
static int width
Definition: getami.c:101
#define MAX_X
Definition: getami.c:54
int compare ( struct cuse a,
struct cuse b 
)

Definition at line 529 of file getami.c.

References cuse::j.

530 {
531  if (a->j < b->j)
532  return 1;
533  else if (a->j > b->j)
534  return -1;
535  else
536  return 0;
537 }
int j
Definition: getami.c:87
int CXBRK ( void  )
int display_rle ( void  )

Definition at line 695 of file getami.c.

References b, cmap, depth, g, height, rle_hdr::ncolors, offsetx, offsety, r, rle_hdr::rle_file, rle_get_setup(), rle_getcom(), rle_getrow(), sh, sl, sw, tfd, width, x, rle_hdr::xmax, rle_hdr::xmin, y, rle_hdr::ymax, and rle_hdr::ymin.

696 {
697  rle_hdr rle_f_hdr;
698  char *como;
699  int ncolors, i, j, packed, pix, col;
700 
701  rle_f_hdr.rle_file = tfd;
702  if (rle_get_setup(&rle_f_hdr) < 0)
703  return -1;
704 
705  RLE_CLR_BIT (rle_f_hdr, RLE_ALPHA);
706  for (i = 3; i < rle_f_hdr.ncolors; i++)
707  RLE_CLR_BIT (rle_f_hdr, i);
708 
709  ncolors = rle_f_hdr.ncolors > 3 ? 3 : rle_f_hdr.ncolors;
710  if (ncolors == 2)
711  return -1;
712 
713  height = rle_f_hdr.ymax - rle_f_hdr.ymin + 1;
714  width = rle_f_hdr.xmax - rle_f_hdr.xmin + 1;
715 
716  depth = 0, packed = 0;
717  if ((como = rle_getcom ("cy_depth", &rle_f_hdr)) != NULL) {
718  depth = atoi (como);
719  if ((como = rle_getcom ("cy_width", &rle_f_hdr)) != NULL)
720  width = atoi (como);
721  como = rle_getcom ("cy_packed", &rle_f_hdr);
722  packed = como ? 1 : 0;
723  }
724  if (!depth)
725  depth = ncolors * 8;
726  offsetx = (sw - width) / 2;
727  offsety = (sh - height) / 2;
728 
729  for (i = 0; i < 3; i++)
730  if ((sl[i] = (rle_pixel *) malloc(rle_f_hdr.xmax -
731  rle_f_hdr.xmin + 1)) == NULL) {
732  for (j = 0; j < i; j++)
733  free ((char *) sl[j]);
734  return -1;
735  }
736 
737  rle_f_hdr.xmax -= rle_f_hdr.xmin, rle_f_hdr.xmin = 0;
738 
739  while ((y = rle_getrow(&rle_f_hdr, sl)) <= rle_f_hdr.ymax) {
740  if (handleIDCMP()) {
741  _abort();
742  }
743  y -= rle_f_hdr.ymin;
744  if (ncolors == 3) {
745  for (x = 0; x < width; x++)
746  r = sl[0][x], g = sl[1][x], b = sl[2][x], show_rgb ();
747  } else if (ncolors == 1 && !packed) {
748  for (x = 0; x < width; x++) {
749  r = cmap[0][sl[0][x]];
750  g = cmap[1][sl[0][x]];
751  b = cmap[2][sl[0][x]];
752  show_rgb ();
753  }
754  } else {
755  for (col = 0, x = 0; x < width; col = (col + 1) & 7, x++) {
756  pix = (sl[0][x / 8] & (1 << (7 - col))) ? 0: 255;
757  r = pix, g = pix, b = pix, show_rgb ();
758  }
759  }
760  }
761  for (i = 0; i < 3; i++)
762  free((char *) sl[i]);
763 
764  return 0;
765 }
static unsigned char g
Definition: getami.c:692
int xmin
Definition: rle.h:100
static int sh
Definition: getami.c:101
char * rle_getcom(const char *name, rle_hdr *the_hdr)
static int depth
Definition: getami.c:101
static int width
Definition: getami.c:101
static unsigned char r
Definition: getami.c:692
void show_rgb(void)
Definition: getami.c:768
static FILE * tfd
Definition: getami.c:100
static int offsety
Definition: getami.c:105
static int height
Definition: getami.c:101
int ymin
Definition: rle.h:100
static rle_pixel ** cmap
Definition: getami.c:97
static int y
Definition: getami.c:691
static int sw
Definition: getami.c:101
static unsigned char b
Definition: getami.c:692
static rle_pixel * sl[3]
Definition: getami.c:96
int rle_get_setup(rle_hdr *the_hdr)
Definition: rle_getrow.c:74
Definition: rle.h:96
int xmax
Definition: rle.h:100
static int x
Definition: getami.c:691
#define _abort
Definition: getami.c:208
#define RLE_CLR_BIT(glob, bit)
Definition: rle.h:124
int ymax
Definition: rle.h:100
unsigned char rle_pixel
Definition: rle.h:56
void * malloc()
int i
Definition: rletorla.c:82
UBYTE handleIDCMP(void)
#define RLE_ALPHA
Definition: rle.h:65
static int offsetx
Definition: getami.c:105
int rle_getrow(rle_hdr *the_hdr, rle_pixel *scanline[])
FILE * rle_file
Definition: rle.h:114
int ncolors
Definition: rle.h:100

Here is the call graph for this function:

int find_most_used ( void  )

Definition at line 540 of file getami.c.

References rle_hdr::alpha, B, rle_hdr::background, buildmap(), bw, cmap, rle_hdr::cmap, rle_hdr::cmaplen, rle_hdr::comments, depth, rle_hdr::dispatch, G, height, cuse::i, ifd, cuse::j, rle_hdr::ncmap, rle_hdr::ncolors, nused, R, rle_dflt_hdr, rle_hdr::rle_file, rle_get_setup(), rle_getcom(), rle_getrow(), rle_put_setup(), rle_putcom(), rle_putrow(), RUN_DISPATCH, sl, tfd, threescreens, width, rle_hdr::xmax, rle_hdr::xmin, rle_hdr::ymax, and rle_hdr::ymin.

541 {
542  rle_hdr rle_f_hdr;
543  char comi[4][100];
544  char *como;
545  unsigned char r, g, b;
546  int ncolors, i, j, x, y, packed, pix, col;
547 
548  rle_f_hdr.rle_file = ifd;
549  if (rle_get_setup(&rle_f_hdr) < 0)
550  return -1;
551 
552  RLE_CLR_BIT (rle_f_hdr, RLE_ALPHA);
553  for (i = 3; i < rle_f_hdr.ncolors; i++)
554  RLE_CLR_BIT (rle_f_hdr, i);
555 
556  ncolors = rle_f_hdr.ncolors > 3 ? 3 : rle_f_hdr.ncolors;
557  if (ncolors == 2)
558  return -1;
559 
560  height = rle_f_hdr.ymax - rle_f_hdr.ymin + 1;
561  width = rle_f_hdr.xmax - rle_f_hdr.xmin + 1;
562 
563  depth = 0, packed = 0;
564  if ((como = rle_getcom ("cy_depth", &rle_f_hdr)) != NULL) {
565  depth = atoi (como);
566  if ((como = rle_getcom ("cy_width", &rle_f_hdr)) != NULL)
567  width = atoi (como);
568  como = rle_getcom ("cy_packed", &rle_f_hdr);
569  packed = como ? 1 : 0;
570  }
571  if (!depth)
572  depth = ncolors * 8;
573 
574  for (i = 0; i < 3; i++)
575  if ((sl[i] = (rle_pixel *) malloc(rle_f_hdr.xmax -
576  rle_f_hdr.xmin + 1)) == NULL) {
577  for (j = 0; j < i; j++)
578  free ((char *) sl[j]);
579  return -1;
580  }
581 
582  rle_f_hdr.xmax -= rle_f_hdr.xmin, rle_f_hdr.xmin = 0;
583 
585  rle_dflt_hdr.alpha = 0;
586  rle_dflt_hdr.background = rle_f_hdr.background;
587  rle_dflt_hdr.ncmap = rle_f_hdr.ncmap;
588  rle_dflt_hdr.cmaplen = rle_f_hdr.cmaplen;
589  rle_dflt_hdr.cmap = rle_f_hdr.cmap;
590  rle_dflt_hdr.comments = NULL;
592  rle_dflt_hdr.xmin = 0;
593  rle_dflt_hdr.xmax = width - 1;
594  rle_dflt_hdr.ymin = 0;
595  rle_dflt_hdr.ymax = height - 1;
596  rle_dflt_hdr.ncolors = ncolors;
597  for (i = 0; i < MIN (3, ncolors); i++)
599  for (i = MIN (3, ncolors); i < ncolors; i++)
602 
603  if (packed) {
604  sprintf (comi[0], "cy_depth=%d", depth), rle_putcom (comi[0], &rle_dflt_hdr);
605  sprintf (comi[1], "cy_width=%d", width), rle_putcom (comi[1], &rle_dflt_hdr);
606  strcpy (comi[2], "cy_packed=1"), rle_putcom (comi[2], &rle_dflt_hdr);
607  }
608 
609  cmap = buildmap (&rle_f_hdr, 3, 1.0, 0.0);
610 
612 
613  while ((y = rle_getrow(&rle_f_hdr, sl)) <= rle_f_hdr.ymax) {
615  y -= rle_f_hdr.ymin;
616  if (ncolors == 3) {
617  for (x = 0; x < width; x++)
618  r = sl[0][x], g = sl[1][x], b = sl[2][x], cusage[index(r, g, b)].j++;
619  } else if (ncolors == 1 && !packed) {
620  for (x = 0; x < width; x++) {
621  r = cmap[0][sl[0][x]];
622  g = cmap[1][sl[0][x]];
623  b = cmap[2][sl[0][x]];
624  cusage[index(r, g, b)].j++;
625  }
626  } else {
627  for (col = 0, x = 0; x < width; col = (col + 1) & 7, x++) {
628  pix = (sl[0][x / 8] & (1 << (7 - col))) ? 0: 255;
629  r = pix, g = pix, b = pix, cusage[index(r, g, b)].j++;
630  }
631  }
632  }
633  for (i = 0; i < 3; i++)
634  free((char *) sl[i]);
635 
636  nused = 0;
637  for (i = 0; i < 4096; i++) {
638  cusage[i].i = i;
639  if (cusage[i].j)
640  nused++;
641  }
642  printf ("colors used: %d\n", nused);
643 
644  qsort ((char *) cusage, 4096, sizeof (struct cuse), compare);
645 
646  if (threescreens) {
647  nused = 16;
648  return 0;
649  }
650  if (bw) {
651  for (i = 0; i < 16; i++) {
652  R[i] = G[i] = B[i] = i;
653  nused = 16;
654  }
655  return 0;
656  }
657  if (nused <= 32) {
658  for (i = 0; i < 32; i++) {
659  R[i] = (cusage[i].i >> 8) & 0xf;
660  G[i] = (cusage[i].i >> 4) & 0xf;
661  B[i] = cusage[i].i & 0xf;
662  }
663  return 0;
664  }
665 
666 #if 0
667  nleft = nused;
668  for (i = nused - 1; i >= 0; i--) {
669  if (nleft <= 16)
670  break;
671  for (j = 0; j < i; j++)
672  if (rdist (i, j) + gdist (i, j) + bdist (i, j) <= 1) {
673  cusage[i].j = 0, nleft--;
674  break;
675  }
676  }
677  printf ("colors left %d\n", nleft);
678 #endif
679 
680  for (i = 0, j = 0; j < 16 && i < nused; i++)
681  if (cusage[i].j) {
682  R[j] = (cusage[i].i >> 8) & 0xf;
683  G[j] = (cusage[i].i >> 4) & 0xf;
684  B[j] = cusage[i].i & 0xf;
685  j++;
686  }
687 
688  return 0;
689 }
static unsigned char g
Definition: getami.c:692
#define RLE_SET_BIT(glob, bit)
Definition: rle.h:122
static unsigned int R[32]
Definition: getami.c:98
#define MIN(x, y)
Definition: getami.c:34
int xmin
Definition: rle.h:100
static int bw
Definition: getami.c:106
const char ** comments
Definition: rle.h:113
char * rle_getcom(const char *name, rle_hdr *the_hdr)
static int threescreens
Definition: getami.c:106
static int depth
Definition: getami.c:101
const char * rle_putcom(const char *value, rle_hdr *the_hdr)
static int width
Definition: getami.c:101
static FILE * ifd
Definition: getami.c:100
static unsigned char r
Definition: getami.c:692
rle_map * cmap
Definition: rle.h:112
void rle_putrow(rle_pixel *rows[], int rowlen, rle_hdr *the_hdr)
#define rdist(a, b)
Definition: getami.c:38
static int nused
Definition: getami.c:101
int j
Definition: getami.c:87
rle_pixel ** buildmap()
rle_hdr rle_dflt_hdr
Definition: rle_global.c:66
static FILE * tfd
Definition: getami.c:100
static int height
Definition: getami.c:101
int ymin
Definition: rle.h:100
#define bdist(a, b)
Definition: getami.c:42
static rle_pixel ** cmap
Definition: getami.c:97
static int y
Definition: getami.c:691
static unsigned char b
Definition: getami.c:692
static unsigned int B[32]
Definition: getami.c:98
static rle_pixel * sl[3]
Definition: getami.c:96
int rle_get_setup(rle_hdr *the_hdr)
Definition: rle_getrow.c:74
Definition: rle.h:96
int xmax
Definition: rle.h:100
enum rle_dispatch dispatch
Definition: rle.h:99
static int x
Definition: getami.c:691
int i
Definition: getami.c:87
#define index(r, g, b)
Definition: getami.c:37
#define gdist(a, b)
Definition: getami.c:40
static unsigned int G[32]
Definition: getami.c:98
int background
Definition: rle.h:100
#define RLE_CLR_BIT(glob, bit)
Definition: rle.h:124
int ncmap
Definition: rle.h:100
int ymax
Definition: rle.h:100
unsigned char rle_pixel
Definition: rle.h:56
void * malloc()
int cmaplen
Definition: rle.h:100
int i
Definition: rletorla.c:82
int alpha
Definition: rle.h:100
#define RLE_ALPHA
Definition: rle.h:65
int compare(struct cuse *, struct cuse *)
Definition: getami.c:529
void rle_put_setup(rle_hdr *the_hdr)
Definition: rle_putrow.c:453
static struct cuse cusage[4096]
Definition: getami.c:86
int rle_getrow(rle_hdr *the_hdr, rle_pixel *scanline[])
FILE * rle_file
Definition: rle.h:114
int ncolors
Definition: rle.h:100

Here is the call graph for this function:

void FixColors ( void  )

Definition at line 1017 of file getami.c.

References B, G, R, rp1, rp2, rp3, threescreens, vp1, vp2, and vp3.

1018 {
1019  if (threescreens) {
1020  OptSetAPen1(rp1, 1L); OptSetAPen2(rp2, 1L); OptSetAPen3(rp3, 1L);
1021  SetBPen(rp1, 0L); SetBPen(rp2, 0L); SetBPen(rp3, 0L);
1022  SetRGB4(vp1, 1L, 15L, 15L, 15L);
1023  SetRGB4(vp2, 1L, 15L, 15L, 15L);
1024  SetRGB4(vp3, 1L, 15L, 15L, 15L);
1025  }else{
1026  OptSetAPen1(rp1, 1L);
1027  SetBPen(rp1, 0L);
1028  SetRGB4(vp1, 1L, (R[0]+8) % 16, (G[0]+8) % 16, (B[0]+8) % 16);
1029  }
1030 }
static unsigned int R[32]
Definition: getami.c:98
static struct RastPort * rp1
Definition: getami.c:91
static int threescreens
Definition: getami.c:106
static struct ViewPort * vp2
Definition: getami.c:95
#define OptSetAPen2(rp, col)
Definition: getami.c:221
static unsigned int B[32]
Definition: getami.c:98
static struct RastPort * rp3
Definition: getami.c:91
static struct RastPort * rp2
Definition: getami.c:91
static struct ViewPort * vp3
Definition: getami.c:95
static unsigned int G[32]
Definition: getami.c:98
#define OptSetAPen3(rp, col)
Definition: getami.c:222
#define OptSetAPen1(rp, col)
Definition: getami.c:220
static struct ViewPort * vp1
Definition: getami.c:95
UBYTE handleIDCMP ( void  )
if ( tfd  )

Definition at line 852 of file getami.c.

References tfd, and tfile.

852  {
853  fclose (tfd);
854  unlink (tfile);
855  }
static FILE * tfd
Definition: getami.c:100
static char * tfile
Definition: getami.c:99
if ( w1  )

Definition at line 857 of file getami.c.

References w1.

857  {
858  if (w1->MenuStrip)
859  ClearMenuStrip(w1);
860  CloseWindow (w1);
861  }
static struct Window * w1
Definition: getami.c:90
if ( w2  )

Definition at line 863 of file getami.c.

References w2.

863  {
864  if (w2->MenuStrip)
865  ClearMenuStrip(w2);
866  CloseWindow (w2);
867  }
static struct Window * w2
Definition: getami.c:90
if ( w3  )

Definition at line 869 of file getami.c.

References w3.

869  {
870  if (w3->MenuStrip)
871  ClearMenuStrip(w3);
872  CloseWindow (w3);
873  }
static struct Window * w3
Definition: getami.c:90
if ( s1  )

Definition at line 875 of file getami.c.

906 {
907  UBYTE flag = 0;
908  struct IntuiMessage *message = NULL;
909  USHORT code, selection;
910  ULONG class, itemnum;
911  int t;
912 
913  while ((message = (struct IntuiMessage *)GetMsg(w1->UserPort)) ||
914  (threescreens && (message=(struct IntuiMessage *)GetMsg(w2->UserPort))) ||
915  (threescreens && (message=(struct IntuiMessage *)GetMsg(w3->UserPort)))) {
916  class = message->Class;
917  code = message->Code;
918  switch (class) {
919  case GADGETUP:
920  flag = 1;
921  break;
922  case REQSET:
923  FixColors();
924  if (threescreens) ScreenToFront(s1);
925  ActivateGadget(&fgad, w1, &freq);
926  break;
927  case REQCLEAR:
928  save();
929  havereq = 0;
930  ResetColors();
931  break;
932  case MENUVERIFY:
933  havemenu = 1;
934  FixColors();
935  break;
936  case MENUPICK:
937  selection = code;
938  while (selection != MENUNULL) {
939  itemnum = ITEMNUM(selection);
940  switch (itemnum) {
941  case 0:
942  if (ifd == stdin) {
943  if (threescreens) ScreenToFront(s1);
944  havereq = 1;
945  Request(&freq, w1);
946  }else{
947  strcpy(fnam, infile);
948  t = strlen(fnam);
949  if ( (t >= 4) && (strcmp(&fnam[t-4], ".rle") == 0)) {
950  fnam[t-4] = '\000';
951  }
952  strcat(fnam, ".ilbm");
953  }
954  save();
955  break;
956  case 1:
957  if (threescreens) ScreenToFront(s1);
958  havereq = 1;
959  Request(&freq, w1);
960  break;
961  case 2:
962  flag = 1;
963  break;
964  default:
965  break;
966  }
967  selection = ((struct MenuItem *)ItemAddress
968  (&menu, (LONG)selection))->NextSelect;
969  }
970  havemenu = 0;
971  ResetColors();
972  break;
973  default:
974  break;
975  }
976  ReplyMsg((struct Message *)message);
977  }
978  return flag;
979 }
void FixColors(void)
Definition: getami.c:1017
void save(void)
Definition: getami.c:982
static struct Window * w1
Definition: getami.c:90
static int threescreens
Definition: getami.c:106
static FILE * ifd
Definition: getami.c:100
static struct Gadget fgad
Definition: getami.c:184
static struct Window * w3
Definition: getami.c:90
static int havereq
Definition: getami.c:106
static struct Menu menu
Definition: getami.c:163
void ResetColors(void)
Definition: getami.c:1033
static struct Window * w2
Definition: getami.c:90
static int havemenu
Definition: getami.c:106
#define LONG
Definition: rle_code.h:36
static struct Requester freq
Definition: getami.c:192
static struct Screen * s1
Definition: getami.c:92
static char fnam[80]
Definition: getami.c:167
static char * infile
Definition: getami.c:99
void main ( int  argc,
char **  argv 
)

Definition at line 229 of file getami.c.

References B, bw, flip, fnam, forceham, G, ifd, IFFBase, infile, IntuitionBase, isham, mktemp(), nused, optarg, optind, R, s1, s2, s3, sd, sh, sw, tfd, tfile, threescreens, vp1, vp2, vp3, and width.

230 {
231  int i, SW=0, SH=0, dump=0, load=0, dx, dy, max_x, max_y;
232  ULONG signalmask, signals;
233  UBYTE done;
234  BYTE pal;
235  FILE *f;
236  struct Preferences prefs;
237  extern char *optarg;
238  extern int optind;
239 
240 /* _abort (#define'd as CXBRK for Lattice) is the default signal handler.
241  No need to call signal, unless we are using some compiler other than
242  Manx/gcc or lattice
243 */
244 #if !defined(MCH_AMIGA) && !defined(LATTICE)
245  (void)signal(SIGINT, (void (*) (int))_abort);
246 #endif
247  while ((i = getopt(argc, argv, "w:h:o:dlb3fH")) != EOF) {
248  switch(i) {
249  case 'w':
250  SW = atoi(optarg);
251  break;
252  case 'h':
253  SH = atoi(optarg);
254  break;
255  case 'o':
256  strcpy(fnam, optarg);
257  break;
258  case 'd':
259  dump = 1;
260  break;
261  case 'l':
262  load = 1;
263  break;
264  case 'b':
265  bw = 1;
266  forceham = 0;
267  threescreens = 0;
268  break;
269  case '3':
270  threescreens = 1;
271  bw = 0;
272  forceham = 0;
273  break;
274  case 'f':
275  flip = 1;
276  break;
277  case 'H':
278  forceham = 1;
279  bw = 0;
280  threescreens = 0;
281  break;
282  case '?':
283  default:
284  fprintf(stderr,
285  "Usage: %s [-dlfb3H] [-w width] [-h height] [-o IFFfile] [file]\n",
286  BASENAME(argv[0]));
287  exit(1);
288  }
289  }
290 
291  if (optind >= argc)
292  ifd = stdin;
293  else{
294  infile = argv[optind];
295  if ((ifd = fopen (infile, "r")) == NULL)
296  fprintf (stderr, "cannot open input file %s\n", infile), _abort ();
297  }
298 
299  if ((tfile = mktemp ("t:rle.XXX")) == NULL)
300  fprintf (stderr, "cannot create a temp name for tfile\n"), _abort ();
301 
302  if ((tfd = fopen (tfile, "w+")) == NULL)
303  fprintf (stderr, "cannot open output file %s\n", tfile), _abort ();
304 
305  if ((GfxBase =
306  (struct GfxBase *) OpenLibrary ("graphics.library", 0L)) == NULL)
307  fprintf (stderr, "Can't open graphics.library\n"), _abort ();
308  pal = (GfxBase->DisplayFlags & PAL) ? 1 : 0;
309 
310  if ((IntuitionBase = (struct IntuitionBase *)
311  OpenLibrary ("intuition.library", 0L)) == NULL)
312  fprintf (stderr, "Can't open intuition.library\n"), _abort ();
313 
314 #ifndef NOIFFLIB
315  if ((IFFBase = OpenLibrary(IFFNAME, IFFVERSION)) == NULL) {
316 #endif
317  actions[0].Flags &= ~ITEMENABLED;
318  actions[1].Flags &= ~ITEMENABLED;
319 #ifndef NOIFFLIB
320  }
321 #endif
322 
323  if (find_most_used () == -1)
324  fprintf (stderr, "error in find_most_used\n"), _abort ();
325 
326  if (load) {
327  f = fopen("cmap", "r");
328  if (!f) {
329  fprintf(stderr, "Can't find cmap file\n");
330  }else{
331  fread((char *)R, sizeof(R), 1, f);
332  fread((char *)G, sizeof(G), 1, f);
333  fread((char *)B, sizeof(B), 1, f);
334  }
335  fclose(f);
336  }
337  if (dump) {
338  f = fopen("cmap", "w");
339  if (!f) {
340  fprintf(stderr, "Can't create cmap file\n");
341  }else{
342  fwrite((char *)R, sizeof(R), 1, f);
343  fwrite((char *)G, sizeof(G), 1, f);
344  fwrite((char *)B, sizeof(B), 1, f);
345  }
346  fclose(f);
347  }
348  fseek (tfd, 0L, 0);
349 
350  if (!forceham && (bw || threescreens || nused <= 32)) {
351  isham = FALSE;
352  sw = CalcWidth(width);
353  sh = CalcHeight(height, pal);
354  if (nused > 16) sd = 5;
355  else if (nused > 8) sd = 4;
356  else if (nused > 4) sd = 3;
357  else if (nused > 2) sd = 2;
358  else if (nused > 0) sd = 1;
359  else
360  fprintf (stderr, "found 0!! colors\n"), _abort ();
361  if (SW) sw = SW;
362  if (SH) sh = SH;
363  screen.Width = sw, screen.Height = sh, screen.Depth = sd;
364  if (pal) {
365  screen.ViewModes =
366  ((sh > MAX_Y_PAL) ? LACE : 0) | ((sw > MAX_X) ? HIRES : 0);
367  }else{
368  screen.ViewModes =
369  ((sh > MAX_Y_NTSC) ? LACE : 0) | ((sw > MAX_X) ? HIRES : 0);
370  }
371  window.Width = sw, window.Height = sh;
372  } else {
373  isham = TRUE;
374  sd = 6;
375  sw = CalcHAMWidth(width);
376  sh = CalcHeight(height, pal);
377  if (SW) sw = SW;
378  if (SH) sh = SH;
379  screen.Width = sw, screen.Height = sh, screen.Depth = sd;
380  if (pal) {
381  screen.ViewModes = ((sh > MAX_Y_PAL) ? LACE : 0) | HAM;
382  }else{
383  screen.ViewModes = ((sh > MAX_Y_NTSC) ? LACE : 0) | HAM;
384  }
385  window.Width = sw, window.Height = sh;
386  }
387 
388  for (i=0; i<MENUITEMS; i++) {
389  if (screen.ViewModes & HIRES) {
390  actions[i].Width += COMMWIDTH;
391  }else{
392  actions[i].Width += LOWCOMMWIDTH;
393  }
394  }
395 
396  GetPrefs(&prefs, sizeof(prefs));
397  Ptr = (USHORT *)AllocMem(POINTERSIZE * sizeof(USHORT), MEMF_CHIP);
398  if (!Ptr) {
399  fprintf (stderr, "Can't allocate chip memory for pointer\n");
400  _abort ();
401  }
402 
403  if (threescreens) {
404  if ((s3 = OpenScreen (&screen)) == NULL)
405  fprintf (stderr, "Can't open screen 3\n"), _abort ();
406  AdjustScreen(s3, &dx, &dy);
407  ShowTitle (s3, FALSE);
408  window.Screen = s3;
409  if ((w3 = OpenWindow (&window)) == NULL)
410  fprintf (stderr, "Can't open window 3\n"), _abort ();
411  vp3 = &(s3->ViewPort);
412  rp3 = w3->RPort;
413  SetMenuStrip(w3, &menu);
414 
415  if ((s2 = OpenScreen (&screen)) == NULL)
416  fprintf (stderr, "Can't open screen 2\n"), _abort ();
417  AdjustScreen(s2, &dx, &dy);
418  ShowTitle (s2, FALSE);
419  window.Screen = s2;
420  if ((w2 = OpenWindow (&window)) == NULL)
421  fprintf (stderr, "Can't open window 2\n"), _abort ();
422  vp2 = &(s2->ViewPort);
423  rp2 = w2->RPort;
424  SetMenuStrip(w2, &menu);
425  }
426  if ((s1 = OpenScreen (&screen)) == NULL)
427  fprintf (stderr, "Can't open screen 1\n"), _abort ();
428  AdjustScreen(s1, &dx, &dy);
429  ShowTitle (s1, FALSE);
430  window.Screen = s1;
431  if ((w1 = OpenWindow (&window)) == NULL)
432  fprintf (stderr, "Can't open window 1\n"), _abort ();
433  vp1 = &(s1->ViewPort);
434  rp1 = w1->RPort;
435  SetMenuStrip(w1, &menu);
436 
437  max_y = (GfxBase->DisplayFlags & PAL) ? MAX_Y_PAL : MAX_Y_NTSC;
438  if (s1->ViewPort.Modes & LACE){
439  max_y *= 2;
440  }
441  max_x = MAX_X;
442  if (s1->ViewPort.Modes & HIRES){
443  max_x *= 2;
444  }
445  if (sw <= max_x) {
446  freq.LeftEdge = (sw - FREQW) / 2;
447  }else{
448  freq.LeftEdge = (max_x - FREQW) / 2;
449  }
450  if (sh <= max_y) {
451  freq.TopEdge = (sh - FREQH) / 2;
452  }else{
453  freq.TopEdge = (max_y - FREQH) / 2;
454  }
455 
456  if (isham) nused = 16;
457  for (i = 0; i < nused; i++) {
458  if (threescreens) {
459  SetRGB4 (vp1, (long) i, (long) i, 0L, 0L);
460  SetRGB4 (vp2, (long) i, 0L, (long) i, 0L);
461  SetRGB4 (vp3, (long) i, 0L, 0L, (long) i);
462  }else{
463  SetRGB4 (vp1, (long) i, (long) R[i], (long) G[i], (long) B[i]);
464  }
465  }
466 
467  memcpy(Ptr, RenderPtr, POINTERSIZE * sizeof(USHORT));
468  SetPointer(w1, Ptr, 16, 16, dx - 1, dy);
469  if (threescreens) {
470  SetPointer(w2, Ptr, 16, 16, dx - 1, dy);
471  SetPointer(w3, Ptr, 16, 16, dx - 1, dy);
472  }
473 
474  display_rle ();
475 
476  memcpy(Ptr, prefs.PointerMatrix, POINTERSIZE * sizeof(USHORT));
477  SetPointer(w1, Ptr, 16, 16, dx - 1 + prefs.XOffset, dy + prefs.YOffset);
478  if (threescreens) {
479  SetPointer(w2, Ptr, 16, 16, dx - 1 + prefs.XOffset, dy + prefs.YOffset);
480  SetPointer(w3, Ptr, 16, 16, dx - 1 + prefs.XOffset, dy + prefs.YOffset);
481  }
482 
483  if (fnam[0]) {
484 #ifndef NOIFFLIB
485  if (IFFBase) save();
486 #else
487  save();
488 #endif
489  }else{
490  done = (UBYTE)0;
491  if (threescreens) {
492  signalmask = (1L << w1->UserPort->mp_SigBit) |
493  (1L << w2->UserPort->mp_SigBit) |
494  (1L << w3->UserPort->mp_SigBit);
495  }else{
496  signalmask = 1L << w1->UserPort->mp_SigBit;
497  }
498 
499  if (threescreens) { /* Run at high priority to reduce flicker */
500  SetTaskPri(FindTask(0L), 20L);
501  }
502  while (!done) {
503  if (threescreens) {
504  if (!(havemenu || havereq)) {
505  ScreenToFront(s1);
506  }
507  done = handleIDCMP();
508  if (!(havemenu || havereq)) {
509  ScreenToFront(s2);
510  }
511  done |= handleIDCMP();
512  if (!(havemenu || havereq)) {
513  ScreenToFront(s3);
514  }
515  done |= handleIDCMP();
516  }
517  if (!threescreens || havemenu || havereq) {
518  signals = Wait(signalmask);
519  if (signals & signalmask) {
520  done = handleIDCMP();
521  }
522  }
523  }
524  }
525  _abort ();
526 }
static unsigned int R[32]
Definition: getami.c:98
static int bw
Definition: getami.c:106
static struct RastPort * rp1
Definition: getami.c:91
static int sh
Definition: getami.c:101
void save(void)
Definition: getami.c:982
static USHORT * Ptr
Definition: getami.c:109
int getopt(int argc, argv, char *optstring)
Definition: getopt.c:37
static struct Window * w1
Definition: getami.c:90
static USHORT RenderPtr[]
Definition: getami.c:111
struct GfxBase * GfxBase
Definition: getami.c:61
static int threescreens
Definition: getami.c:106
int find_most_used(void)
Definition: getami.c:540
static int sd
Definition: getami.c:101
#define MENUITEMS
Definition: getami.c:143
static int width
Definition: getami.c:101
#define FREQH
Definition: getami.c:190
int display_rle(void)
Definition: getami.c:695
static FILE * ifd
Definition: getami.c:100
static struct ViewPort * vp2
Definition: getami.c:95
#define MAX_Y_NTSC
Definition: getami.c:55
static struct Window * w3
Definition: getami.c:90
#define FALSE
Definition: giftorle.c:39
static struct NewScreen screen
Definition: getami.c:67
int CalcHeight(int, int)
Definition: getami.c:1061
static int nused
Definition: getami.c:101
char * mktemp(char *)
Definition: mktemp.c:7
static struct Screen * s3
Definition: getami.c:94
static int havereq
Definition: getami.c:106
static struct Menu menu
Definition: getami.c:163
static FILE * tfd
Definition: getami.c:100
static int height
Definition: getami.c:101
static char * tfile
Definition: getami.c:99
static struct Window * w2
Definition: getami.c:90
static struct NewWindow window
Definition: getami.c:80
static int sw
Definition: getami.c:101
int CalcHAMWidth(int)
Definition: getami.c:1054
static unsigned int B[32]
Definition: getami.c:98
#define MAX_X
Definition: getami.c:54
static struct RastPort * rp3
Definition: getami.c:91
static struct RastPort * rp2
Definition: getami.c:91
static struct ViewPort * vp3
Definition: getami.c:95
static int havemenu
Definition: getami.c:106
static int isham
Definition: getami.c:101
static int forceham
Definition: getami.c:107
#define BASENAME(x)
Definition: getami.c:58
#define _abort
Definition: getami.c:208
#define TRUE
Definition: giftorle.c:38
int optind
Definition: getopt.c:30
void AdjustScreen(register struct Screen *, int *, int *)
Definition: AdjustScreen.c:12
struct Window * OpenWindow()
static unsigned int G[32]
Definition: getami.c:98
#define FREQW
Definition: getami.c:189
struct Library * OpenLibrary()
done()
Definition: getcx3d.c:270
struct Screen * OpenScreen()
static int flip
Definition: getami.c:106
int i
Definition: rletorla.c:82
int CalcWidth(int)
Definition: getami.c:1045
UBYTE handleIDCMP(void)
int max_y
Definition: unslice.c:42
static struct Requester freq
Definition: getami.c:192
char * optarg
Definition: getopt.c:29
static struct Screen * s2
Definition: getami.c:93
static struct Screen * s1
Definition: getami.c:92
static struct MenuItem actions[]
Definition: getami.c:151
static char fnam[80]
Definition: getami.c:167
struct Library * IFFBase
Definition: getami.c:64
static char * infile
Definition: getami.c:99
#define MAX_Y_PAL
Definition: getami.c:56
static struct ViewPort * vp1
Definition: getami.c:95
struct IntuitionBase * IntuitionBase
Definition: getami.c:62

Here is the call graph for this function:

char* mktemp ( char *  )

Definition at line 7 of file mktemp.c.

Referenced by main().

8 {
9  long pid = (long)FindTask(0L);
10  char *c;
11 
12  c = buf + strlen(buf);
13 
14  while (*--c == 'X') {
15  *c = pid % 10 + '0';
16  pid /= 10;
17  }
18  c++;
19  if (*c) {
20  for(*c='A'; *c <= 'Z'; (*c)++) {
21  if (access(buf, 0)) {
22  return buf;
23  }
24  }
25  *c = 0;
26  return buf;
27  }else{
28  return buf;
29  }
30 }
static char buf[4096 +1]
Definition: into.c:46

Here is the caller graph for this function:

struct Library* OpenLibrary ( )
struct Screen* OpenScreen ( )
struct Window* OpenWindow ( )
void ResetColors ( void  )

Definition at line 1033 of file getami.c.

References B, G, R, threescreens, vp1, vp2, and vp3.

1034 {
1035  if (threescreens) {
1036  SetRGB4(vp1, 1L, 1L, 1L, 1L);
1037  SetRGB4(vp2, 1L, 1L, 1L, 1L);
1038  SetRGB4(vp3, 1L, 1L, 1L, 1L);
1039  }else{
1040  SetRGB4(vp1, 1L, (long)R[1], (long)G[1], (long)B[1]);
1041  }
1042 }
static unsigned int R[32]
Definition: getami.c:98
static int threescreens
Definition: getami.c:106
static struct ViewPort * vp2
Definition: getami.c:95
static unsigned int B[32]
Definition: getami.c:98
static struct ViewPort * vp3
Definition: getami.c:95
static unsigned int G[32]
Definition: getami.c:98
static struct ViewPort * vp1
Definition: getami.c:95
void save ( void  )

Definition at line 982 of file getami.c.

References fnam, IFFBase, and threescreens.

983 {
984 #ifndef NOIFFLIB
985  char *name;
986 
987  if (*fnam == '\000')
988  return;
989 
990  if (IFFBase) {
991  ResetColors();
992  if (threescreens) {
993  name = malloc(strlen(fnam) + 4);
994  if (!name) {
995  fprintf(stderr, "malloc failed\n");
996  return;
997  }
998  strcpy(name, fnam);
999  strcat(name, ".r");
1000  SaveBitMap(name, s1->BitMap,vp1->ColorMap->ColorTable,(isham ? 0x81 : 1));
1001  strcpy(name, fnam);
1002  strcat(name, ".g");
1003  SaveBitMap(name, s2->BitMap,vp2->ColorMap->ColorTable,(isham ? 0x81 : 1));
1004  strcpy(name, fnam);
1005  strcat(name, ".b");
1006  SaveBitMap(name, s3->BitMap,vp3->ColorMap->ColorTable,(isham ? 0x81 : 1));
1007  free(name);
1008  }else{
1009  SaveBitMap(fnam, s1->BitMap,vp1->ColorMap->ColorTable,(isham ? 0x81 : 1));
1010  }
1011  FixColors();
1012  }
1013 #endif
1014 }
void FixColors(void)
Definition: getami.c:1017
static int threescreens
Definition: getami.c:106
static struct ViewPort * vp2
Definition: getami.c:95
static struct Screen * s3
Definition: getami.c:94
void ResetColors(void)
Definition: getami.c:1033
static struct ViewPort * vp3
Definition: getami.c:95
static int isham
Definition: getami.c:101
void * malloc()
static struct Screen * s2
Definition: getami.c:93
static struct Screen * s1
Definition: getami.c:92
static char fnam[80]
Definition: getami.c:167
struct Library * IFFBase
Definition: getami.c:64
static struct ViewPort * vp1
Definition: getami.c:95
void show_rgb ( void  )

Definition at line 768 of file getami.c.

References B, b, bw, flip, G, g, isham, nused, R, r, rp1, rp2, rp3, threescreens, x, and y.

769 {
770  int xx, yy, i, j;
771  long d, td, d1, d2, d3, rd, gd, bd;
772 
773  static unsigned char pr, pg, pb;
774 
775  xx = mapx (x);
776  if (!flip) {
777  yy = mapy (y);
778  }else{
779  yy = fmapy (y);
780  }
781  if (!inside (xx, yy))
782  return;
783 
784  if (bw) {
785 #if 0
786  r = g = b = 0.35 * r + 0.55 * g + 0.10 * b;
787 #else
788  r = g = b = (35 * r + 55 * g + 10 * b) / 100;
789 #endif
790  }
791 #ifndef AZTEC_C
792  r >>= 4, g >>= 4, b >>= 4;
793 #else /* avoid a manx bug */
794  r = (r >> 4) & 0xf, g = (g >> 4) & 0xf, b = (b >> 4) & 0xf;
795 #endif
796  if (threescreens) {
797  OptSetAPen1 (rp1, (long) r); OptWritePixel1 (rp1, (long) xx, (long) yy);
798  OptSetAPen2 (rp2, (long) g); OptWritePixel2 (rp2, (long) xx, (long) yy);
799  OptSetAPen3 (rp3, (long) b); OptWritePixel3 (rp3, (long) xx, (long) yy);
800  return;
801  }
802  if (!isham) {
803  for (i = 0; i < nused; i++) {
804  if (R[i] == (int) r && G[i] == (int) g && B[i] == (int) b) {
805  OptSetAPen1 (rp1, (long) i); OptWritePixel1 (rp1, (long) xx, (long) yy);
806  break;
807  }
808  }
809  return;
810  }
811  for (i = 0, d = 3276700, j = -1; i < 16; i++) {
812  td = SQ (r - R[i]) + SQ (g - G[i]) + SQ (b - B[i]);
813  if (td < d)
814  d = td, j = i;
815  if (d == 0)
816  break;
817  }
818  if (d == 0 || x == 0) {
819  OptSetAPen1 (rp1, (long) EXACT (j));
820  pr = R[j], pg = G[j], pb = B[j];
821  } else {
822  rd = SQ (r - pr), gd = SQ (g - pg), bd = SQ (b - pb);
823  d1 = rd + gd, d2 = rd + bd, d3 = gd + bd;
824  if (d <= d1 && d <= d2 && d <= d3) {
825  OptSetAPen1 (rp1, (long) EXACT (j));
826  pr = R[j], pg = G[j], pb = B[j];
827  } else if (d1 <= d2 && d1 <= d3) {
828  OptSetAPen1 (rp1, (long) BLUE (b));
829  pb = b;
830  } else if (d2 <= d3 && d2 <= d1) {
831  OptSetAPen1 (rp1, (long) GREEN (g));
832  pg = g;
833  } else {
834  OptSetAPen1 (rp1, (long) RED (r));
835  pr = r;
836  }
837  }
838  OptWritePixel1 (rp1, (long) xx, (long) yy);
839 }
static unsigned char g
Definition: getami.c:692
static unsigned int R[32]
Definition: getami.c:98
#define mapx(x)
Definition: getami.c:44
static int bw
Definition: getami.c:106
static struct RastPort * rp1
Definition: getami.c:91
#define OptWritePixel3(rp, x, y)
Definition: getami.c:226
static int threescreens
Definition: getami.c:106
#define OptWritePixel2(rp, x, y)
Definition: getami.c:225
static unsigned char r
Definition: getami.c:692
#define fmapy(y)
Definition: getami.c:46
static int nused
Definition: getami.c:101
#define EXACT(x)
Definition: getami.c:48
static int y
Definition: getami.c:691
#define OptSetAPen2(rp, col)
Definition: getami.c:221
static unsigned char b
Definition: getami.c:692
static unsigned int B[32]
Definition: getami.c:98
#define SQ(x)
Definition: getami.c:52
static int x
Definition: getami.c:691
static struct RastPort * rp3
Definition: getami.c:91
static struct RastPort * rp2
Definition: getami.c:91
static int isham
Definition: getami.c:101
#define GREEN(x)
Definition: getami.c:50
static unsigned int G[32]
Definition: getami.c:98
#define mapy(y)
Definition: getami.c:45
#define inside(x, y)
Definition: getami.c:47
static int flip
Definition: getami.c:106
#define BLUE(x)
Definition: getami.c:51
int i
Definition: rletorla.c:82
#define OptSetAPen3(rp, col)
Definition: getami.c:222
#define OptSetAPen1(rp, col)
Definition: getami.c:220
#define RED(x)
Definition: getami.c:49
#define OptWritePixel1(rp, x, y)
Definition: getami.c:224

Variable Documentation

struct MenuItem actions[]
static
Initial value:
= {
{ &actions[1], 0, 0, 68, 8, ITEMTEXT | ITEMENABLED | HIGHBOX | COMMSEQ, 0,
(APTR)&txt[0], ((void *)0) , 'S', ((void *)0) , MENUNULL
},
{ &actions[2], 0, 10, 68, 8, ITEMTEXT | ITEMENABLED | HIGHBOX | COMMSEQ, 0,
(APTR)&txt[1], ((void *)0) , 'A', ((void *)0) , MENUNULL
},
{ ((void *)0) , 0, 20, 68, 8, ITEMTEXT | ITEMENABLED | HIGHBOX | COMMSEQ, 0,
(APTR)&txt[2], ((void *)0) , 'Q', ((void *)0) , MENUNULL
}
}
static struct IntuiText txt[]
Definition: getami.c:145
static struct MenuItem actions[]
Definition: getami.c:151

Definition at line 151 of file getami.c.

unsigned int B[32]
static

Definition at line 98 of file getami.c.

Referenced by find_most_used(), FixColors(), main(), ResetColors(), and show_rgb().

unsigned char b
static

Definition at line 692 of file getami.c.

Referenced by display_rle(), and show_rgb().

int bw =0
static

Definition at line 106 of file getami.c.

Referenced by find_most_used(), main(), and show_rgb().

struct Gadget CloseGadget
static
Initial value:
= {
((void *)0) , 0, 0, 10, 10, GADGHCOMP | GADGIMAGE, RELVERIFY, BOOLGADGET, (APTR)&img,
((void *)0) , ((void *)0) , 0, ((void *)0) , 1, ((void *)0)
}
static struct Image img
Definition: getami.c:71

Definition at line 75 of file getami.c.

rle_pixel** cmap
static

Definition at line 97 of file getami.c.

Referenced by display_rle(), and find_most_used().

int curcol1

Definition at line 218 of file getami.c.

int curcol2

Definition at line 218 of file getami.c.

int curcol3

Definition at line 218 of file getami.c.

struct cuse cusage[4096]
static
int depth
static

Definition at line 101 of file getami.c.

Referenced by display_rle(), and find_most_used().

SHORT fbcoord[] = {1, 1, 146, 1, 146, 26, 1, 26, 1, 1}
static

Definition at line 178 of file getami.c.

struct Border fbord
static
Initial value:
= {
0, 0, 0, 1, JAM1, 5, fbcoord, ((void *)0)
}
static SHORT fbcoord[]
Definition: getami.c:178

Definition at line 180 of file getami.c.

struct Gadget fgad
static
Initial value:
= {
((void *)0) , 58, 10, 80, 8, GADGHCOMP, ENDGADGET, STRGADGET | REQGADGET,
((void *)0) , ((void *)0) , ((void *)0) , 0, (APTR)&fgadinfo, 0, ((void *)0)
}
static struct StringInfo fgadinfo
Definition: getami.c:170

Definition at line 184 of file getami.c.

struct StringInfo fgadinfo
static
Initial value:
= {
fnam, ufnam, 0, sizeof(fnam), 0, 0, 0, 0, 0, 0, ((void *)0) , 0, ((void *)0)
}
static char ufnam[80]
Definition: getami.c:168
static char fnam[80]
Definition: getami.c:167

Definition at line 170 of file getami.c.

int flip =0
static

Definition at line 106 of file getami.c.

Referenced by main(), and show_rgb().

char fnam[80] = {'\0'}
static

Definition at line 167 of file getami.c.

Referenced by main(), and save().

int forceham =0
static

Definition at line 107 of file getami.c.

Referenced by main().

struct Requester freq
static
Initial value:
= {
((void *)0) , 0, 0, 148 , 28 , 0, 0, &fgad, &fbord, &ftxt, ((void *)0) , 1, ((void *)0) ,
{ ((void *)0) }, ((void *)0) , ((void *)0) , { ((void *)0) }
}
static struct IntuiText ftxt
Definition: getami.c:174
static struct Gadget fgad
Definition: getami.c:184
static struct Border fbord
Definition: getami.c:180

Definition at line 192 of file getami.c.

struct IntuiText ftxt
static
Initial value:
= {
0, 1, JAM2, 9, 10, ((void *)0) , "File:", ((void *)0)
}

Definition at line 174 of file getami.c.

unsigned int G[32]
static

Definition at line 98 of file getami.c.

Referenced by find_most_used(), FixColors(), main(), ResetColors(), and show_rgb().

unsigned char g
static

Definition at line 692 of file getami.c.

Referenced by display_rle(), and show_rgb().

struct GfxBase* GfxBase = ((void *)0)

Definition at line 61 of file getami.c.

int havemenu =0
static

Definition at line 106 of file getami.c.

int havereq =0
static

Definition at line 106 of file getami.c.

int height
static

Definition at line 101 of file getami.c.

Referenced by display_rle(), and find_most_used().

FILE* ifd = ((void *)0)
static

Definition at line 100 of file getami.c.

Referenced by find_most_used(), and main().

struct Library* IFFBase = ((void *)0)

Definition at line 64 of file getami.c.

struct Image img
static
Initial value:
= {
0, 0, 10, 10, 0, ((void *)0) , 0, 0, ((void *)0)
}

Definition at line 71 of file getami.c.

char * infile = ((void *)0)
static

Definition at line 99 of file getami.c.

Referenced by main().

int
Initial value:
{
if (ifd && ifd != stdin )
fclose (ifd)
static FILE * ifd
Definition: getami.c:100

Definition at line 848 of file getami.c.

struct IntuitionBase* IntuitionBase = ((void *)0)

Definition at line 62 of file getami.c.

int isham
static

Definition at line 101 of file getami.c.

Referenced by main(), and show_rgb().

struct Menu menu
static
Initial value:
= {
((void *)0) , 10, 0, 56, 0, MENUENABLED, "Actions", &actions[0]
}
static struct MenuItem actions[]
Definition: getami.c:151

Definition at line 163 of file getami.c.

int nused
static

Definition at line 101 of file getami.c.

Referenced by find_most_used(), main(), and show_rgb().

int offsetx
static

Definition at line 105 of file getami.c.

Referenced by display_rle().

int offsety
static

Definition at line 105 of file getami.c.

Referenced by display_rle().

USHORT* Ptr = ((void *)0)
static

Definition at line 109 of file getami.c.

unsigned int R[32]
static

Definition at line 98 of file getami.c.

Referenced by find_most_used(), FixColors(), main(), ResetColors(), and show_rgb().

unsigned char r
static

Definition at line 692 of file getami.c.

Referenced by display_rle(), and show_rgb().

USHORT RenderPtr[]
static
Initial value:
= {
0x0000, 0x0000,
0x7800, 0x3800,
0x7000, 0x9000,
0x7800, 0x8800,
0x5C00, 0xA400,
0x0E00, 0x1200,
0x0700, 0x0900,
0xC300, 0xC400,
0xADD1, 0xADD1,
0xA955, 0xA955,
0xC9FF, 0xC9FF,
0x0000, 0x0000,
0x0BB8, 0x0BB8,
0x0AA8, 0x0AA8,
0x0AB8, 0x0AB8,
0x0008, 0x0008,
0x0038, 0x0038,
0x0000, 0x0000
}

Definition at line 111 of file getami.c.

struct RastPort* rp1 = ((void *)0)
static

Definition at line 91 of file getami.c.

Referenced by FixColors(), and show_rgb().

struct RastPort * rp2 = ((void *)0)
static

Definition at line 91 of file getami.c.

Referenced by FixColors(), and show_rgb().

struct RastPort * rp3 = ((void *)0)
static

Definition at line 91 of file getami.c.

Referenced by FixColors(), and show_rgb().

struct Screen* s1 = ((void *)0)
static

Definition at line 92 of file getami.c.

Referenced by main().

struct Screen* s2 = ((void *)0)
static

Definition at line 93 of file getami.c.

Referenced by main().

struct Screen* s3 = ((void *)0)
static

Definition at line 94 of file getami.c.

Referenced by main().

struct NewScreen screen
static
Initial value:
= {
0, 0, 0, 0, 6, 1, 0, 0, CUSTOMSCREEN, ((void *)0) , "GetAmi", ((void *)0) , ((void *)0)
}

Definition at line 67 of file getami.c.

int sd
static

Definition at line 101 of file getami.c.

Referenced by main().

int sh
static

Definition at line 101 of file getami.c.

Referenced by display_rle(), and main().

rle_pixel* sl[3]
static

Definition at line 96 of file getami.c.

Referenced by display_rle(), and find_most_used().

int SQtmp
static

Definition at line 133 of file getami.c.

int sw
static

Definition at line 101 of file getami.c.

Referenced by display_rle(), and main().

FILE * tfd = ((void *)0)
static

Definition at line 100 of file getami.c.

Referenced by display_rle(), find_most_used(), if(), and main().

char* tfile
static

Definition at line 99 of file getami.c.

Referenced by if(), and main().

int threescreens =0
static

Definition at line 106 of file getami.c.

Referenced by find_most_used(), FixColors(), main(), ResetColors(), save(), and show_rgb().

struct IntuiText txt[]
static
Initial value:
= {
{ 1, 0, JAM2, 0, 0, ((void *)0) , "Save", ((void *)0) },
{ 1, 0, JAM2, 0, 0, ((void *)0) , "Save As", ((void *)0) },
{ 1, 0, JAM2, 0, 0, ((void *)0) , "Quit", ((void *)0) }
}

Definition at line 145 of file getami.c.

char ufnam[80] = {'\0'}
static

Definition at line 168 of file getami.c.

struct ViewPort* vp1 = ((void *)0)
static

Definition at line 95 of file getami.c.

Referenced by FixColors(), main(), and ResetColors().

struct ViewPort * vp2 = ((void *)0)
static

Definition at line 95 of file getami.c.

Referenced by FixColors(), main(), and ResetColors().

struct ViewPort * vp3 = ((void *)0)
static

Definition at line 95 of file getami.c.

Referenced by FixColors(), main(), and ResetColors().

struct Window* w1 = ((void *)0)
static

Definition at line 90 of file getami.c.

Referenced by if().

struct Window * w2 = ((void *)0)
static

Definition at line 90 of file getami.c.

Referenced by if().

struct Window * w3 = ((void *)0)
static

Definition at line 90 of file getami.c.

Referenced by if().

int width
static

Definition at line 101 of file getami.c.

Referenced by display_rle(), find_most_used(), and main().

struct NewWindow window
static
Initial value:
= {
0, 0, 0, 0, 1, 0, GADGETUP | MENUPICK | MENUVERIFY | REQSET | REQCLEAR,
SMART_REFRESH | BACKDROP | BORDERLESS,
&CloseGadget, ((void *)0) , ((void *)0) , ((void *)0) , ((void *)0) , 0, 0, 0, 0, CUSTOMSCREEN
}
static struct Gadget CloseGadget
Definition: getami.c:75

Definition at line 80 of file getami.c.

int x
static

Definition at line 691 of file getami.c.

Referenced by display_rle(), and show_rgb().

int y
static

Definition at line 691 of file getami.c.

Referenced by display_rle(), and show_rgb().