Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
CenterScreen.c
Go to the documentation of this file.
1 #include <intuition/intuition.h>
2 #include <graphics/gfxbase.h>
3 #ifdef LATTICE
4 #include <proto/intuition.h>
5 #endif
6 
7 #define MAX_X 362
8 #define MAX_Y_NTSC 241
9 #define MAX_Y_PAL 283
10 
11 void
12 CenterScreen(register struct Screen *screen, int *dx, int *dy)
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 }
#define MAX_X
Definition: AdjustScreen.c:7
#define MAX_Y_PAL
Definition: AdjustScreen.c:9
#define MAX_Y_NTSC
Definition: AdjustScreen.c:8