Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
Functions | Variables
show3.c File Reference
#include <stdio.h>
#include <string.h>
#include <exec/types.h>
#include <graphics/gfxbase.h>
#include <intuition/intuition.h>
#include <iff.h>
Include dependency graph for show3.c:

Go to the source code of this file.

Functions

struct Library * OpenLibrary ()
 
struct ScreenOpenScreen ()
 
void CenterScreen (register struct Screen *, int *, int *)
 
void Fail (char *text, int status)
 
 main (int argc, char *argv[])
 

Variables

struct Library * IntuitionBase = ((void *)0)
 
struct Library * IFFBase = ((void *)0)
 
struct GfxBase * GfxBase = ((void *)0)
 
struct NewScreen ns
 
struct Screenscreen [3] = { ((void *)0) , ((void *)0) , ((void *)0) }
 
APTR ifffile = ((void *)0)
 
char * fname [3] = { ((void *)0) , ((void *)0) , ((void *)0) }
 
int fsiz = 0
 

Function Documentation

void CenterScreen ( register struct Screen ,
int ,
int  
)

Definition at line 12 of file CenterScreen.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  screen->ViewPort.DxOffset += (c640 - w) / 2;
45  *dx = screen->ViewPort.DxOffset / 2;
46  }else{
47  screen->ViewPort.DxOffset += (c320 - w) / 2;
48  *dx = screen->ViewPort.DxOffset;
49  }
50  if (screen->ViewPort.Modes & LACE){
51  screen->ViewPort.DyOffset += (r400 - h) / 2;
52  *dy = screen->ViewPort.DyOffset / 2;
53  }else{
54  screen->ViewPort.DyOffset += (r200 - h) / 2;
55  *dy = screen->ViewPort.DyOffset;
56  }
57 
58  RemakeDisplay();
59 }
struct GfxBase * GfxBase
Definition: getami.c:61
#define MAX_Y_PAL
Definition: CenterScreen.c:9
static struct NewScreen screen
Definition: getami.c:67
int max_y
Definition: unslice.c:42
#define MAX_Y_NTSC
Definition: CenterScreen.c:8
#define MAX_X
Definition: CenterScreen.c:7
void Fail ( char *  text,
int  status 
)

Definition at line 36 of file show3.c.

References fname, fsiz, IFFBase, IntuitionBase, and screen.

37 {
38  int i;
39 
40  if(ifffile) CloseIFF(ifffile);
41  if(screen[0]) CloseScreen(screen[0]);
42  if(screen[1]) CloseScreen(screen[1]);
43  if(screen[2]) CloseScreen(screen[2]);
44  if (fsiz) {
45  for (i=0; i<3; i++) {
46  if (fname[i]) FreeMem(fname[i], fsiz);
47  }
48  }
49  if (*text) {
50  printf("%s\n",text);
51  }
52  if(IFFBase) {
53  if (i = IffError()) {
54  printf("IffError = %ld\n", i);
55  }
56  CloseLibrary(IFFBase); /* MUST ALWAYS BE CLOSED !! */
57  }
58  if(IntuitionBase) CloseLibrary(IntuitionBase);
59  if(GfxBase) CloseLibrary((struct Library *)GfxBase);
60  exit(status);
61 }
status_ $t status
Definition: getap.c:99
struct GfxBase * GfxBase
Definition: show3.c:21
int fsiz
Definition: show3.c:32
char * fname[3]
Definition: show3.c:31
APTR ifffile
Definition: show3.c:30
struct Library * IntuitionBase
Definition: show3.c:20
struct Library * IFFBase
Definition: show3.c:20
struct Screen * screen[3]
Definition: show3.c:29
int i
Definition: rletorla.c:82
main ( int  argc,
char *  argv[] 
)

Definition at line 63 of file show3.c.

References fname, fsiz, IntuitionBase, and screen.

