325 |
|
* Initialization |
326 |
|
*/ |
327 |
|
|
328 |
< |
// Set VideoMonitor according to video mode |
329 |
< |
void set_video_monitor(int width, int height, int bytes_per_row, bool native_byte_order) |
328 |
> |
// Add resolution to list of supported modes and set VideoMonitor |
329 |
> |
static void set_video_monitor(uint32 width, uint32 height, uint32 bytes_per_row, bool native_byte_order) |
330 |
|
{ |
331 |
+ |
video_mode mode; |
332 |
|
#if !REAL_ADDRESSING && !DIRECT_ADDRESSING |
333 |
|
int layout = FLAYOUT_DIRECT; |
334 |
|
switch (depth) { |
354 |
|
else |
355 |
|
MacFrameLayout = FLAYOUT_DIRECT; |
356 |
|
#endif |
357 |
+ |
|
358 |
+ |
mode.x = width; |
359 |
+ |
mode.y = height; |
360 |
+ |
mode.resolution_id = 0x80; |
361 |
+ |
mode.bytes_per_row = bytes_per_row; |
362 |
+ |
|
363 |
|
switch (depth) { |
364 |
|
case 1: |
365 |
< |
VideoMonitor.mode = VMODE_1BIT; |
365 |
> |
mode.depth = VDEPTH_1BIT; |
366 |
> |
break; |
367 |
> |
case 2: |
368 |
> |
mode.depth = VDEPTH_2BIT; |
369 |
> |
break; |
370 |
> |
case 4: |
371 |
> |
mode.depth = VDEPTH_4BIT; |
372 |
|
break; |
373 |
|
case 8: |
374 |
< |
VideoMonitor.mode = VMODE_8BIT; |
374 |
> |
mode.depth = VDEPTH_8BIT; |
375 |
|
break; |
376 |
|
case 15: |
377 |
< |
VideoMonitor.mode = VMODE_16BIT; |
377 |
> |
mode.depth = VDEPTH_16BIT; |
378 |
|
break; |
379 |
|
case 16: |
380 |
< |
VideoMonitor.mode = VMODE_16BIT; |
380 |
> |
mode.depth = VDEPTH_16BIT; |
381 |
|
break; |
382 |
|
case 24: |
383 |
|
case 32: |
384 |
< |
VideoMonitor.mode = VMODE_32BIT; |
384 |
> |
mode.depth = VDEPTH_32BIT; |
385 |
|
break; |
386 |
|
} |
387 |
< |
VideoMonitor.x = width; |
388 |
< |
VideoMonitor.y = height; |
389 |
< |
VideoMonitor.bytes_per_row = bytes_per_row; |
387 |
> |
|
388 |
> |
VideoModes.push_back(mode); |
389 |
> |
VideoMonitor.mode = mode; |
390 |
|
} |
391 |
|
|
392 |
|
// Set window name and class |
579 |
|
&black, &white, 0, 0); |
580 |
|
XDefineCursor(x_display, the_win, mac_cursor); |
581 |
|
|
582 |
< |
// Set VideoMonitor |
582 |
> |
// Add resolution and set VideoMonitor |
583 |
|
bool native_byte_order; |
584 |
|
#ifdef WORDS_BIGENDIAN |
585 |
|
native_byte_order = (XImageByteOrder(x_display) == MSBFirst); |
968 |
|
|
969 |
|
uint32 a = 0; |
970 |
|
for (int i = 0; i < mainBuffer.pageCount; i++) { |
971 |
< |
int y1 = a / VideoMonitor.bytes_per_row; |
972 |
< |
if (y1 >= VideoMonitor.y) |
973 |
< |
y1 = VideoMonitor.y - 1; |
974 |
< |
|
975 |
< |
int y2 = (a + mainBuffer.pageSize) / VideoMonitor.bytes_per_row; |
976 |
< |
if (y2 >= VideoMonitor.y) |
977 |
< |
y2 = VideoMonitor.y - 1; |
971 |
> |
int y1 = a / VideoMonitor.mode.bytes_per_row; |
972 |
> |
if (y1 >= VideoMonitor.mode.y) |
973 |
> |
y1 = VideoMonitor.mode.y - 1; |
974 |
> |
|
975 |
> |
int y2 = (a + mainBuffer.pageSize) / VideoMonitor.mode.bytes_per_row; |
976 |
> |
if (y2 >= VideoMonitor.mode.y) |
977 |
> |
y2 = VideoMonitor.mode.y - 1; |
978 |
|
|
979 |
|
mainBuffer.pageInfo[i].top = y1; |
980 |
|
mainBuffer.pageInfo[i].bottom = y2; |
1161 |
|
#if !REAL_ADDRESSING && !DIRECT_ADDRESSING |
1162 |
|
// Set variables for UAE memory mapping |
1163 |
|
MacFrameBaseHost = the_buffer; |
1164 |
< |
MacFrameSize = VideoMonitor.bytes_per_row * VideoMonitor.y; |
1164 |
> |
MacFrameSize = VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y; |
1165 |
|
|
1166 |
|
// No special frame buffer in Classic mode (frame buffer is in Mac RAM) |
1167 |
|
if (classic) |
1372 |
|
LOCK_FRAME_BUFFER; |
1373 |
|
|
1374 |
|
// Save frame buffer |
1375 |
< |
fb_save = malloc(VideoMonitor.y * VideoMonitor.bytes_per_row); |
1375 |
> |
fb_save = malloc(VideoMonitor.mode.y * VideoMonitor.mode.bytes_per_row); |
1376 |
|
if (fb_save) |
1377 |
< |
memcpy(fb_save, the_buffer, VideoMonitor.y * VideoMonitor.bytes_per_row); |
1377 |
> |
memcpy(fb_save, the_buffer, VideoMonitor.mode.y * VideoMonitor.mode.bytes_per_row); |
1378 |
|
|
1379 |
|
// Close full screen display |
1380 |
|
#ifdef ENABLE_XF86_DGA |
1425 |
|
LOCK_VOSF; |
1426 |
|
PFLAG_SET_ALL; |
1427 |
|
UNLOCK_VOSF; |
1428 |
< |
memset(the_buffer_copy, 0, VideoMonitor.bytes_per_row * VideoMonitor.y); |
1428 |
> |
memset(the_buffer_copy, 0, VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y); |
1429 |
|
} |
1430 |
|
#endif |
1431 |
|
|
1435 |
|
// Don't copy fb_save to the temporary frame buffer in VOSF mode |
1436 |
|
if (!use_vosf) |
1437 |
|
#endif |
1438 |
< |
memcpy(the_buffer, fb_save, VideoMonitor.y * VideoMonitor.bytes_per_row); |
1438 |
> |
memcpy(the_buffer, fb_save, VideoMonitor.mode.y * VideoMonitor.mode.bytes_per_row); |
1439 |
|
free(fb_save); |
1440 |
|
fb_save = NULL; |
1441 |
|
} |
1716 |
|
LOCK_VOSF; |
1717 |
|
PFLAG_SET_ALL; |
1718 |
|
UNLOCK_VOSF; |
1719 |
< |
memset(the_buffer_copy, 0, VideoMonitor.bytes_per_row * VideoMonitor.y); |
1719 |
> |
memset(the_buffer_copy, 0, VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y); |
1720 |
|
} |
1721 |
|
else |
1722 |
|
#endif |
1727 |
|
updt_box[x1][y1] = true; |
1728 |
|
nr_boxes = 16 * 16; |
1729 |
|
} else // Static refresh |
1730 |
< |
memset(the_buffer_copy, 0, VideoMonitor.bytes_per_row * VideoMonitor.y); |
1730 |
> |
memset(the_buffer_copy, 0, VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y); |
1731 |
|
} |
1732 |
|
break; |
1733 |
|
|
1753 |
|
int y1, y2, y2s, y2a, i, x1, xm, xmo, ymo, yo, yi, yil, xi; |
1754 |
|
int xil = 0; |
1755 |
|
int rxm = 0, rxmo = 0; |
1756 |
< |
int bytes_per_row = VideoMonitor.bytes_per_row; |
1757 |
< |
int bytes_per_pixel = VideoMonitor.bytes_per_row / VideoMonitor.x; |
1758 |
< |
int rx = VideoMonitor.bytes_per_row / 16; |
1759 |
< |
int ry = VideoMonitor.y / 16; |
1756 |
> |
int bytes_per_row = VideoMonitor.mode.bytes_per_row; |
1757 |
> |
int bytes_per_pixel = VideoMonitor.mode.bytes_per_row / VideoMonitor.mode.x; |
1758 |
> |
int rx = VideoMonitor.mode.bytes_per_row / 16; |
1759 |
> |
int ry = VideoMonitor.mode.y / 16; |
1760 |
|
int max_box; |
1761 |
|
|
1762 |
|
y2s = sm_uptd[ticker % 8]; |
1842 |
|
{ |
1843 |
|
// Incremental update code |
1844 |
|
int wide = 0, high = 0, x1, x2, y1, y2, i, j; |
1845 |
< |
int bytes_per_row = VideoMonitor.bytes_per_row; |
1846 |
< |
int bytes_per_pixel = VideoMonitor.bytes_per_row / VideoMonitor.x; |
1845 |
> |
int bytes_per_row = VideoMonitor.mode.bytes_per_row; |
1846 |
> |
int bytes_per_pixel = VideoMonitor.mode.bytes_per_row / VideoMonitor.mode.x; |
1847 |
|
uint8 *p, *p2; |
1848 |
|
|
1849 |
|
// Check for first line from top and first line from bottom that have changed |
1850 |
|
y1 = 0; |
1851 |
< |
for (j=0; j<VideoMonitor.y; j++) { |
1851 |
> |
for (j=0; j<VideoMonitor.mode.y; j++) { |
1852 |
|
if (memcmp(&the_buffer[j * bytes_per_row], &the_buffer_copy[j * bytes_per_row], bytes_per_row)) { |
1853 |
|
y1 = j; |
1854 |
|
break; |
1855 |
|
} |
1856 |
|
} |
1857 |
|
y2 = y1 - 1; |
1858 |
< |
for (j=VideoMonitor.y-1; j>=y1; j--) { |
1858 |
> |
for (j=VideoMonitor.mode.y-1; j>=y1; j--) { |
1859 |
|
if (memcmp(&the_buffer[j * bytes_per_row], &the_buffer_copy[j * bytes_per_row], bytes_per_row)) { |
1860 |
|
y2 = j; |
1861 |
|
break; |
1866 |
|
// Check for first column from left and first column from right that have changed |
1867 |
|
if (high) { |
1868 |
|
if (depth == 1) { |
1869 |
< |
x1 = VideoMonitor.x - 1; |
1869 |
> |
x1 = VideoMonitor.mode.x - 1; |
1870 |
|
for (j=y1; j<=y2; j++) { |
1871 |
|
p = &the_buffer[j * bytes_per_row]; |
1872 |
|
p2 = &the_buffer_copy[j * bytes_per_row]; |
1884 |
|
p2 = &the_buffer_copy[j * bytes_per_row]; |
1885 |
|
p += bytes_per_row; |
1886 |
|
p2 += bytes_per_row; |
1887 |
< |
for (i=(VideoMonitor.x>>3); i>(x2>>3); i--) { |
1887 |
> |
for (i=(VideoMonitor.mode.x>>3); i>(x2>>3); i--) { |
1888 |
|
p--; p2--; |
1889 |
|
if (*p != *p2) { |
1890 |
|
x2 = (i << 3) + 7; |
1903 |
|
} |
1904 |
|
|
1905 |
|
} else { |
1906 |
< |
x1 = VideoMonitor.x; |
1906 |
> |
x1 = VideoMonitor.mode.x; |
1907 |
|
for (j=y1; j<=y2; j++) { |
1908 |
|
p = &the_buffer[j * bytes_per_row]; |
1909 |
|
p2 = &the_buffer_copy[j * bytes_per_row]; |
1921 |
|
p2 = &the_buffer_copy[j * bytes_per_row]; |
1922 |
|
p += bytes_per_row; |
1923 |
|
p2 += bytes_per_row; |
1924 |
< |
for (i=VideoMonitor.x*bytes_per_pixel; i>x2*bytes_per_pixel; i--) { |
1924 |
> |
for (i=VideoMonitor.mode.x*bytes_per_pixel; i>x2*bytes_per_pixel; i--) { |
1925 |
|
p--; |
1926 |
|
p2--; |
1927 |
|
if (*p != *p2) { |