1 |
/* |
2 |
* video.h - Video/graphics emulation |
3 |
* |
4 |
* Basilisk II (C) 1997-2001 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 |
8 |
* the Free Software Foundation; either version 2 of the License, or |
9 |
* (at your option) any later version. |
10 |
* |
11 |
* This program is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
15 |
* |
16 |
* You should have received a copy of the GNU General Public License |
17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 |
*/ |
20 |
|
21 |
#ifndef VIDEO_H |
22 |
#define VIDEO_H |
23 |
|
24 |
#include <vector> |
25 |
|
26 |
// Color depth codes |
27 |
enum video_depth { |
28 |
VDEPTH_1BIT, // 2 colors |
29 |
VDEPTH_2BIT, // 4 colors |
30 |
VDEPTH_4BIT, // 16 colors |
31 |
VDEPTH_8BIT, // 256 colors |
32 |
VDEPTH_16BIT, // "Thousands" |
33 |
VDEPTH_32BIT // "Millions" |
34 |
}; |
35 |
|
36 |
inline uint16 DepthToAppleMode(video_depth depth) |
37 |
{ |
38 |
return depth + 0x80; |
39 |
} |
40 |
|
41 |
inline video_depth AppleModeToDepth(uint16 mode) |
42 |
{ |
43 |
return video_depth(mode - 0x80); |
44 |
} |
45 |
|
46 |
inline bool IsDirectMode(video_depth depth) |
47 |
{ |
48 |
return depth == VDEPTH_16BIT || depth == VDEPTH_32BIT; |
49 |
} |
50 |
|
51 |
inline bool IsDirectMode(uint16 mode) |
52 |
{ |
53 |
return IsDirectMode(AppleModeToDepth(mode)); |
54 |
} |
55 |
|
56 |
inline video_depth DepthModeForPixelDepth(int depth) |
57 |
{ |
58 |
switch (depth) { |
59 |
case 1: return VDEPTH_1BIT; |
60 |
case 2: return VDEPTH_2BIT; |
61 |
case 4: return VDEPTH_4BIT; |
62 |
case 8: return VDEPTH_8BIT; |
63 |
case 15: case 16: return VDEPTH_16BIT; |
64 |
case 24: case 32: return VDEPTH_32BIT; |
65 |
default: return VDEPTH_1BIT; |
66 |
} |
67 |
} |
68 |
|
69 |
// Return a bytes-per-row value that assumes no padding for specified depth and pixel width |
70 |
inline uint32 TrivialBytesPerRow(uint32 width, video_depth depth) |
71 |
{ |
72 |
switch (depth) { |
73 |
case VDEPTH_1BIT: return width / 8; |
74 |
case VDEPTH_2BIT: return width / 4; |
75 |
case VDEPTH_4BIT: return width / 2; |
76 |
case VDEPTH_8BIT: return width; |
77 |
case VDEPTH_16BIT: return width * 2; |
78 |
case VDEPTH_32BIT: return width * 4; |
79 |
} |
80 |
} |
81 |
|
82 |
// Description of one video mode |
83 |
struct video_mode { |
84 |
uint32 x; // X size of screen (pixels) |
85 |
uint32 y; // Y size of screen (pixels) |
86 |
uint32 resolution_id; // Resolution ID (should be >= 0x80 and uniquely identify the sets of modes with the same X/Y size) |
87 |
uint32 bytes_per_row; // Bytes per row of frame buffer |
88 |
video_depth depth; // Color depth (see definitions above) |
89 |
}; |
90 |
|
91 |
inline bool IsDirectMode(const video_mode &mode) |
92 |
{ |
93 |
return IsDirectMode(mode.depth); |
94 |
} |
95 |
|
96 |
// List of all supported video modes |
97 |
extern std::vector<video_mode> VideoModes; |
98 |
|
99 |
// Description for one (possibly virtual) monitor |
100 |
struct monitor_desc { |
101 |
uint32 mac_frame_base; // Mac frame buffer address |
102 |
video_mode mode; // Currently selected video mode description |
103 |
}; |
104 |
|
105 |
extern monitor_desc VideoMonitor; // Description of the main monitor, set by VideoInit() |
106 |
|
107 |
extern int16 VideoDriverOpen(uint32 pb, uint32 dce); |
108 |
extern int16 VideoDriverControl(uint32 pb, uint32 dce); |
109 |
extern int16 VideoDriverStatus(uint32 pb, uint32 dce); |
110 |
|
111 |
// System specific and internal functions/data |
112 |
extern bool VideoInit(bool classic); |
113 |
extern void VideoExit(void); |
114 |
|
115 |
extern void VideoQuitFullScreen(void); |
116 |
|
117 |
extern void VideoInterrupt(void); |
118 |
extern void VideoRefresh(void); |
119 |
|
120 |
extern void video_switch_to_mode(const video_mode &mode); |
121 |
extern void video_set_palette(uint8 *pal); |
122 |
|
123 |
#endif |