1 |
|
/* |
2 |
|
* video.h - Video/graphics emulation |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-2001 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2005 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
27 |
|
using std::vector; |
28 |
|
#endif |
29 |
|
|
30 |
+ |
|
31 |
|
/* |
32 |
|
Some of the terminology here is completely frelled. In Basilisk II, a |
33 |
|
"video mode" refers to a combination of resolution and color depth, and |
56 |
|
VDEPTH_32BIT // "Millions" |
57 |
|
}; |
58 |
|
|
59 |
< |
// For compatibility reasons with older (pre-Display Manager) versions of |
59 |
< |
// MacOS, the Apple modes must start at 0x80 and be contiguous. Therefore |
60 |
< |
// we construct an array to map the depth codes to the corresponding Apple |
61 |
< |
// mode. This array is initialized by video_init_depth_list() which must |
62 |
< |
// be called by the platform-dependant VideoInit() routine after filling |
63 |
< |
// the VideoModes array. |
64 |
< |
extern uint16 apple_mode_for_depth[6]; |
65 |
< |
|
66 |
< |
inline uint16 DepthToAppleMode(video_depth depth) |
67 |
< |
{ |
68 |
< |
return apple_mode_for_depth[depth]; |
69 |
< |
} |
70 |
< |
|
59 |
> |
// 1, 2, 4 and 8 bit depths use a color palette |
60 |
|
inline bool IsDirectMode(video_depth depth) |
61 |
|
{ |
62 |
|
return depth == VDEPTH_16BIT || depth == VDEPTH_32BIT; |
90 |
|
} |
91 |
|
} |
92 |
|
|
93 |
+ |
|
94 |
|
/* |
95 |
|
You are not completely free in your selection of depth/resolution |
96 |
|
combinations: |
124 |
|
uint32 x; // X size of screen (pixels) |
125 |
|
uint32 y; // Y size of screen (pixels) |
126 |
|
uint32 resolution_id; // Resolution ID (should be >= 0x80 and uniquely identify the sets of modes with the same X/Y size) |
137 |
– |
uint32 bytes_per_row; // Bytes per row of frame buffer |
127 |
|
video_depth depth; // Color depth (see definitions above) |
128 |
+ |
uint32 bytes_per_row; // Bytes per row of frame buffer |
129 |
+ |
uint32 user_data; // Free for use by platform-specific code |
130 |
|
}; |
131 |
|
|
132 |
|
inline bool IsDirectMode(const video_mode &mode) |
134 |
|
return IsDirectMode(mode.depth); |
135 |
|
} |
136 |
|
|
146 |
– |
// List of all supported video modes |
147 |
– |
extern vector<video_mode> VideoModes; |
137 |
|
|
138 |
< |
// Description for one (possibly virtual) monitor |
139 |
< |
struct monitor_desc { |
140 |
< |
uint32 mac_frame_base; // Mac frame buffer address |
141 |
< |
video_mode mode; // Currently selected video mode description |
138 |
> |
// Mac video driver per-display private variables (opaque) |
139 |
> |
struct video_locals; |
140 |
> |
|
141 |
> |
|
142 |
> |
// Abstract base class representing one (possibly virtual) monitor |
143 |
> |
// ("monitor" = rectangular display with a contiguous frame buffer) |
144 |
> |
class monitor_desc { |
145 |
> |
public: |
146 |
> |
monitor_desc(const vector<video_mode> &available_modes, video_depth default_depth, uint32 default_id); |
147 |
> |
virtual ~monitor_desc() {} |
148 |
> |
|
149 |
> |
// Get Mac slot ID number |
150 |
> |
uint8 get_slot_id(void) const {return slot_id;} |
151 |
> |
|
152 |
> |
// Get current Mac frame buffer base address |
153 |
> |
uint32 get_mac_frame_base(void) const {return mac_frame_base;} |
154 |
> |
|
155 |
> |
// Set Mac frame buffer base address (called from switch_to_mode()) |
156 |
> |
void set_mac_frame_base(uint32 base) {mac_frame_base = base;} |
157 |
> |
|
158 |
> |
// Get current video mode |
159 |
> |
const video_mode &get_current_mode(void) const {return *current_mode;} |
160 |
> |
|
161 |
> |
// Get Apple mode id for given depth |
162 |
> |
uint16 depth_to_apple_mode(video_depth depth) const {return apple_mode_for_depth[depth];} |
163 |
> |
|
164 |
> |
// Get current color depth |
165 |
> |
uint16 get_apple_mode(void) const {return depth_to_apple_mode(current_mode->depth);} |
166 |
> |
|
167 |
> |
// Get bytes-per-row value for specified resolution/depth |
168 |
> |
// (if the mode isn't supported, make a good guess) |
169 |
> |
uint32 get_bytes_per_row(video_depth depth, uint32 id) const; |
170 |
> |
|
171 |
> |
// Check whether a mode with the specified depth exists on this display |
172 |
> |
bool has_depth(video_depth depth) const; |
173 |
> |
|
174 |
> |
// Mac video driver functions |
175 |
> |
int16 driver_open(void); |
176 |
> |
int16 driver_control(uint16 code, uint32 param, uint32 dce); |
177 |
> |
int16 driver_status(uint16 code, uint32 param); |
178 |
> |
|
179 |
> |
protected: |
180 |
> |
vector<video_mode> modes; // List of supported video modes |
181 |
> |
vector<video_mode>::const_iterator current_mode; // Currently selected video mode |
182 |
> |
|
183 |
> |
uint32 mac_frame_base; // Mac frame buffer address for current mode |
184 |
> |
|
185 |
> |
// Mac video driver per-display private variables/functions |
186 |
> |
private: |
187 |
> |
// Check whether the specified resolution ID is one of the supported resolutions |
188 |
> |
bool has_resolution(uint32 id) const; |
189 |
> |
|
190 |
> |
// Return iterator signifying "invalid mode" |
191 |
> |
vector<video_mode>::const_iterator invalid_mode(void) const {return modes.end();} |
192 |
> |
|
193 |
> |
// Find specified mode (depth/resolution) (or invalid_mode() if not found) |
194 |
> |
vector<video_mode>::const_iterator find_mode(uint16 apple_mode, uint32 id) const; |
195 |
> |
|
196 |
> |
// Find maximum supported depth for given resolution ID |
197 |
> |
video_depth max_depth_of_resolution(uint32 id) const; |
198 |
> |
|
199 |
> |
// Get X/Y size of specified resolution |
200 |
> |
void get_size_of_resolution(uint32 id, uint32 &x, uint32 &y) const; |
201 |
> |
|
202 |
> |
// Set palette to 50% gray |
203 |
> |
void set_gray_palette(void); |
204 |
> |
|
205 |
> |
// Load gamma-corrected black-to-white ramp to palette for direct-color mode |
206 |
> |
void load_ramp_palette(void); |
207 |
> |
|
208 |
> |
// Allocate gamma table of specified size |
209 |
> |
bool allocate_gamma_table(int size); |
210 |
> |
|
211 |
> |
// Set gamma table (0 = build linear ramp) |
212 |
> |
bool set_gamma_table(uint32 user_table); |
213 |
> |
|
214 |
> |
// Switch video mode |
215 |
> |
void switch_mode(vector<video_mode>::const_iterator it, uint32 param, uint32 dce); |
216 |
> |
|
217 |
> |
uint8 slot_id; // NuBus slot ID number |
218 |
> |
static uint8 next_slot_id; // Next available slot ID |
219 |
> |
|
220 |
> |
uint8 palette[256 * 3]; // Color palette, 256 entries, RGB |
221 |
> |
|
222 |
> |
bool luminance_mapping; // Luminance mapping on/off |
223 |
> |
bool interrupts_enabled; // VBL interrupts on/off |
224 |
> |
bool dm_present; // We received a GetVideoParameters call, so the Display Manager seems to be present |
225 |
> |
|
226 |
> |
uint32 gamma_table; // Mac address of gamma table |
227 |
> |
int alloc_gamma_table_size; // Allocated size of gamma table |
228 |
> |
|
229 |
> |
uint16 current_apple_mode; // Currently selected depth/resolution |
230 |
> |
uint32 current_id; |
231 |
> |
uint16 preferred_apple_mode; // Preferred depth/resolution |
232 |
> |
uint32 preferred_id; |
233 |
> |
|
234 |
> |
uint32 slot_param; // Mac address of Slot Manager parameter block |
235 |
> |
|
236 |
> |
// For compatibility reasons with older (pre-Display Manager) versions of |
237 |
> |
// MacOS, the Apple modes must start at 0x80 and be contiguous. Therefore |
238 |
> |
// we maintain an array to map the depth codes to the corresponding Apple |
239 |
> |
// mode. |
240 |
> |
uint16 apple_mode_for_depth[6]; |
241 |
> |
|
242 |
> |
// The following functions are implemented by platform-specific code |
243 |
> |
public: |
244 |
> |
|
245 |
> |
// Called by the video driver to switch the video mode on this display |
246 |
> |
// (must call set_mac_frame_base()) |
247 |
> |
virtual void switch_to_current_mode(void) = 0; |
248 |
> |
|
249 |
> |
// Called by the video driver to set the color palette (in indexed modes) |
250 |
> |
// or the gamma table (in direct modes) |
251 |
> |
virtual void set_palette(uint8 *pal, int num) = 0; |
252 |
|
}; |
253 |
|
|
254 |
< |
// Description of the main (and currently the only) monitor, set by VideoInit() |
255 |
< |
extern monitor_desc VideoMonitor; |
254 |
> |
// Vector of pointers to available monitor descriptions, filled by VideoInit() |
255 |
> |
extern vector<monitor_desc *> VideoMonitors; |
256 |
> |
|
257 |
|
|
258 |
|
extern int16 VideoDriverOpen(uint32 pb, uint32 dce); |
259 |
|
extern int16 VideoDriverControl(uint32 pb, uint32 dce); |
260 |
|
extern int16 VideoDriverStatus(uint32 pb, uint32 dce); |
261 |
|
|
262 |
+ |
|
263 |
|
// System specific and internal functions/data |
264 |
|
extern bool VideoInit(bool classic); |
265 |
|
extern void VideoExit(void); |
269 |
|
extern void VideoInterrupt(void); |
270 |
|
extern void VideoRefresh(void); |
271 |
|
|
171 |
– |
// Called by the video driver to switch the video mode |
172 |
– |
extern void video_switch_to_mode(const video_mode &mode); |
173 |
– |
|
174 |
– |
// Called by the video driver to set the color palette (in indexed modes) |
175 |
– |
// or gamma table (in direct modes) |
176 |
– |
extern void video_set_palette(uint8 *pal, int num); |
177 |
– |
|
178 |
– |
// Check whether a mode with the specified depth exists |
179 |
– |
extern bool video_has_depth(video_depth depth); |
180 |
– |
|
181 |
– |
// Get bytes-per-row value for specified resolution/depth |
182 |
– |
extern uint32 video_bytes_per_row(video_depth depth, uint32 id); |
183 |
– |
|
184 |
– |
// Initialize apple_mode_for_depth[] array from VideoModes list |
185 |
– |
extern void video_init_depth_list(void); |
186 |
– |
|
272 |
|
#endif |