Nugget
configuration.hh
1 /*
2 
3 MIT License
4 
5 Copyright (c) 2022 PCSX-Redux authors
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in all
15 copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 SOFTWARE.
24 
25 */
26 
27 #pragma once
28 
30  Configuration &set(Resolution resolution) {
31  if (resolution == Resolution::W368) {
32  config.hResolution = HR_EXTENDED;
33  config.hResolutionExtended = HRE_368;
34  } else {
35  config.hResolutionExtended = HRE_NORMAL;
36  switch (resolution) {
37  case Resolution::W256:
38  config.hResolution = HR_256;
39  break;
40  case Resolution::W320:
41  config.hResolution = HR_320;
42  break;
43  case Resolution::W512:
44  config.hResolution = HR_512;
45  break;
46  case Resolution::W640:
47  config.hResolution = HR_640;
48  break;
49  }
50  }
51  return *this;
52  }
53  Configuration &set(VideoMode videoMode) {
54  switch (videoMode) {
55  case VideoMode::AUTO:
56  config.videoMode = (*((char *)0xbfc7ff52) == 'E') ? VM_PAL : VM_NTSC;
57  break;
58  case VideoMode::NTSC:
59  config.videoMode = VM_NTSC;
60  break;
61  case VideoMode::PAL:
62  config.videoMode = VM_PAL;
63  break;
64  }
65  return *this;
66  }
67  Configuration &set(ColorMode colorMode) {
68  switch (colorMode) {
69  case ColorMode::C15BITS:
70  config.colorDepth = CD_15BITS;
71  break;
72  case ColorMode::C24BITS:
73  config.colorDepth = CD_24BITS;
74  break;
75  }
76  return *this;
77  }
78  Configuration &set(Interlace interlace) {
79  config.videoInterlace = interlace == Interlace::INTERLACED ? VI_ON : VI_OFF;
80  return *this;
81  }
82 
83  private:
84  enum HResolution {
85  HR_EXTENDED,
86  HR_256 = 0,
87  HR_320 = 1,
88  HR_512 = 2,
89  HR_640 = 3,
90  };
91 
92  enum VResolution {
93  VR_240 = 0,
94  VR_480 = 1,
95  };
96 
97  enum VMode {
98  VM_NTSC = 0,
99  VM_PAL = 1,
100  };
101 
102  enum ColorDepth {
103  CD_15BITS = 0,
104  CD_24BITS = 1,
105  };
106 
107  enum VideoInterlace {
108  VI_OFF = 0,
109  VI_ON = 1,
110  };
111 
112  enum HResolutionExtended {
113  HRE_NORMAL = 0,
114  HRE_368 = 1,
115  };
116 
117  struct DisplayModeConfig {
118  enum HResolution hResolution;
119  enum VResolution vResolution;
120  enum VMode videoMode;
121  enum ColorDepth colorDepth;
122  enum VideoInterlace videoInterlace;
123  enum HResolutionExtended hResolutionExtended;
124  };
125 
126  DisplayModeConfig config = {};
127  friend class GPU;
128 };
The singleton GPU class.
Definition: gpu.hh:57
Definition: configuration.hh:29