197 |
|
int pageBits; // Shift count to get the page number |
198 |
|
uint32 pageCount; // Number of pages allocated to the screen |
199 |
|
|
200 |
< |
uint8 * dirtyPages; // Table of flags set if page was altered |
200 |
> |
char * dirtyPages; // Table of flags set if page was altered |
201 |
|
ScreenPageInfo * pageInfo; // Table of mappings page -> Mac scanlines |
202 |
|
}; |
203 |
|
|
204 |
|
static ScreenInfo mainBuffer; |
205 |
|
|
206 |
< |
#define PFLAG_SET(page) mainBuffer.dirtyPages[page] = 1 |
207 |
< |
#define PFLAG_CLEAR(page) mainBuffer.dirtyPages[page] = 0 |
208 |
< |
#define PFLAG_ISSET(page) mainBuffer.dirtyPages[page] |
209 |
< |
#define PFLAG_ISCLEAR(page) (mainBuffer.dirtyPages[page] == 0) |
206 |
> |
#define PFLAG_SET_VALUE 0x00 |
207 |
> |
#define PFLAG_CLEAR_VALUE 0x01 |
208 |
> |
#define PFLAG_SET_VALUE_4 0x00000000 |
209 |
> |
#define PFLAG_CLEAR_VALUE_4 0x01010101 |
210 |
> |
#define PFLAG_SET(page) mainBuffer.dirtyPages[page] = PFLAG_SET_VALUE |
211 |
> |
#define PFLAG_CLEAR(page) mainBuffer.dirtyPages[page] = PFLAG_CLEAR_VALUE |
212 |
> |
#define PFLAG_ISSET(page) (mainBuffer.dirtyPages[page] == PFLAG_SET_VALUE) |
213 |
> |
#define PFLAG_ISCLEAR(page) (mainBuffer.dirtyPages[page] != PFLAG_SET_VALUE) |
214 |
> |
|
215 |
|
#ifdef UNALIGNED_PROFITABLE |
216 |
< |
# define PFLAG_ISCLEAR_4(page) (*((uint32 *)(mainBuffer.dirtyPages + page)) == 0) |
216 |
> |
# define PFLAG_ISSET_4(page) (*((uint32 *)(mainBuffer.dirtyPages + (page))) == PFLAG_SET_VALUE_4) |
217 |
> |
# define PFLAG_ISCLEAR_4(page) (*((uint32 *)(mainBuffer.dirtyPages + (page))) == PFLAG_CLEAR_VALUE_4) |
218 |
> |
#else |
219 |
> |
# define PFLAG_ISSET_4(page) \ |
220 |
> |
PFLAG_ISSET(page ) && PFLAG_ISSET(page+1) \ |
221 |
> |
&& PFLAG_ISSET(page+2) && PFLAG_ISSET(page+3) |
222 |
> |
# define PFLAG_ISCLEAR_4(page) \ |
223 |
> |
PFLAG_ISCLEAR(page ) && PFLAG_ISCLEAR(page+1) \ |
224 |
> |
&& PFLAG_ISCLEAR(page+2) && PFLAG_ISCLEAR(page+3) |
225 |
> |
#endif |
226 |
> |
|
227 |
> |
// Set the selected page range [ first_page, last_page [ into the SET state |
228 |
> |
#define PFLAG_SET_RANGE(first_page, last_page) \ |
229 |
> |
memset(mainBuffer.dirtyPages + (first_page), PFLAG_SET_VALUE, \ |
230 |
> |
(last_page) - (first_page)) |
231 |
> |
|
232 |
> |
// Set the selected page range [ first_page, last_page [ into the CLEAR state |
233 |
> |
#define PFLAG_CLEAR_RANGE(first_page, last_page) \ |
234 |
> |
memset(mainBuffer.dirtyPages + (first_page), PFLAG_CLEAR_VALUE, \ |
235 |
> |
(last_page) - (first_page)) |
236 |
> |
|
237 |
> |
#define PFLAG_SET_ALL \ |
238 |
> |
PFLAG_SET_RANGE(0, mainBuffer.pageCount) |
239 |
> |
|
240 |
> |
#define PFLAG_CLEAR_ALL \ |
241 |
> |
PFLAG_CLEAR_RANGE(0, mainBuffer.pageCount) |
242 |
> |
|
243 |
> |
// Set the following macro definition to 1 if your system |
244 |
> |
// provides a really fast strchr() implementation |
245 |
> |
//#define HAVE_FAST_STRCHR 0 |
246 |
> |
|
247 |
> |
static inline int find_next_page_set(int page) |
248 |
> |
{ |
249 |
> |
#if HAVE_FAST_STRCHR |
250 |
> |
char *match = strchr(mainBuffer.dirtyPages + page, PFLAG_SET_VALUE); |
251 |
> |
return match ? match - mainBuffer.dirtyPages : mainBuffer.pageCount; |
252 |
|
#else |
253 |
< |
# define PFLAG_ISCLEAR_4(page) \ |
254 |
< |
(mainBuffer.dirtyPages[page ] == 0) \ |
255 |
< |
&& (mainBuffer.dirtyPages[page+1] == 0) \ |
256 |
< |
&& (mainBuffer.dirtyPages[page+2] == 0) \ |
257 |
< |
&& (mainBuffer.dirtyPages[page+3] == 0) |
253 |
> |
while (PFLAG_ISCLEAR_4(page)) |
254 |
> |
page += 4; |
255 |
> |
while (PFLAG_ISCLEAR(page)) |
256 |
> |
page++; |
257 |
> |
return page; |
258 |
|
#endif |
259 |
< |
#define PFLAG_CLEAR_ALL memset(mainBuffer.dirtyPages, 0, mainBuffer.pageCount) |
260 |
< |
#define PFLAG_SET_ALL memset(mainBuffer.dirtyPages, 1, mainBuffer.pageCount) |
259 |
> |
} |
260 |
> |
|
261 |
> |
static inline int find_next_page_clear(int page) |
262 |
> |
{ |
263 |
> |
#if HAVE_FAST_STRCHR |
264 |
> |
char *match = strchr(mainBuffer.dirtyPages + page, PFLAG_CLEAR_VALUE); |
265 |
> |
return match ? match - mainBuffer.dirtyPages : mainBuffer.pageCount; |
266 |
> |
#else |
267 |
> |
while (PFLAG_ISSET_4(page)) |
268 |
> |
page += 4; |
269 |
> |
while (PFLAG_ISSET(page)) |
270 |
> |
page++; |
271 |
> |
return page; |
272 |
> |
#endif |
273 |
> |
} |
274 |
|
|
275 |
|
static int zero_fd = -1; |
276 |
|
static bool Screen_fault_handler_init(); |
295 |
|
} |
296 |
|
return l; |
297 |
|
} |
298 |
< |
|
246 |
< |
#endif |
298 |
> |
#endif /* ENABLE_VOSF */ |
299 |
|
|
300 |
|
// VideoRefresh function |
301 |
|
void VideoRefreshInit(void); |
386 |
|
hints->res_name = "BasiliskII"; |
387 |
|
hints->res_class = "BasiliskII"; |
388 |
|
XSetClassHint(x_display, w, hints); |
389 |
< |
XFree((char *)hints); |
389 |
> |
XFree(hints); |
390 |
|
} |
391 |
|
} |
392 |
|
|
399 |
|
hints->initial_state = NormalState; |
400 |
|
hints->flags = InputHint | StateHint; |
401 |
|
XSetWMHints(x_display, w, hints); |
402 |
< |
XFree((char *)hints); |
402 |
> |
XFree(hints); |
403 |
|
} |
404 |
|
} |
405 |
|
|
480 |
|
hints->max_height = height; |
481 |
|
hints->flags = PMinSize | PMaxSize; |
482 |
|
XSetWMNormalHints(x_display, the_win, hints); |
483 |
< |
XFree((char *)hints); |
483 |
> |
XFree(hints); |
484 |
|
} |
485 |
|
} |
486 |
|
|
570 |
|
// Set VideoMonitor |
571 |
|
bool native_byte_order; |
572 |
|
#ifdef WORDS_BIGENDIAN |
573 |
< |
native_byte_order = (img->bitmap_bit_order == MSBFirst); |
573 |
> |
native_byte_order = (XImageByteOrder(x_display) == MSBFirst); |
574 |
|
#else |
575 |
< |
native_byte_order = (img->bitmap_bit_order == LSBFirst); |
575 |
> |
native_byte_order = (XImageByteOrder(x_display) == LSBFirst); |
576 |
|
#endif |
577 |
|
#ifdef ENABLE_VOSF |
578 |
|
do_update_framebuffer = GET_FBCOPY_FUNC(depth, native_byte_order, DISPLAY_WINDOW); |
943 |
|
if (mainBuffer.dirtyPages != 0) |
944 |
|
free(mainBuffer.dirtyPages); |
945 |
|
|
946 |
< |
mainBuffer.dirtyPages = (uint8 *) malloc(mainBuffer.pageCount); |
946 |
> |
mainBuffer.dirtyPages = (char *) malloc(mainBuffer.pageCount + 2); |
947 |
|
|
948 |
|
if (mainBuffer.pageInfo != 0) |
949 |
|
free(mainBuffer.pageInfo); |
954 |
|
return false; |
955 |
|
|
956 |
|
PFLAG_CLEAR_ALL; |
957 |
+ |
// Safety net to insure the loops in the update routines will terminate |
958 |
+ |
// See a discussion in <video_vosf.h> for further details |
959 |
+ |
PFLAG_CLEAR(mainBuffer.pageCount); |
960 |
+ |
PFLAG_SET(mainBuffer.pageCount+1); |
961 |
|
|
962 |
|
uint32 a = 0; |
963 |
|
for (int i = 0; i < mainBuffer.pageCount; i++) { |
1010 |
|
keycode_init(); |
1011 |
|
|
1012 |
|
// Read prefs |
1013 |
< |
mouse_wheel_mode = PrefsFindInt16("mousewheelmode"); |
1014 |
< |
mouse_wheel_lines = PrefsFindInt16("mousewheellines"); |
1013 |
> |
mouse_wheel_mode = PrefsFindInt32("mousewheelmode"); |
1014 |
> |
mouse_wheel_lines = PrefsFindInt32("mousewheellines"); |
1015 |
|
|
1016 |
|
// Find screen and root window |
1017 |
|
screen = XDefaultScreen(x_display); |
1949 |
|
* Screen refresh functions |
1950 |
|
*/ |
1951 |
|
|
1952 |
< |
// The specialisations hereunder are meant to enable VOSF with DGA in direct |
1953 |
< |
// addressing mode in case the address spaces (RAM, ROM, FrameBuffer) could |
1954 |
< |
// not get mapped correctly with respect to the predetermined host frame |
1955 |
< |
// buffer base address. |
1956 |
< |
// |
1901 |
< |
// Hmm, in other words, when in direct addressing mode and DGA is requested, |
1902 |
< |
// we first try to "triple allocate" the address spaces according to the real |
1903 |
< |
// host frame buffer address. Then, if it fails, we will use a temporary |
1904 |
< |
// frame buffer thus making the real host frame buffer updated when pages |
1905 |
< |
// of the temp frame buffer are altered. |
1906 |
< |
// |
1907 |
< |
// As a side effect, a little speed gain in screen updates could be noticed |
1908 |
< |
// for other modes than DGA. |
1909 |
< |
// |
1910 |
< |
// The following two functions below are inline so that a clever compiler |
1911 |
< |
// could specialise the code according to the current screen depth and |
1912 |
< |
// display type. A more clever compiler would the job by itself though... |
1913 |
< |
// (update_display_vosf is inlined as well) |
1952 |
> |
// We suggest the compiler to inline the next two functions so that it |
1953 |
> |
// may specialise the code according to the current screen depth and |
1954 |
> |
// display type. A clever compiler would do that job by itself though... |
1955 |
> |
|
1956 |
> |
// NOTE: update_display_vosf is inlined too |
1957 |
|
|
1958 |
|
static inline void possibly_quit_dga_mode() |
1959 |
|
{ |
2135 |
|
ticks++; |
2136 |
|
} |
2137 |
|
uint64 end = GetTicks_usec(); |
2138 |
< |
printf("%Ld ticks in %Ld usec = %Ld ticks/sec\n", ticks, end - start, (end - start) / ticks); |
2138 |
> |
printf("%Ld ticks in %Ld usec = %Ld ticks/sec\n", ticks, end - start, ticks * 1000000 / (end - start)); |
2139 |
|
return NULL; |
2140 |
|
} |
2141 |
|
#endif |