64 {
65  long count,i;
66  int dx, dy;
67  WORD colortable[128];
68  struct BitMapHeader *bmhd;
69 
70  if(!strcmp(argv[1],"?") || ((argc !=4) && (argc != 2))) {
71  printf("Usage: %s redfile greenfile bluefile\n"
72  " %s filename (.[rgb] will be appended)\n",
73  argv[0], argv[0]);
74  exit(1);
75  }
76  if (argc == 4) {
77  for (i=0; i<3; i++) {
78  fname[i] = argv[i+1];
79  }
80  }else{
81  fsiz = strlen(argv[1]) + 3;
82  for (i=0; i<3; i++) {
83  fname[i] = AllocMem(fsiz, 0L);
84  if (!fname[i]) {
85  Fail("Can't allocate memory", 1);
86  }
87  strcpy(fname[i], argv[1]);
88  strcat(fname[i], ((i == 0) ? ".r" : ((i == 1) ? ".g" : ".b")));
89  }
90  }
91  GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0L);
92  if (!GfxBase) {
93  Fail("Can't open graphics.library", 1);
94  }
95  IntuitionBase = OpenLibrary("intuition.library",0L);
96  if (!IntuitionBase) {
97  Fail("Can't open intuition.library", 1);
98  }
99  if(!(IFFBase = OpenLibrary(IFFNAME,IFFVERSION))) {
100  Fail("Copy the iff.library to your LIBS: directory!", 1);
101  }
102 
103  for (i=0; i<3; i++) {
104  if(!(ifffile=OpenIFF(fname[i]))){
105  Fail("Error opening file", 1);
106  }
107  if(!(bmhd=GetBMHD(ifffile))) {
108  Fail("BitMapHeader not found", 1);
109  }
110  ns.Width = bmhd->w;
111  ns.Height = bmhd->h;
112  ns.Depth = bmhd->nPlanes;
113  ns.ViewModes = GetViewModes(ifffile);
114 
115  if(!(screen[i] = OpenScreen(&ns))) {
116  Fail("Can't open screen!", 1);
117  }
118  CenterScreen(screen[i], &dx, &dy);
119 
120  count = GetColorTab(ifffile,colortable);
121  if(count>32L) count = 32L; /* Some HAM pictures have 64 colors ?! */
122  LoadRGB4(&(screen[i]->ViewPort),colortable,count);
123 
124  if(!DecodePic(ifffile,&screen[i]->BitMap)) {
125  Fail("Can't decode picture", 1);
126  }
127  CloseIFF(ifffile);
128  ifffile = NULL;
129  }
130  SetTaskPri(FindTask(0L), 20L); /* Run at high priority to reduce */
131  for(;;) { /* flicker! */
132  if(!((*((UBYTE*)0xbfe001))&64)) break; /* I know it's a hack */
133  ScreenToFront(screen[0]);
134  if(!((*((UBYTE*)0xbfe001))&64)) break; /* I know it's a hack */
135  ScreenToFront(screen[1]);
136  if(!((*((UBYTE*)0xbfe001))&64)) break; /* I know it's a hack */
137  ScreenToFront(screen[2]);
138  }
139  Fail("", 0); /* Close the whole stuff */
140 }
struct GfxBase * GfxBase
Definition: show3.c:21
struct NewScreen ns
Definition: show3.c:23
void CenterScreen(register struct Screen *, int *, int *)
Definition: CenterScreen.c:12
int fsiz
Definition: show3.c:32
char * fname[3]
Definition: show3.c:31
struct Library * OpenLibrary()
APTR ifffile
Definition: show3.c:30
struct Library * IntuitionBase
Definition: show3.c:20
struct Screen * OpenScreen()
struct Library * IFFBase
Definition: show3.c:20
struct Screen * screen[3]
Definition: show3.c:29
int i
Definition: rletorla.c:82
void Fail(char *text, int status)
Definition: show3.c:36
struct Library * OpenLibrary ( )
struct Screen * OpenScreen ( )

Variable Documentation

char* fname[3] = { ((void *)0) , ((void *)0) , ((void *)0) }

Definition at line 31 of file show3.c.

int fsiz = 0

Definition at line 32 of file show3.c.

Referenced by Fail(), and main().

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

Definition at line 21 of file show3.c.

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

Definition at line 20 of file show3.c.

Referenced by Fail(), main(), and save().

APTR ifffile = ((void *)0)

Definition at line 30 of file show3.c.

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

Definition at line 20 of file show3.c.

Referenced by Fail(), and main().

struct NewScreen ns
Initial value:
=
{
0,0,0,0,0,0,0, ((void *)0) , CUSTOMSCREEN | SCREENQUIET, ((void *)0) , (STRPTR)"Show3", ((void *)0) ,
((void *)0)
}

Definition at line 23 of file show3.c.

struct Screen* screen[3] = { ((void *)0) , ((void *)0) , ((void *)0) }

Definition at line 29 of file show3.c.