Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
AdjustScreen.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 AdjustScreen(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  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 }
#define MAX_X
Definition: AdjustScreen.c:7
#define MAX_Y_PAL
Definition: AdjustScreen.c:9
#define MAX_Y_NTSC
Definition: AdjustScreen.c:8