ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/include/video.h
Revision: 1.9
Committed: 2001-07-01T00:46:38Z (23 years, 2 months ago) by cebix
Content type: text/plain
Branch: MAIN
Changes since 1.8: +55 -3 lines
Log Message:
- added some documentation
- VidLocal.sp -> VidLocal.slot_param
- X11 color map is loaded with ramp upon startup to avoid the annoying black
  screen during initialization

File Contents

# User Rev Content
1 cebix 1.1 /*
2     * video.h - Video/graphics emulation
3     *
4 cebix 1.5 * Basilisk II (C) 1997-2001 Christian Bauer
5 cebix 1.1 *
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 cebix 1.6 #include <vector>
25    
26 cebix 1.9 /*
27     Some of the terminology here is completely frelled. In Basilisk II, a
28     "video mode" refers to a combination of resolution and color depth, and
29     this information is stored in a video_mode structure. In Apple
30     documentation, a "mode" historically refers to the color depth only
31     (because old Macs had fixed-frequency monitors and could not change the
32     resolution). These "modes" are assigned a number (0x80, 0x81, etc.),
33     which we here call "Apple mode". When Macs learned how to deal with
34     multiscan monitors, Apple introduced another type of "mode", also having
35     numbers starting from 0x80 but refrerring to the resolution and/or video
36     timing of the display (it's possible to have two modes with the same
37     dimension but different refresh rates). We call this a "resolution ID".
38     The combination of "Apple mode" and "ID" corresponds to a Basilisk II
39     "video mode". To make the confusion worse, the video driver control call
40     that sets the color depth is called "SetMode" while the one that sets
41     both depth and resolution is "SwitchMode"...
42     */
43    
44 cebix 1.6 // Color depth codes
45     enum video_depth {
46     VDEPTH_1BIT, // 2 colors
47     VDEPTH_2BIT, // 4 colors
48     VDEPTH_4BIT, // 16 colors
49     VDEPTH_8BIT, // 256 colors
50     VDEPTH_16BIT, // "Thousands"
51     VDEPTH_32BIT // "Millions"
52 cebix 1.1 };
53    
54 cebix 1.8 inline uint16 DepthToAppleMode(video_depth depth)
55     {
56     return depth + 0x80;
57     }
58    
59     inline video_depth AppleModeToDepth(uint16 mode)
60     {
61     return video_depth(mode - 0x80);
62     }
63    
64 cebix 1.6 inline bool IsDirectMode(video_depth depth)
65     {
66     return depth == VDEPTH_16BIT || depth == VDEPTH_32BIT;
67     }
68    
69 cebix 1.8 inline bool IsDirectMode(uint16 mode)
70     {
71     return IsDirectMode(AppleModeToDepth(mode));
72     }
73    
74 cebix 1.9 // Return the depth code that corresponds to the specified bits-per-pixel value
75 cebix 1.8 inline video_depth DepthModeForPixelDepth(int depth)
76 cebix 1.6 {
77 cebix 1.8 switch (depth) {
78     case 1: return VDEPTH_1BIT;
79     case 2: return VDEPTH_2BIT;
80     case 4: return VDEPTH_4BIT;
81     case 8: return VDEPTH_8BIT;
82     case 15: case 16: return VDEPTH_16BIT;
83     case 24: case 32: return VDEPTH_32BIT;
84     default: return VDEPTH_1BIT;
85     }
86 cebix 1.6 }
87 cebix 1.1
88 cebix 1.9 // Return a bytes-per-row value (assuming no padding) for the specified depth and pixel width
89 cebix 1.8 inline uint32 TrivialBytesPerRow(uint32 width, video_depth depth)
90 cebix 1.6 {
91 cebix 1.8 switch (depth) {
92     case VDEPTH_1BIT: return width / 8;
93     case VDEPTH_2BIT: return width / 4;
94     case VDEPTH_4BIT: return width / 2;
95     case VDEPTH_8BIT: return width;
96     case VDEPTH_16BIT: return width * 2;
97     case VDEPTH_32BIT: return width * 4;
98     }
99 cebix 1.6 }
100    
101 cebix 1.9 /*
102     You are not completely free in your selection of depth/resolution
103     combinations:
104     1) the lowest supported color depth must be available in all
105     resolutions
106     2) if one resolution provides a certain color depth, it must also
107     provide all lower supported depths
108    
109     For example, it is possible to have this set of modes:
110     640x480 @ 8 bit
111     640x480 @ 32 bit
112     800x600 @ 8 bit
113     800x600 @ 32 bit
114     1024x768 @ 8 bit
115    
116     But this is not possible (violates rule 1):
117     640x480 @ 8 bit
118     800x600 @ 8 bit
119     1024x768 @ 1 bit
120    
121     And neither is this (violates rule 2, 640x480 @ 16 bit is missing):
122     640x480 @ 8 bit
123     640x480 @ 32 bit
124     800x600 @ 8 bit
125     800x600 @ 16 bit
126     1024x768 @ 8 bit
127     */
128    
129     // Description of a video mode
130 cebix 1.6 struct video_mode {
131 cebix 1.1 uint32 x; // X size of screen (pixels)
132     uint32 y; // Y size of screen (pixels)
133 cebix 1.6 uint32 resolution_id; // Resolution ID (should be >= 0x80 and uniquely identify the sets of modes with the same X/Y size)
134     uint32 bytes_per_row; // Bytes per row of frame buffer
135     video_depth depth; // Color depth (see definitions above)
136     };
137    
138     inline bool IsDirectMode(const video_mode &mode)
139     {
140     return IsDirectMode(mode.depth);
141     }
142    
143     // List of all supported video modes
144 cebix 1.8 extern std::vector<video_mode> VideoModes;
145 cebix 1.6
146     // Description for one (possibly virtual) monitor
147     struct monitor_desc {
148     uint32 mac_frame_base; // Mac frame buffer address
149     video_mode mode; // Currently selected video mode description
150 cebix 1.1 };
151    
152 cebix 1.9 // Description of the main (and currently the only) monitor, set by VideoInit()
153     extern monitor_desc VideoMonitor;
154 cebix 1.1
155 cebix 1.2 extern int16 VideoDriverOpen(uint32 pb, uint32 dce);
156     extern int16 VideoDriverControl(uint32 pb, uint32 dce);
157     extern int16 VideoDriverStatus(uint32 pb, uint32 dce);
158 cebix 1.1
159     // System specific and internal functions/data
160     extern bool VideoInit(bool classic);
161     extern void VideoExit(void);
162    
163     extern void VideoQuitFullScreen(void);
164    
165     extern void VideoInterrupt(void);
166 cebix 1.4 extern void VideoRefresh(void);
167 cebix 1.1
168 cebix 1.9 // Called by the video driver to switch the video mode
169 cebix 1.7 extern void video_switch_to_mode(const video_mode &mode);
170 cebix 1.9
171     // Called by the video driver to set the color palette (in indexed modes)
172     // or gamma table (in direct modes)
173 cebix 1.1 extern void video_set_palette(uint8 *pal);
174    
175     #endif