ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/include/video.h
Revision: 1.8
Committed: 2001-06-28T21:20:00Z (23 years, 4 months ago) by cebix
Content type: text/plain
Branch: MAIN
Changes since 1.7: +36 -5 lines
Log Message:
video_x.cpp supports resolution switching in windowed mode: the available
resolutions are 512x384, 640x480, 800x600, 1024x768 and 1280x1024 (the prefs
editor has to be updated to reflect this). The resolution selected in the
prefs editor is used as the default, but it can be changed in the Monitors
control panel. So far only tested with direct addressing.

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     // 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 cebix 1.1 };
35    
36 cebix 1.8 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 cebix 1.6 inline bool IsDirectMode(video_depth depth)
47     {
48     return depth == VDEPTH_16BIT || depth == VDEPTH_32BIT;
49     }
50    
51 cebix 1.8 inline bool IsDirectMode(uint16 mode)
52     {
53     return IsDirectMode(AppleModeToDepth(mode));
54     }
55    
56     inline video_depth DepthModeForPixelDepth(int depth)
57 cebix 1.6 {
58 cebix 1.8 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 cebix 1.6 }
68 cebix 1.1
69 cebix 1.8 // 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 cebix 1.6 {
72 cebix 1.8 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 cebix 1.6 }
81    
82     // Description of one video mode
83     struct video_mode {
84 cebix 1.1 uint32 x; // X size of screen (pixels)
85     uint32 y; // Y size of screen (pixels)
86 cebix 1.6 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 cebix 1.8 extern std::vector<video_mode> VideoModes;
98 cebix 1.6
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 cebix 1.1 };
104    
105 cebix 1.6 extern monitor_desc VideoMonitor; // Description of the main monitor, set by VideoInit()
106 cebix 1.1
107 cebix 1.2 extern int16 VideoDriverOpen(uint32 pb, uint32 dce);
108     extern int16 VideoDriverControl(uint32 pb, uint32 dce);
109     extern int16 VideoDriverStatus(uint32 pb, uint32 dce);
110 cebix 1.1
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 cebix 1.4 extern void VideoRefresh(void);
119 cebix 1.1
120 cebix 1.7 extern void video_switch_to_mode(const video_mode &mode);
121 cebix 1.1 extern void video_set_palette(uint8 *pal);
122    
123     #endif