ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/video_vosf.h
(Generate patch)

Comparing BasiliskII/src/Unix/video_vosf.h (file contents):
Revision 1.12 by gbeauche, 2001-01-11T18:00:40Z vs.
Revision 1.13 by gbeauche, 2001-01-28T14:05:19Z

# Line 1 | Line 1
1   /*
2   *  video_vosf.h - Video/graphics emulation, video on SEGV signals support
3   *
4 < *  Basilisk II (C) 1997-2000 Christian Bauer
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
# Line 45 | Line 45 | static void * allocate_framebuffer(uint3
45  
46  
47   /*
48 *      Screen depth identification
49 */
50
51 enum {
52        ID_DEPTH_UNKNOWN = -1,
53        ID_DEPTH_1,
54        ID_DEPTH_8,
55        ID_DEPTH_15,
56        ID_DEPTH_16,
57        ID_DEPTH_24,
58        ID_DEPTH_32 = ID_DEPTH_24,
59        ID_DEPTH_COUNT
60 };
61
62 static int depth_id(int depth)
63 {
64        int id;
65        switch (depth) {
66                case 1  : id = ID_DEPTH_1;      break;
67                case 8  : id = ID_DEPTH_8;      break;
68                case 15 : id = ID_DEPTH_15;     break;
69                case 16 : id = ID_DEPTH_16;     break;
70                case 24 : id = ID_DEPTH_24;     break;
71                case 32 : id = ID_DEPTH_32;     break;
72                default : id = ID_DEPTH_UNKNOWN;
73        }
74        return id;
75 }
76
77
78 /*
79 *      Frame buffer copy function templates
80 */
81
82 // No conversion required
83
84 #define MEMCPY_PROFITABLE
85 #ifdef MEMCPY_PROFITABLE
86 static void do_fbcopy_raw(uint8 * dest, const uint8 * source, uint32 length)
87 {
88        memcpy(dest, source, length);
89 }
90 #else
91 #define FB_BLIT_1(dst, src)     (dst = (src))
92 #define FB_BLIT_2(dst, src)     (dst = (src))
93 #define FB_DEPTH                        0
94 #define FB_FUNC_NAME            do_fbcopy_raw
95 #include "video_blit.h"
96 #endif
97
98
99 // RGB 555
100
101 #ifdef WORDS_BIGENDIAN
102 # define FB_FUNC_NAME do_fbcopy_15_obo
103 #else
104 # define FB_FUNC_NAME do_fbcopy_15_nbo
105 #endif
106
107 #define FB_BLIT_1(dst, src) \
108        (dst = (((src) >> 8) & 0xff) | (((src) & 0xff) << 8))
109        
110 #define FB_BLIT_2(dst, src) \
111        (dst = (((src) >> 8) & 0x00ff00ff) | (((src) & 0x00ff00ff) << 8))
112
113 #define FB_DEPTH 15
114 #include "video_blit.h"
115
116
117 // RGB 565
118
119 #ifdef WORDS_BIGENDIAN
120
121 // native byte order
122
123 #define FB_BLIT_1(dst, src) \
124        (dst = (((src) & 0x1f) | (((src) << 1) & 0xffc0)))
125
126 #define FB_BLIT_2(dst, src) \
127        (dst = (((src) & 0x001f001f) | (((src) << 1) & 0xffc0ffc0)))
128
129 #define FB_DEPTH 16
130 #define FB_FUNC_NAME do_fbcopy_16_nbo
131 #include "video_blit.h"
132
133 // opposite byte order
134
135 #define FB_BLIT_1(dst, src) \
136        (dst = ((((src) >> 7) & 0xff) | (((src) << 9) & 0xc000) | (((src) << 8) & 0x1f00)))
137
138 #define FB_BLIT_2(dst, src) \
139        (dst = ((((src) >> 7) & 0x00ff00ff) | (((src) << 9) & 0xc000c000) | (((src) << 8) & 0x1f001f00)))
140
141 #define FB_DEPTH 16
142 #define FB_FUNC_NAME do_fbcopy_16_obo
143 #include "video_blit.h"
144
145 #else
146
147 // native byte order
148
149 #define FB_BLIT_1(dst, src) \
150        (dst = (((src) >> 8) & 0x001f) | (((src) << 9) & 0xfe00) | (((src) >> 7) & 0x01c0))
151        
152 #define FB_BLIT_2(dst, src) \
153        (dst = (((src) >> 8) & 0x001f001f) | (((src) << 9) & 0xfe00fe00) | (((src) >> 7) & 0x01c001c0))
154
155 #define FB_DEPTH 16
156 #define FB_FUNC_NAME do_fbcopy_16_nbo
157 #include "video_blit.h"
158
159 // opposite byte order (untested)
160
161 #define FB_BLIT_1(dst, src) \
162        (dst = (((src) & 0x1f00) | (((src) << 1) & 0xe0fe) | (((src) >> 15) & 1)))
163
164 #define FB_BLIT_2(dst, src) \
165        (dst = (((src) & 0x1f001f00) | (((src) << 1) & 0xe0fee0fe) | (((src) >> 15) & 0x10001)))
166
167 #define FB_DEPTH 16
168 #define FB_FUNC_NAME do_fbcopy_16_obo
169 #include "video_blit.h"
170
171 #endif
172
173 // RGB 888
174
175 #ifdef WORDS_BIGENDIAN
176 # define FB_FUNC_NAME do_fbcopy_24_obo
177 #else
178 # define FB_FUNC_NAME do_fbcopy_24_nbo
179 #endif
180
181 #define FB_BLIT_1(dst, src) \
182        (dst = (src))
183
184 #define FB_BLIT_2(dst, src) \
185        (dst = (((src) >> 24) & 0xff) | (((src) >> 8) & 0xff00) | (((src) & 0xff00) << 8) | (((src) & 0xff) << 24))
186
187 #define FB_DEPTH 24
188 #include "video_blit.h"
189
190
191 /*
192 *      Frame buffer copy functions map table
193 */
194
195 typedef void (*fbcopy_func)(uint8 *, const uint8 *, uint32);
196 static fbcopy_func do_update_framebuffer;
197
198 #define FBCOPY_FUNC(aHandler) do_ ## aHandler
199
200 #if REAL_ADDRESSING || DIRECT_ADDRESSING
201 #define WD(X) { FBCOPY_FUNC(X), FBCOPY_FUNC(X) }
202 #else
203 #define WD(X) { FBCOPY_FUNC(fbcopy_raw), FBCOPY_FUNC(fbcopy_raw) }
204 #endif
205
206 // fb_copy_funcs[depth_id][native_byte_order][dga_mode]
207 // NT  : not tested
208 // OK  : has been successfully tested
209 // NBO : native byte order (X server vs. client)
210 // OBO : opposite byte order (X server vs. client)
211 static fbcopy_func fbcopy_funcs[ID_DEPTH_COUNT][2][2] = {
212 #ifdef WORDS_BIGENDIAN
213                                /*      opposite byte order             native byte order       */
214 /*  1 bpp */    {       WD(fbcopy_raw)          ,       WD(fbcopy_raw)          },      // NT
215 /*  8 bpp */    {       WD(fbcopy_raw)          ,       WD(fbcopy_raw)          },      // OK (NBO)
216 /* 15 bpp */    {       WD(fbcopy_15_obo)       ,       WD(fbcopy_raw)          },      // OK (OBO)
217 /* 16 bpp */    {       WD(fbcopy_16_obo)       ,       WD(fbcopy_16_nbo)       },      // OK (OBO)
218 /* 24 bpp */    {       WD(fbcopy_24_obo)       ,       WD(fbcopy_raw)          }       // OK (OBO)
219 #else
220                                /*      opposite byte order             native byte order       */
221 /*  1 bpp */    {       WD(fbcopy_raw)          ,       WD(fbcopy_raw)          },      // NT
222 /*  8 bpp */    {       WD(fbcopy_raw)          ,       WD(fbcopy_raw)          },      // OK (NBO)
223 /* 15 bpp */    {       WD(fbcopy_raw)          ,       WD(fbcopy_15_nbo)       },      // OK (NBO)
224 /* 16 bpp */    {       WD(fbcopy_16_obo)       ,       WD(fbcopy_16_nbo)       },      // OK (NBO)
225 /* 24 bpp */    {       WD(fbcopy_raw)          ,       WD(fbcopy_24_nbo)       }       // OK (NBO)
226 #endif
227 };
228
229 #undef WD
230
231 #define FBCOPY_FUNC_ERROR \
232        ErrorAlert("Invalid screen depth")
233
234 #define GET_FBCOPY_FUNC(aDepth, aNativeByteOrder, aDisplay) \
235        ((depth_id(aDepth) == ID_DEPTH_UNKNOWN) ? ( FBCOPY_FUNC_ERROR, (fbcopy_func)0 ) : \
236        fbcopy_funcs[depth_id(aDepth)][(aNativeByteOrder)][(aDisplay) == DISPLAY_DGA ? 1 : 0])
237
238
239 /*
48   *      Screen fault handler
49   */
50  
# Line 254 | Line 62 | static inline void do_handle_screen_faul
62                  LOCK_VOSF;
63                  PFLAG_SET(page);
64                  mprotect(page_ad, mainBuffer.pageSize, PROT_READ | PROT_WRITE);
65 +                mainBuffer.dirty = true;
66                  UNLOCK_VOSF;
67                  return;
68          }
# Line 350 | Line 159 | static bool Screen_fault_handler_init()
159   *      Update display for Windowed mode and VOSF
160   */
161  
162 + // From video_blit.cpp
163 + extern void (*Screen_blit)(uint8 * dest, const uint8 * source, uint32 length);
164 + extern bool Screen_blitter_init(XVisualInfo * visual_info, bool native_byte_order);
165 +
166   /*      How can we deal with array overrun conditions ?
167          
168          The state of the framebuffer pages that have been touched are maintained
# Line 364 | Line 177 | Terminology
177  
178   Rough process
179          
180 <        The update routines must determine which pages have to blitted to the
180 >        The update routines must determine which pages have to be blitted to the
181          screen. This job consists in finding the first_page that was touched.
182          i.e. find the next page that is SET. Then, finding how many pages were
183          touched starting from first_page. i.e. find the next page that is CLEAR.
184  
185 < Two cases
185 > There are two cases to check:
186  
187          - Last Page is CLEAR: find_next_page_set() will reach the SET Page Guard
188          but it is beyond the valid pageCount value. Therefore, we exit from the
# Line 441 | Line 254 | static inline void update_display_window
254                          // Update the_host_buffer and copy of the_buffer
255                          i = y1 * bytes_per_row + (x1 >> 3);
256                          for (j = y1; j <= y2; j++) {
257 <                                do_update_framebuffer(the_host_buffer + i, the_buffer + i, width >> 3);
257 >                                Screen_blit(the_host_buffer + i, the_buffer + i, width >> 3);
258                                  memcpy(the_buffer_copy + i, the_buffer + i, width >> 3);
259                                  i += bytes_per_row;
260                          }
# Line 478 | Line 291 | static inline void update_display_window
291                          // Update the_host_buffer and copy of the_buffer
292                          i = y1 * bytes_per_row + x1 * bytes_per_pixel;
293                          for (j = y1; j <= y2; j++) {
294 <                                do_update_framebuffer(the_host_buffer + i, the_buffer + i, bytes_per_pixel * width);
294 >                                Screen_blit(the_host_buffer + i, the_buffer + i, bytes_per_pixel * width);
295                                  memcpy(the_buffer_copy + i, the_buffer + i, bytes_per_pixel * width);
296                                  i += bytes_per_row;
297                          }
# Line 489 | Line 302 | static inline void update_display_window
302                  else
303                          XPutImage(x_display, the_win, the_gc, img, x1, y1, x1, y1, width, height);
304          }
305 +        mainBuffer.dirty = false;
306   }
307  
308  
# Line 555 | Line 369 | static inline void update_display_dga_vo
369                  const int width = x2 - x1 + 1;
370                  i = y1 * bytes_per_row + x1 * bytes_per_pixel;
371                  for (j = y1; j <= y2; j++) {
372 <                        do_update_framebuffer(the_host_buffer + i, the_buffer + i, bytes_per_pixel * width);
372 >                        Screen_blit(the_host_buffer + i, the_buffer + i, bytes_per_pixel * width);
373                          memcpy(the_buffer_copy + i, the_buffer + i, bytes_per_pixel * width);
374                          i += bytes_per_row;
375                  }
376          }
377 +        mainBuffer.dirty = false;
378   }
379   #endif
380  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines