57 |
|
|
58 |
|
// Constants |
59 |
|
const char KEYCODE_FILE_NAME[] = DATADIR "/keycodes"; |
60 |
+ |
static const bool mac_cursor_enabled = false; // Flag: Enable MacOS to X11 copy of cursor? |
61 |
|
|
62 |
|
// Global variables |
63 |
|
static int32 frame_skip; |
506 |
|
XSetState(x_display, the_gc, black_pixel, white_pixel, GXcopy, AllPlanes); |
507 |
|
|
508 |
|
// Create cursor |
509 |
< |
cursor_image = XCreateImage(x_display, vis, 1, XYPixmap, 0, (char *)MacCursor + 4, 16, 16, 16, 2); |
510 |
< |
cursor_image->byte_order = MSBFirst; |
511 |
< |
cursor_image->bitmap_bit_order = MSBFirst; |
512 |
< |
cursor_mask_image = XCreateImage(x_display, vis, 1, XYPixmap, 0, (char *)MacCursor + 36, 16, 16, 16, 2); |
513 |
< |
cursor_mask_image->byte_order = MSBFirst; |
514 |
< |
cursor_mask_image->bitmap_bit_order = MSBFirst; |
515 |
< |
cursor_map = XCreatePixmap(x_display, the_win, 16, 16, 1); |
516 |
< |
cursor_mask_map = XCreatePixmap(x_display, the_win, 16, 16, 1); |
517 |
< |
cursor_gc = XCreateGC(x_display, cursor_map, 0, 0); |
518 |
< |
cursor_mask_gc = XCreateGC(x_display, cursor_mask_map, 0, 0); |
519 |
< |
mac_cursor = XCreatePixmapCursor(x_display, cursor_map, cursor_mask_map, &black, &white, 0, 0); |
520 |
< |
cursor_changed = false; |
509 |
> |
if (mac_cursor_enabled) { |
510 |
> |
cursor_image = XCreateImage(x_display, vis, 1, XYPixmap, 0, (char *)MacCursor + 4, 16, 16, 16, 2); |
511 |
> |
cursor_image->byte_order = MSBFirst; |
512 |
> |
cursor_image->bitmap_bit_order = MSBFirst; |
513 |
> |
cursor_mask_image = XCreateImage(x_display, vis, 1, XYPixmap, 0, (char *)MacCursor + 36, 16, 16, 16, 2); |
514 |
> |
cursor_mask_image->byte_order = MSBFirst; |
515 |
> |
cursor_mask_image->bitmap_bit_order = MSBFirst; |
516 |
> |
cursor_map = XCreatePixmap(x_display, the_win, 16, 16, 1); |
517 |
> |
cursor_mask_map = XCreatePixmap(x_display, the_win, 16, 16, 1); |
518 |
> |
cursor_gc = XCreateGC(x_display, cursor_map, 0, 0); |
519 |
> |
cursor_mask_gc = XCreateGC(x_display, cursor_mask_map, 0, 0); |
520 |
> |
mac_cursor = XCreatePixmapCursor(x_display, cursor_map, cursor_mask_map, &black, &white, 0, 0); |
521 |
> |
cursor_changed = false; |
522 |
> |
} |
523 |
> |
|
524 |
> |
// Create no_cursor |
525 |
> |
else { |
526 |
> |
mac_cursor = XCreatePixmapCursor(x_display, |
527 |
> |
XCreatePixmap(x_display, the_win, 1, 1, 1), |
528 |
> |
XCreatePixmap(x_display, the_win, 1, 1, 1), |
529 |
> |
&black, &white, 0, 0); |
530 |
> |
XDefineCursor(x_display, the_win, mac_cursor); |
531 |
> |
} |
532 |
|
|
533 |
|
// Init blitting routines |
534 |
|
bool native_byte_order; |
1623 |
|
* Install graphics acceleration |
1624 |
|
*/ |
1625 |
|
|
1626 |
< |
#if 0 |
1627 |
< |
// Rectangle filling/inversion |
1628 |
< |
static void accl_fillrect8(accl_params *p) |
1626 |
> |
// Rectangle inversion |
1627 |
> |
template< int bpp > |
1628 |
> |
static inline void do_invrect(uint8 *dest, uint32 length) |
1629 |
|
{ |
1630 |
< |
D(bug("accl_fillrect8\n")); |
1630 |
> |
#define INVERT_1(PTR, OFS) ((uint8 *)(PTR))[OFS] = ~((uint8 *)(PTR))[OFS] |
1631 |
> |
#define INVERT_2(PTR, OFS) ((uint16 *)(PTR))[OFS] = ~((uint16 *)(PTR))[OFS] |
1632 |
> |
#define INVERT_4(PTR, OFS) ((uint32 *)(PTR))[OFS] = ~((uint32 *)(PTR))[OFS] |
1633 |
> |
#define INVERT_8(PTR, OFS) ((uint64 *)(PTR))[OFS] = ~((uint64 *)(PTR))[OFS] |
1634 |
|
|
1635 |
< |
// Get filling parameters |
1636 |
< |
int16 dest_X = p->dest_rect[1] - p->dest_bounds[1]; |
1637 |
< |
int16 dest_Y = p->dest_rect[0] - p->dest_bounds[0]; |
1638 |
< |
int16 dest_X_max = p->dest_rect[3] - p->dest_bounds[1] - 1; |
1639 |
< |
int16 dest_Y_max = p->dest_rect[2] - p->dest_bounds[0] - 1; |
1640 |
< |
uint8 color = p->pen_mode == 8 ? p->fore_pen : p->back_pen; |
1626 |
< |
D(bug(" dest X %d, dest Y %d\n", dest_X, dest_Y)); |
1627 |
< |
D(bug(" dest X max %d, dest Y max %d\n", dest_X_max, dest_Y_max)); |
1635 |
> |
#ifndef UNALIGNED_PROFITABLE |
1636 |
> |
// Align on 16-bit boundaries |
1637 |
> |
if (bpp < 16 && (((uintptr)dest) & 1)) { |
1638 |
> |
INVERT_1(dest, 0); |
1639 |
> |
dest += 1; length -= 1; |
1640 |
> |
} |
1641 |
|
|
1642 |
< |
// And perform the fill |
1643 |
< |
fillrect8_hook(dest_X, dest_Y, dest_X_max, dest_Y_max, color); |
1644 |
< |
} |
1642 |
> |
// Align on 32-bit boundaries |
1643 |
> |
if (bpp < 32 && (((uintptr)dest) & 2)) { |
1644 |
> |
INVERT_2(dest, 0); |
1645 |
> |
dest += 2; length -= 2; |
1646 |
> |
} |
1647 |
> |
#endif |
1648 |
|
|
1649 |
< |
static void accl_fillrect32(accl_params *p) |
1650 |
< |
{ |
1651 |
< |
D(bug("accl_fillrect32\n")); |
1649 |
> |
// Invert 8-byte words |
1650 |
> |
if (length >= 8) { |
1651 |
> |
const int r = (length / 8) % 8; |
1652 |
> |
dest += r * 8; |
1653 |
|
|
1654 |
< |
// Get filling parameters |
1655 |
< |
int16 dest_X = p->dest_rect[1] - p->dest_bounds[1]; |
1656 |
< |
int16 dest_Y = p->dest_rect[0] - p->dest_bounds[0]; |
1657 |
< |
int16 dest_X_max = p->dest_rect[3] - p->dest_bounds[1] - 1; |
1658 |
< |
int16 dest_Y_max = p->dest_rect[2] - p->dest_bounds[0] - 1; |
1659 |
< |
uint32 color = p->pen_mode == 8 ? p->fore_pen : p->back_pen; |
1660 |
< |
D(bug(" dest X %d, dest Y %d\n", dest_X, dest_Y)); |
1661 |
< |
D(bug(" dest X max %d, dest Y max %d\n", dest_X_max, dest_Y_max)); |
1654 |
> |
int n = ((length / 8) + 7) / 8; |
1655 |
> |
switch (r) { |
1656 |
> |
case 0: do { |
1657 |
> |
dest += 64; |
1658 |
> |
INVERT_8(dest, -8); |
1659 |
> |
case 7: INVERT_8(dest, -7); |
1660 |
> |
case 6: INVERT_8(dest, -6); |
1661 |
> |
case 5: INVERT_8(dest, -5); |
1662 |
> |
case 4: INVERT_8(dest, -4); |
1663 |
> |
case 3: INVERT_8(dest, -3); |
1664 |
> |
case 2: INVERT_8(dest, -2); |
1665 |
> |
case 1: INVERT_8(dest, -1); |
1666 |
> |
} while (--n > 0); |
1667 |
> |
} |
1668 |
> |
} |
1669 |
|
|
1670 |
< |
// And perform the fill |
1671 |
< |
fillrect32_hook(dest_X, dest_Y, dest_X_max, dest_Y_max, color); |
1670 |
> |
// 32-bit cell to invert? |
1671 |
> |
if (length & 4) { |
1672 |
> |
INVERT_4(dest, 0); |
1673 |
> |
if (bpp <= 16) |
1674 |
> |
dest += 4; |
1675 |
> |
} |
1676 |
> |
|
1677 |
> |
// 16-bit cell to invert? |
1678 |
> |
if (bpp <= 16 && (length & 2)) { |
1679 |
> |
INVERT_2(dest, 0); |
1680 |
> |
if (bpp <= 8) |
1681 |
> |
dest += 2; |
1682 |
> |
} |
1683 |
> |
|
1684 |
> |
// 8-bit cell to invert? |
1685 |
> |
if (bpp <= 8 && (length & 1)) |
1686 |
> |
INVERT_1(dest, 0); |
1687 |
> |
|
1688 |
> |
#undef INVERT_1 |
1689 |
> |
#undef INVERT_2 |
1690 |
> |
#undef INVERT_4 |
1691 |
> |
#undef INVERT_8 |
1692 |
|
} |
1693 |
|
|
1694 |
< |
static void accl_invrect(accl_params *p) |
1694 |
> |
void NQD_invrect(uint32 p) |
1695 |
|
{ |
1696 |
< |
D(bug("accl_invrect\n")); |
1696 |
> |
D(bug("accl_invrect %08x\n", p)); |
1697 |
|
|
1698 |
|
// Get inversion parameters |
1699 |
< |
int16 dest_X = p->dest_rect[1] - p->dest_bounds[1]; |
1700 |
< |
int16 dest_Y = p->dest_rect[0] - p->dest_bounds[0]; |
1701 |
< |
int16 dest_X_max = p->dest_rect[3] - p->dest_bounds[1] - 1; |
1702 |
< |
int16 dest_Y_max = p->dest_rect[2] - p->dest_bounds[0] - 1; |
1699 |
> |
int16 dest_X = (int16)ReadMacInt16(p + acclDestRect + 2) - (int16)ReadMacInt16(p + acclDestBoundsRect + 2); |
1700 |
> |
int16 dest_Y = (int16)ReadMacInt16(p + acclDestRect + 0) - (int16)ReadMacInt16(p + acclDestBoundsRect + 0); |
1701 |
> |
int16 width = (int16)ReadMacInt16(p + acclDestRect + 6) - (int16)ReadMacInt16(p + acclDestRect + 2); |
1702 |
> |
int16 height = (int16)ReadMacInt16(p + acclDestRect + 4) - (int16)ReadMacInt16(p + acclDestRect + 0); |
1703 |
|
D(bug(" dest X %d, dest Y %d\n", dest_X, dest_Y)); |
1704 |
< |
D(bug(" dest X max %d, dest Y max %d\n", dest_X_max, dest_Y_max)); |
1704 |
> |
D(bug(" width %d, height %d, bytes_per_row %d\n", width, height, (int32)ReadMacInt32(p + acclDestRowBytes))); |
1705 |
|
|
1706 |
|
//!!?? pen_mode == 14 |
1707 |
|
|
1708 |
|
// And perform the inversion |
1709 |
< |
invrect_hook(dest_X, dest_Y, dest_X_max, dest_Y_max); |
1709 |
> |
const int bpp = bytes_per_pixel(ReadMacInt32(p + acclDestPixelSize)); |
1710 |
> |
const int dest_row_bytes = (int32)ReadMacInt32(p + acclDestRowBytes); |
1711 |
> |
uint8 *dest = Mac2HostAddr(ReadMacInt32(p + acclDestBaseAddr) + (dest_Y * dest_row_bytes) + (dest_X * bpp)); |
1712 |
> |
width *= bpp; |
1713 |
> |
switch (bpp) { |
1714 |
> |
case 1: |
1715 |
> |
for (int i = 0; i < height; i++) { |
1716 |
> |
do_invrect<8>(dest, width); |
1717 |
> |
dest += dest_row_bytes; |
1718 |
> |
} |
1719 |
> |
break; |
1720 |
> |
case 2: |
1721 |
> |
for (int i = 0; i < height; i++) { |
1722 |
> |
do_invrect<16>(dest, width); |
1723 |
> |
dest += dest_row_bytes; |
1724 |
> |
} |
1725 |
> |
break; |
1726 |
> |
case 4: |
1727 |
> |
for (int i = 0; i < height; i++) { |
1728 |
> |
do_invrect<32>(dest, width); |
1729 |
> |
dest += dest_row_bytes; |
1730 |
> |
} |
1731 |
> |
break; |
1732 |
> |
} |
1733 |
> |
} |
1734 |
> |
|
1735 |
> |
// Rectangle filling |
1736 |
> |
template< int bpp > |
1737 |
> |
static inline void do_fillrect(uint8 *dest, uint32 color, uint32 length) |
1738 |
> |
{ |
1739 |
> |
#define FILL_1(PTR, OFS, VAL) ((uint8 *)(PTR))[OFS] = (VAL) |
1740 |
> |
#define FILL_2(PTR, OFS, VAL) ((uint16 *)(PTR))[OFS] = (VAL) |
1741 |
> |
#define FILL_4(PTR, OFS, VAL) ((uint32 *)(PTR))[OFS] = (VAL) |
1742 |
> |
#define FILL_8(PTR, OFS, VAL) ((uint64 *)(PTR))[OFS] = (VAL) |
1743 |
> |
|
1744 |
> |
#ifndef UNALIGNED_PROFITABLE |
1745 |
> |
// Align on 16-bit boundaries |
1746 |
> |
if (bpp < 16 && (((uintptr)dest) & 1)) { |
1747 |
> |
FILL_1(dest, 0, color); |
1748 |
> |
dest += 1; length -= 1; |
1749 |
> |
} |
1750 |
> |
|
1751 |
> |
// Align on 32-bit boundaries |
1752 |
> |
if (bpp < 32 && (((uintptr)dest) & 2)) { |
1753 |
> |
FILL_2(dest, 0, color); |
1754 |
> |
dest += 2; length -= 2; |
1755 |
> |
} |
1756 |
> |
#endif |
1757 |
> |
|
1758 |
> |
// Fill 8-byte words |
1759 |
> |
if (length >= 8) { |
1760 |
> |
const uint64 c = (((uint64)color) << 32) | color; |
1761 |
> |
const int r = (length / 8) % 8; |
1762 |
> |
dest += r * 8; |
1763 |
> |
|
1764 |
> |
int n = ((length / 8) + 7) / 8; |
1765 |
> |
switch (r) { |
1766 |
> |
case 0: do { |
1767 |
> |
dest += 64; |
1768 |
> |
FILL_8(dest, -8, c); |
1769 |
> |
case 7: FILL_8(dest, -7, c); |
1770 |
> |
case 6: FILL_8(dest, -6, c); |
1771 |
> |
case 5: FILL_8(dest, -5, c); |
1772 |
> |
case 4: FILL_8(dest, -4, c); |
1773 |
> |
case 3: FILL_8(dest, -3, c); |
1774 |
> |
case 2: FILL_8(dest, -2, c); |
1775 |
> |
case 1: FILL_8(dest, -1, c); |
1776 |
> |
} while (--n > 0); |
1777 |
> |
} |
1778 |
> |
} |
1779 |
> |
|
1780 |
> |
// 32-bit cell to fill? |
1781 |
> |
if (length & 4) { |
1782 |
> |
FILL_4(dest, 0, color); |
1783 |
> |
if (bpp <= 16) |
1784 |
> |
dest += 4; |
1785 |
> |
} |
1786 |
> |
|
1787 |
> |
// 16-bit cell to fill? |
1788 |
> |
if (bpp <= 16 && (length & 2)) { |
1789 |
> |
FILL_2(dest, 0, color); |
1790 |
> |
if (bpp <= 8) |
1791 |
> |
dest += 2; |
1792 |
> |
} |
1793 |
> |
|
1794 |
> |
// 8-bit cell to fill? |
1795 |
> |
if (bpp <= 8 && (length & 1)) |
1796 |
> |
FILL_1(dest, 0, color); |
1797 |
> |
|
1798 |
> |
#undef FILL_1 |
1799 |
> |
#undef FILL_2 |
1800 |
> |
#undef FILL_4 |
1801 |
> |
#undef FILL_8 |
1802 |
> |
} |
1803 |
> |
|
1804 |
> |
void NQD_fillrect(uint32 p) |
1805 |
> |
{ |
1806 |
> |
D(bug("accl_fillrect %08x\n", p)); |
1807 |
> |
|
1808 |
> |
// Get filling parameters |
1809 |
> |
int16 dest_X = (int16)ReadMacInt16(p + acclDestRect + 2) - (int16)ReadMacInt16(p + acclDestBoundsRect + 2); |
1810 |
> |
int16 dest_Y = (int16)ReadMacInt16(p + acclDestRect + 0) - (int16)ReadMacInt16(p + acclDestBoundsRect + 0); |
1811 |
> |
int16 width = (int16)ReadMacInt16(p + acclDestRect + 6) - (int16)ReadMacInt16(p + acclDestRect + 2); |
1812 |
> |
int16 height = (int16)ReadMacInt16(p + acclDestRect + 4) - (int16)ReadMacInt16(p + acclDestRect + 0); |
1813 |
> |
uint32 color = ReadMacInt32(p + acclPenMode) == 8 ? ReadMacInt32(p + acclForePen) : ReadMacInt32(p + acclBackPen); |
1814 |
> |
D(bug(" dest X %d, dest Y %d\n", dest_X, dest_Y)); |
1815 |
> |
D(bug(" width %d, height %d\n", width, height)); |
1816 |
> |
D(bug(" bytes_per_row %d color %08x\n", (int32)ReadMacInt32(p + acclDestRowBytes), color)); |
1817 |
> |
|
1818 |
> |
// And perform the fill |
1819 |
> |
const int bpp = bytes_per_pixel(ReadMacInt32(p + acclDestPixelSize)); |
1820 |
> |
const int dest_row_bytes = (int32)ReadMacInt32(p + acclDestRowBytes); |
1821 |
> |
uint8 *dest = Mac2HostAddr(ReadMacInt32(p + acclDestBaseAddr) + (dest_Y * dest_row_bytes) + (dest_X * bpp)); |
1822 |
> |
width *= bpp; |
1823 |
> |
switch (bpp) { |
1824 |
> |
case 1: |
1825 |
> |
for (int i = 0; i < height; i++) { |
1826 |
> |
memset(dest, color, width); |
1827 |
> |
dest += dest_row_bytes; |
1828 |
> |
} |
1829 |
> |
break; |
1830 |
> |
case 2: |
1831 |
> |
for (int i = 0; i < height; i++) { |
1832 |
> |
do_fillrect<16>(dest, color, width); |
1833 |
> |
dest += dest_row_bytes; |
1834 |
> |
} |
1835 |
> |
break; |
1836 |
> |
case 4: |
1837 |
> |
for (int i = 0; i < height; i++) { |
1838 |
> |
do_fillrect<32>(dest, color, width); |
1839 |
> |
dest += dest_row_bytes; |
1840 |
> |
} |
1841 |
> |
break; |
1842 |
> |
} |
1843 |
|
} |
1844 |
|
|
1845 |
< |
static bool accl_fillrect_hook(accl_params *p) |
1845 |
> |
bool NQD_fillrect_hook(uint32 p) |
1846 |
|
{ |
1847 |
< |
D(bug("accl_fillrect_hook %p\n", p)); |
1847 |
> |
D(bug("accl_fillrect_hook %08x\n", p)); |
1848 |
|
|
1849 |
|
// Check if we can accelerate this fillrect |
1850 |
< |
if (p->dest_base_addr == screen_base && ((uint32 *)p)[0x284 >> 2] != 0 && display_type == DIS_SCREEN) { |
1851 |
< |
if (p->transfer_mode == 8) { |
1850 |
> |
if (ReadMacInt32(p + 0x284) != 0 && ReadMacInt32(p + acclDestPixelSize) >= 8) { |
1851 |
> |
const int transfer_mode = ReadMacInt32(p + acclTransferMode); |
1852 |
> |
if (transfer_mode == 8) { |
1853 |
|
// Fill |
1854 |
< |
if (p->dest_pixel_size == 8 && fillrect8_hook != NULL) { |
1855 |
< |
p->draw_proc = accl_fillrect8; |
1856 |
< |
return true; |
1857 |
< |
} else if (p->dest_pixel_size == 32 && fillrect32_hook != NULL) { |
1680 |
< |
p->draw_proc = accl_fillrect32; |
1681 |
< |
return true; |
1682 |
< |
} |
1683 |
< |
} else if (p->transfer_mode == 10 && invrect_hook != NULL) { |
1854 |
> |
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_FILLRECT)); |
1855 |
> |
return true; |
1856 |
> |
} |
1857 |
> |
else if (transfer_mode == 10) { |
1858 |
|
// Invert |
1859 |
< |
p->draw_proc = accl_invrect; |
1859 |
> |
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_INVRECT)); |
1860 |
|
return true; |
1861 |
|
} |
1862 |
|
} |
1863 |
|
return false; |
1864 |
|
} |
1865 |
|
|
1692 |
– |
static struct accl_hook_info fillrect_hook_info = {accl_fillrect_hook, accl_sync_hook, ACCL_FILLRECT}; |
1693 |
– |
#endif |
1694 |
– |
|
1866 |
|
// Rectangle blitting |
1867 |
|
// TODO: optimize for VOSF and target pixmap == screen |
1868 |
< |
void NQD_bitblt(uint32 arg) |
1868 |
> |
void NQD_bitblt(uint32 p) |
1869 |
|
{ |
1870 |
< |
D(bug("accl_bitblt %08x\n", arg)); |
1700 |
< |
accl_params *p = (accl_params *)arg; |
1870 |
> |
D(bug("accl_bitblt %08x\n", p)); |
1871 |
|
|
1872 |
|
// Get blitting parameters |
1873 |
< |
int16 src_X = p->src_rect[1] - p->src_bounds[1]; |
1874 |
< |
int16 src_Y = p->src_rect[0] - p->src_bounds[0]; |
1875 |
< |
int16 dest_X = p->dest_rect[1] - p->dest_bounds[1]; |
1876 |
< |
int16 dest_Y = p->dest_rect[0] - p->dest_bounds[0]; |
1877 |
< |
int16 width = p->dest_rect[3] - p->dest_rect[1]; |
1878 |
< |
int16 height = p->dest_rect[2] - p->dest_rect[0]; |
1879 |
< |
D(bug(" src addr %08x, dest addr %08x\n", p->src_base_addr, p->dest_base_addr)); |
1873 |
> |
int16 src_X = (int16)ReadMacInt16(p + acclSrcRect + 2) - (int16)ReadMacInt16(p + acclSrcBoundsRect + 2); |
1874 |
> |
int16 src_Y = (int16)ReadMacInt16(p + acclSrcRect + 0) - (int16)ReadMacInt16(p + acclSrcBoundsRect + 0); |
1875 |
> |
int16 dest_X = (int16)ReadMacInt16(p + acclDestRect + 2) - (int16)ReadMacInt16(p + acclDestBoundsRect + 2); |
1876 |
> |
int16 dest_Y = (int16)ReadMacInt16(p + acclDestRect + 0) - (int16)ReadMacInt16(p + acclDestBoundsRect + 0); |
1877 |
> |
int16 width = (int16)ReadMacInt16(p + acclDestRect + 6) - (int16)ReadMacInt16(p + acclDestRect + 2); |
1878 |
> |
int16 height = (int16)ReadMacInt16(p + acclDestRect + 4) - (int16)ReadMacInt16(p + acclDestRect + 0); |
1879 |
> |
D(bug(" src addr %08x, dest addr %08x\n", ReadMacInt32(p + acclSrcBaseAddr), ReadMacInt32(p + acclDestBaseAddr))); |
1880 |
|
D(bug(" src X %d, src Y %d, dest X %d, dest Y %d\n", src_X, src_Y, dest_X, dest_Y)); |
1881 |
|
D(bug(" width %d, height %d\n", width, height)); |
1882 |
|
|
1883 |
|
// And perform the blit |
1884 |
< |
const int bpp = bytes_per_pixel(p->src_pixel_size); |
1884 |
> |
const int bpp = bytes_per_pixel(ReadMacInt32(p + acclSrcPixelSize)); |
1885 |
|
width *= bpp; |
1886 |
< |
if (p->src_row_bytes > 0) { |
1887 |
< |
const int src_row_bytes = p->src_row_bytes; |
1888 |
< |
const int dst_row_bytes = p->dest_row_bytes; |
1889 |
< |
uint8 *src = (uint8 *)p->src_base_addr + (src_Y * src_row_bytes) + (src_X * bpp); |
1890 |
< |
uint8 *dst = (uint8 *)p->dest_base_addr + (dest_Y * dst_row_bytes) + (dest_X * bpp); |
1886 |
> |
if ((int32)ReadMacInt32(p + acclSrcRowBytes) > 0) { |
1887 |
> |
const int src_row_bytes = (int32)ReadMacInt32(p + acclSrcRowBytes); |
1888 |
> |
const int dst_row_bytes = (int32)ReadMacInt32(p + acclDestRowBytes); |
1889 |
> |
uint8 *src = Mac2HostAddr(ReadMacInt32(p + acclSrcBaseAddr) + (src_Y * src_row_bytes) + (src_X * bpp)); |
1890 |
> |
uint8 *dst = Mac2HostAddr(ReadMacInt32(p + acclDestBaseAddr) + (dest_Y * dst_row_bytes) + (dest_X * bpp)); |
1891 |
|
for (int i = 0; i < height; i++) { |
1892 |
|
memcpy(dst, src, width); |
1893 |
|
src += src_row_bytes; |
1895 |
|
} |
1896 |
|
} |
1897 |
|
else { |
1898 |
< |
const int src_row_bytes = -p->src_row_bytes; |
1899 |
< |
const int dst_row_bytes = -p->dest_row_bytes; |
1900 |
< |
uint8 *src = (uint8 *)p->src_base_addr + ((src_Y + height - 1) * src_row_bytes) + (src_X * bpp); |
1901 |
< |
uint8 *dst = (uint8 *)p->dest_base_addr + ((dest_Y + height - 1) * dst_row_bytes) + (dest_X * bpp); |
1898 |
> |
const int src_row_bytes = -(int32)ReadMacInt32(p + acclSrcRowBytes); |
1899 |
> |
const int dst_row_bytes = -(int32)ReadMacInt32(p + acclDestRowBytes); |
1900 |
> |
uint8 *src = Mac2HostAddr(ReadMacInt32(p + acclSrcBaseAddr) + ((src_Y + height - 1) * src_row_bytes) + (src_X * bpp)); |
1901 |
> |
uint8 *dst = Mac2HostAddr(ReadMacInt32(p + acclDestBaseAddr) + ((dest_Y + height - 1) * dst_row_bytes) + (dest_X * bpp)); |
1902 |
|
for (int i = height - 1; i >= 0; i--) { |
1903 |
|
memcpy(dst, src, width); |
1904 |
|
src -= src_row_bytes; |
1907 |
|
} |
1908 |
|
} |
1909 |
|
|
1910 |
< |
bool NQD_bitblt_hook(uint32 arg) |
1910 |
> |
/* |
1911 |
> |
BitBlt transfer modes: |
1912 |
> |
0 : srcCopy |
1913 |
> |
1 : srcOr |
1914 |
> |
2 : srcXor |
1915 |
> |
3 : srcBic |
1916 |
> |
4 : notSrcCopy |
1917 |
> |
5 : notSrcOr |
1918 |
> |
6 : notSrcXor |
1919 |
> |
7 : notSrcBic |
1920 |
> |
32 : blend |
1921 |
> |
33 : addPin |
1922 |
> |
34 : addOver |
1923 |
> |
35 : subPin |
1924 |
> |
36 : transparent |
1925 |
> |
37 : adMax |
1926 |
> |
38 : subOver |
1927 |
> |
39 : adMin |
1928 |
> |
50 : hilite |
1929 |
> |
*/ |
1930 |
> |
|
1931 |
> |
bool NQD_bitblt_hook(uint32 p) |
1932 |
|
{ |
1933 |
< |
D(bug("accl_draw_hook %08x\n", arg)); |
1743 |
< |
accl_params *p = (accl_params *)arg; |
1933 |
> |
D(bug("accl_draw_hook %08x\n", p)); |
1934 |
|
|
1935 |
|
// Check if we can accelerate this bitblt |
1936 |
< |
if (((uint32 *)p)[0x18 >> 2] + ((uint32 *)p)[0x128 >> 2] == 0 && |
1937 |
< |
((uint32 *)p)[0x130 >> 2] == 0 && |
1938 |
< |
p->src_pixel_size >= 8 && p->src_pixel_size == p->dest_pixel_size && |
1939 |
< |
((p->src_row_bytes ^ p->dest_row_bytes) >> 31) == 0 && |
1940 |
< |
p->transfer_mode == 0 && |
1941 |
< |
((uint32 *)p)[0x15c >> 2] > 0) { |
1936 |
> |
if (ReadMacInt32(p + 0x018) + ReadMacInt32(p + 0x128) == 0 && |
1937 |
> |
ReadMacInt32(p + 0x130) == 0 && |
1938 |
> |
ReadMacInt32(p + acclSrcPixelSize) >= 8 && |
1939 |
> |
ReadMacInt32(p + acclSrcPixelSize) == ReadMacInt32(p + acclDestPixelSize) && |
1940 |
> |
(ReadMacInt32(p + acclSrcRowBytes) ^ ReadMacInt32(p + acclDestRowBytes)) >= 0 && // same sign? |
1941 |
> |
ReadMacInt32(p + acclTransferMode) == 0 && // srcCopy? |
1942 |
> |
ReadMacInt32(p + 0x15c) > 0) { |
1943 |
|
|
1944 |
|
// Yes, set function pointer |
1945 |
< |
p->draw_proc = NativeTVECT(NATIVE_BITBLT); |
1945 |
> |
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_BITBLT)); |
1946 |
|
return true; |
1947 |
|
} |
1948 |
|
return false; |
1957 |
|
|
1958 |
|
void VideoInstallAccel(void) |
1959 |
|
{ |
1960 |
+ |
// Temporary hack until it's fixed for e.g. little-endian & 64-bit platforms |
1961 |
+ |
#ifndef __powerpc__ |
1962 |
+ |
return; |
1963 |
+ |
#endif |
1964 |
+ |
|
1965 |
|
// Install acceleration hooks |
1966 |
|
if (PrefsFindBool("gfxaccel")) { |
1967 |
|
D(bug("Video: Installing acceleration hooks\n")); |
1972 |
|
WriteMacInt32(base + 0, NativeTVECT(NATIVE_BITBLT_HOOK)); |
1973 |
|
WriteMacInt32(base + 4, NativeTVECT(NATIVE_SYNC_HOOK)); |
1974 |
|
WriteMacInt32(base + 8, ACCL_BITBLT); |
1779 |
– |
#if defined(__powerpc__) // Temporary hack until it's fixed for e.g. little-endian & 64-bit platforms |
1975 |
|
NQDMisc(6, bitblt_hook_info.ptr()); |
1781 |
– |
#endif |
1976 |
|
|
1977 |
< |
// NQDMisc(6, &fillrect_hook_info); |
1977 |
> |
SheepVar fillrect_hook_info(sizeof(accl_hook_info)); |
1978 |
> |
base = fillrect_hook_info.addr(); |
1979 |
> |
WriteMacInt32(base + 0, NativeTVECT(NATIVE_FILLRECT_HOOK)); |
1980 |
> |
WriteMacInt32(base + 4, NativeTVECT(NATIVE_SYNC_HOOK)); |
1981 |
> |
WriteMacInt32(base + 8, ACCL_FILLRECT); |
1982 |
> |
NQDMisc(6, fillrect_hook_info.ptr()); |
1983 |
|
} |
1984 |
|
} |
1985 |
|
|
2087 |
|
|
2088 |
|
|
2089 |
|
/* |
2090 |
+ |
* Can we set the MacOS cursor image into the window? |
2091 |
+ |
*/ |
2092 |
+ |
|
2093 |
+ |
bool video_can_change_cursor(void) |
2094 |
+ |
{ |
2095 |
+ |
return mac_cursor_enabled && (display_type != DIS_SCREEN); |
2096 |
+ |
} |
2097 |
+ |
|
2098 |
+ |
|
2099 |
+ |
/* |
2100 |
|
* Set cursor image for window |
2101 |
|
*/ |
2102 |
|
|
2341 |
|
update_display(); |
2342 |
|
|
2343 |
|
// Set new cursor image if it was changed |
2344 |
< |
if (cursor_changed) { |
2344 |
> |
if (mac_cursor_enabled && cursor_changed) { |
2345 |
|
cursor_changed = false; |
2346 |
|
memcpy(cursor_image->data, MacCursor + 4, 32); |
2347 |
|
memcpy(cursor_mask_image->data, MacCursor + 36, 32); |