23 |
|
|
24 |
|
#include <vector> |
25 |
|
|
26 |
+ |
#ifndef NO_STD_NAMESPACE |
27 |
+ |
using std::vector; |
28 |
+ |
#endif |
29 |
+ |
|
30 |
+ |
/* |
31 |
+ |
Some of the terminology here is completely frelled. In Basilisk II, a |
32 |
+ |
"video mode" refers to a combination of resolution and color depth, and |
33 |
+ |
this information is stored in a video_mode structure. In Apple |
34 |
+ |
documentation, a "mode" historically refers to the color depth only |
35 |
+ |
(because old Macs had fixed-frequency monitors and could not change the |
36 |
+ |
resolution). These "modes" are assigned a number (0x80, 0x81, etc.), |
37 |
+ |
which we here call "Apple mode". When Macs learned how to deal with |
38 |
+ |
multiscan monitors, Apple introduced another type of "mode", also having |
39 |
+ |
numbers starting from 0x80 but refrerring to the resolution and/or video |
40 |
+ |
timing of the display (it's possible to have two modes with the same |
41 |
+ |
dimension but different refresh rates). We call this a "resolution ID". |
42 |
+ |
The combination of "Apple mode" and "ID" corresponds to a Basilisk II |
43 |
+ |
"video mode". To make the confusion worse, the video driver control call |
44 |
+ |
that sets the color depth is called "SetMode" while the one that sets |
45 |
+ |
both depth and resolution is "SwitchMode"... |
46 |
+ |
*/ |
47 |
+ |
|
48 |
|
// Color depth codes |
49 |
|
enum video_depth { |
50 |
|
VDEPTH_1BIT, // 2 colors |
55 |
|
VDEPTH_32BIT // "Millions" |
56 |
|
}; |
57 |
|
|
58 |
+ |
inline uint16 DepthToAppleMode(video_depth depth) |
59 |
+ |
{ |
60 |
+ |
return depth + 0x80; |
61 |
+ |
} |
62 |
+ |
|
63 |
+ |
inline video_depth AppleModeToDepth(uint16 mode) |
64 |
+ |
{ |
65 |
+ |
return video_depth(mode - 0x80); |
66 |
+ |
} |
67 |
+ |
|
68 |
|
inline bool IsDirectMode(video_depth depth) |
69 |
|
{ |
70 |
|
return depth == VDEPTH_16BIT || depth == VDEPTH_32BIT; |
71 |
|
} |
72 |
|
|
73 |
< |
inline uint16 DepthToAppleMode(video_depth depth) |
73 |
> |
inline bool IsDirectMode(uint16 mode) |
74 |
|
{ |
75 |
< |
return depth + 0x80; |
75 |
> |
return IsDirectMode(AppleModeToDepth(mode)); |
76 |
|
} |
77 |
|
|
78 |
< |
inline video_depth AppleModeToDepth(uint16 mode) |
78 |
> |
// Return the depth code that corresponds to the specified bits-per-pixel value |
79 |
> |
inline video_depth DepthModeForPixelDepth(int depth) |
80 |
|
{ |
81 |
< |
return video_depth(mode - 0x80); |
81 |
> |
switch (depth) { |
82 |
> |
case 1: return VDEPTH_1BIT; |
83 |
> |
case 2: return VDEPTH_2BIT; |
84 |
> |
case 4: return VDEPTH_4BIT; |
85 |
> |
case 8: return VDEPTH_8BIT; |
86 |
> |
case 15: case 16: return VDEPTH_16BIT; |
87 |
> |
case 24: case 32: return VDEPTH_32BIT; |
88 |
> |
default: return VDEPTH_1BIT; |
89 |
> |
} |
90 |
|
} |
91 |
|
|
92 |
< |
// Description of one video mode |
92 |
> |
// Return a bytes-per-row value (assuming no padding) for the specified depth and pixel width |
93 |
> |
inline uint32 TrivialBytesPerRow(uint32 width, video_depth depth) |
94 |
> |
{ |
95 |
> |
switch (depth) { |
96 |
> |
case VDEPTH_1BIT: return width / 8; |
97 |
> |
case VDEPTH_2BIT: return width / 4; |
98 |
> |
case VDEPTH_4BIT: return width / 2; |
99 |
> |
case VDEPTH_8BIT: return width; |
100 |
> |
case VDEPTH_16BIT: return width * 2; |
101 |
> |
case VDEPTH_32BIT: return width * 4; |
102 |
> |
default: return width; |
103 |
> |
} |
104 |
> |
} |
105 |
> |
|
106 |
> |
/* |
107 |
> |
You are not completely free in your selection of depth/resolution |
108 |
> |
combinations: |
109 |
> |
1) the lowest supported color depth must be available in all |
110 |
> |
resolutions |
111 |
> |
2) if one resolution provides a certain color depth, it must also |
112 |
> |
provide all lower supported depths |
113 |
> |
|
114 |
> |
For example, it is possible to have this set of modes: |
115 |
> |
640x480 @ 8 bit |
116 |
> |
640x480 @ 32 bit |
117 |
> |
800x600 @ 8 bit |
118 |
> |
800x600 @ 32 bit |
119 |
> |
1024x768 @ 8 bit |
120 |
> |
|
121 |
> |
But this is not possible (violates rule 1): |
122 |
> |
640x480 @ 8 bit |
123 |
> |
800x600 @ 8 bit |
124 |
> |
1024x768 @ 1 bit |
125 |
> |
|
126 |
> |
And neither is this (violates rule 2, 640x480 @ 16 bit is missing): |
127 |
> |
640x480 @ 8 bit |
128 |
> |
640x480 @ 32 bit |
129 |
> |
800x600 @ 8 bit |
130 |
> |
800x600 @ 16 bit |
131 |
> |
1024x768 @ 8 bit |
132 |
> |
*/ |
133 |
> |
|
134 |
> |
// Description of a video mode |
135 |
|
struct video_mode { |
136 |
|
uint32 x; // X size of screen (pixels) |
137 |
|
uint32 y; // Y size of screen (pixels) |
154 |
|
video_mode mode; // Currently selected video mode description |
155 |
|
}; |
156 |
|
|
157 |
< |
extern monitor_desc VideoMonitor; // Description of the main monitor, set by VideoInit() |
157 |
> |
// Description of the main (and currently the only) monitor, set by VideoInit() |
158 |
> |
extern monitor_desc VideoMonitor; |
159 |
|
|
160 |
|
extern int16 VideoDriverOpen(uint32 pb, uint32 dce); |
161 |
|
extern int16 VideoDriverControl(uint32 pb, uint32 dce); |
170 |
|
extern void VideoInterrupt(void); |
171 |
|
extern void VideoRefresh(void); |
172 |
|
|
173 |
+ |
// Called by the video driver to switch the video mode |
174 |
|
extern void video_switch_to_mode(const video_mode &mode); |
175 |
< |
extern void video_set_palette(uint8 *pal); |
175 |
> |
|
176 |
> |
// Called by the video driver to set the color palette (in indexed modes) |
177 |
> |
// or gamma table (in direct modes) |
178 |
> |
extern void video_set_palette(uint8 *pal, int num); |
179 |
|
|
180 |
|
#endif |