57 |
|
|
58 |
|
// Constants |
59 |
|
const char KEYCODE_FILE_NAME[] = DATADIR "/keycodes"; |
60 |
+ |
static const bool hw_mac_cursor_accl = true; // Flag: Enable MacOS to X11 copy of cursor? |
61 |
|
|
62 |
|
// Global variables |
63 |
|
static int32 frame_skip; |
82 |
|
|
83 |
|
static bool palette_changed = false; // Flag: Palette changed, redraw thread must update palette |
84 |
|
static bool ctrl_down = false; // Flag: Ctrl key pressed |
85 |
+ |
static bool caps_on = false; // Flag: Caps Lock on |
86 |
|
static bool quit_full_screen = false; // Flag: DGA close requested from redraw thread |
87 |
|
static volatile bool quit_full_screen_ack = false; // Acknowledge for quit_full_screen |
88 |
|
static bool emerg_quit = false; // Flag: Ctrl-Esc pressed, emergency quit requested from MacOS thread |
507 |
|
XSetState(x_display, the_gc, black_pixel, white_pixel, GXcopy, AllPlanes); |
508 |
|
|
509 |
|
// Create cursor |
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; |
510 |
> |
if (hw_mac_cursor_accl) { |
511 |
> |
cursor_image = XCreateImage(x_display, vis, 1, XYPixmap, 0, (char *)MacCursor + 4, 16, 16, 16, 2); |
512 |
> |
cursor_image->byte_order = MSBFirst; |
513 |
> |
cursor_image->bitmap_bit_order = MSBFirst; |
514 |
> |
cursor_mask_image = XCreateImage(x_display, vis, 1, XYPixmap, 0, (char *)MacCursor + 36, 16, 16, 16, 2); |
515 |
> |
cursor_mask_image->byte_order = MSBFirst; |
516 |
> |
cursor_mask_image->bitmap_bit_order = MSBFirst; |
517 |
> |
cursor_map = XCreatePixmap(x_display, the_win, 16, 16, 1); |
518 |
> |
cursor_mask_map = XCreatePixmap(x_display, the_win, 16, 16, 1); |
519 |
> |
cursor_gc = XCreateGC(x_display, cursor_map, 0, 0); |
520 |
> |
cursor_mask_gc = XCreateGC(x_display, cursor_mask_map, 0, 0); |
521 |
> |
mac_cursor = XCreatePixmapCursor(x_display, cursor_map, cursor_mask_map, &black, &white, 0, 0); |
522 |
> |
cursor_changed = false; |
523 |
> |
} |
524 |
> |
|
525 |
> |
// Create no_cursor |
526 |
> |
else { |
527 |
> |
mac_cursor = XCreatePixmapCursor(x_display, |
528 |
> |
XCreatePixmap(x_display, the_win, 1, 1, 1), |
529 |
> |
XCreatePixmap(x_display, the_win, 1, 1, 1), |
530 |
> |
&black, &white, 0, 0); |
531 |
> |
XDefineCursor(x_display, the_win, mac_cursor); |
532 |
> |
} |
533 |
|
|
534 |
|
// Init blitting routines |
535 |
|
bool native_byte_order; |
1162 |
|
if (apple_id != -1) |
1163 |
|
cur_mode = find_mode(default_mode, apple_id, DIS_SCREEN); |
1164 |
|
} |
1165 |
< |
if (cur_mode == -1) |
1166 |
< |
cur_mode = find_mode(default_mode, APPLE_W_640x480, DIS_WINDOW); |
1165 |
> |
if (cur_mode == -1) { |
1166 |
> |
// pick up first windowed mode available |
1167 |
> |
for (VideoInfo *p = VModes; p->viType != DIS_INVALID; p++) { |
1168 |
> |
if (p->viType == DIS_WINDOW && p->viAppleMode == default_mode) { |
1169 |
> |
cur_mode = p - VModes; |
1170 |
> |
break; |
1171 |
> |
} |
1172 |
> |
} |
1173 |
> |
} |
1174 |
|
assert(cur_mode != -1); |
1175 |
|
|
1176 |
|
#if DEBUG |
1485 |
|
return -1; |
1486 |
|
} |
1487 |
|
|
1488 |
< |
static int event2keycode(XKeyEvent &ev) |
1488 |
> |
static int event2keycode(XKeyEvent &ev, bool key_down) |
1489 |
|
{ |
1490 |
|
KeySym ks; |
1471 |
– |
int as; |
1491 |
|
int i = 0; |
1492 |
|
|
1493 |
|
do { |
1494 |
|
ks = XLookupKeysym(&ev, i++); |
1495 |
< |
as = kc_decode(ks); |
1496 |
< |
if (as != -1) |
1495 |
> |
int as = kc_decode(ks); |
1496 |
> |
if (as >= 0) |
1497 |
> |
return as; |
1498 |
> |
if (as == -2) |
1499 |
|
return as; |
1500 |
|
} while (ks != NoSymbol); |
1501 |
|
|
1570 |
|
|
1571 |
|
// Keyboard |
1572 |
|
case KeyPress: { |
1573 |
< |
int code = event2keycode(event.xkey); |
1574 |
< |
if (use_keycodes && code != -1) |
1575 |
< |
code = keycode_table[event.xkey.keycode & 0xff]; |
1576 |
< |
if (code != -1) { |
1573 |
> |
int code = -1; |
1574 |
> |
if (use_keycodes) { |
1575 |
> |
if (event2keycode(event.xkey, true) != -2) // This is called to process the hotkeys |
1576 |
> |
code = keycode_table[event.xkey.keycode & 0xff]; |
1577 |
> |
} else |
1578 |
> |
code = event2keycode(event.xkey, true); |
1579 |
> |
if (code >= 0) { |
1580 |
|
if (!emul_suspended) { |
1581 |
< |
ADBKeyDown(code); |
1581 |
> |
if (code == 0x39) { // Caps Lock pressed |
1582 |
> |
if (caps_on) { |
1583 |
> |
ADBKeyUp(code); |
1584 |
> |
caps_on = false; |
1585 |
> |
} else { |
1586 |
> |
ADBKeyDown(code); |
1587 |
> |
caps_on = true; |
1588 |
> |
} |
1589 |
> |
} else |
1590 |
> |
ADBKeyDown(code); |
1591 |
|
if (code == 0x36) |
1592 |
|
ctrl_down = true; |
1593 |
|
} else { |
1598 |
|
break; |
1599 |
|
} |
1600 |
|
case KeyRelease: { |
1601 |
< |
int code = event2keycode(event.xkey); |
1602 |
< |
if (use_keycodes && code != 1) |
1603 |
< |
code = keycode_table[event.xkey.keycode & 0xff]; |
1604 |
< |
if (code != -1) { |
1601 |
> |
int code = -1; |
1602 |
> |
if (use_keycodes) { |
1603 |
> |
if (event2keycode(event.xkey, false) != -2) // This is called to process the hotkeys |
1604 |
> |
code = keycode_table[event.xkey.keycode & 0xff]; |
1605 |
> |
} else |
1606 |
> |
code = event2keycode(event.xkey, false); |
1607 |
> |
if (code >= 0 && code != 0x39) { // Don't propagate Caps Lock releases |
1608 |
|
ADBKeyUp(code); |
1609 |
|
if (code == 0x36) |
1610 |
|
ctrl_down = false; |
1647 |
|
* Install graphics acceleration |
1648 |
|
*/ |
1649 |
|
|
1650 |
< |
#if 0 |
1651 |
< |
// Rectangle filling/inversion |
1652 |
< |
static void accl_fillrect8(accl_params *p) |
1650 |
> |
// Rectangle inversion |
1651 |
> |
template< int bpp > |
1652 |
> |
static inline void do_invrect(uint8 *dest, uint32 length) |
1653 |
|
{ |
1654 |
< |
D(bug("accl_fillrect8\n")); |
1654 |
> |
#define INVERT_1(PTR, OFS) ((uint8 *)(PTR))[OFS] = ~((uint8 *)(PTR))[OFS] |
1655 |
> |
#define INVERT_2(PTR, OFS) ((uint16 *)(PTR))[OFS] = ~((uint16 *)(PTR))[OFS] |
1656 |
> |
#define INVERT_4(PTR, OFS) ((uint32 *)(PTR))[OFS] = ~((uint32 *)(PTR))[OFS] |
1657 |
> |
#define INVERT_8(PTR, OFS) ((uint64 *)(PTR))[OFS] = ~((uint64 *)(PTR))[OFS] |
1658 |
|
|
1659 |
< |
// Get filling parameters |
1660 |
< |
int16 dest_X = p->dest_rect[1] - p->dest_bounds[1]; |
1661 |
< |
int16 dest_Y = p->dest_rect[0] - p->dest_bounds[0]; |
1662 |
< |
int16 dest_X_max = p->dest_rect[3] - p->dest_bounds[1] - 1; |
1663 |
< |
int16 dest_Y_max = p->dest_rect[2] - p->dest_bounds[0] - 1; |
1664 |
< |
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)); |
1659 |
> |
#ifndef UNALIGNED_PROFITABLE |
1660 |
> |
// Align on 16-bit boundaries |
1661 |
> |
if (bpp < 16 && (((uintptr)dest) & 1)) { |
1662 |
> |
INVERT_1(dest, 0); |
1663 |
> |
dest += 1; length -= 1; |
1664 |
> |
} |
1665 |
|
|
1666 |
< |
// And perform the fill |
1667 |
< |
fillrect8_hook(dest_X, dest_Y, dest_X_max, dest_Y_max, color); |
1668 |
< |
} |
1666 |
> |
// Align on 32-bit boundaries |
1667 |
> |
if (bpp < 32 && (((uintptr)dest) & 2)) { |
1668 |
> |
INVERT_2(dest, 0); |
1669 |
> |
dest += 2; length -= 2; |
1670 |
> |
} |
1671 |
> |
#endif |
1672 |
|
|
1673 |
< |
static void accl_fillrect32(accl_params *p) |
1674 |
< |
{ |
1675 |
< |
D(bug("accl_fillrect32\n")); |
1673 |
> |
// Invert 8-byte words |
1674 |
> |
if (length >= 8) { |
1675 |
> |
const int r = (length / 8) % 8; |
1676 |
> |
dest += r * 8; |
1677 |
|
|
1678 |
< |
// Get filling parameters |
1679 |
< |
int16 dest_X = p->dest_rect[1] - p->dest_bounds[1]; |
1680 |
< |
int16 dest_Y = p->dest_rect[0] - p->dest_bounds[0]; |
1681 |
< |
int16 dest_X_max = p->dest_rect[3] - p->dest_bounds[1] - 1; |
1682 |
< |
int16 dest_Y_max = p->dest_rect[2] - p->dest_bounds[0] - 1; |
1683 |
< |
uint32 color = p->pen_mode == 8 ? p->fore_pen : p->back_pen; |
1684 |
< |
D(bug(" dest X %d, dest Y %d\n", dest_X, dest_Y)); |
1685 |
< |
D(bug(" dest X max %d, dest Y max %d\n", dest_X_max, dest_Y_max)); |
1678 |
> |
int n = ((length / 8) + 7) / 8; |
1679 |
> |
switch (r) { |
1680 |
> |
case 0: do { |
1681 |
> |
dest += 64; |
1682 |
> |
INVERT_8(dest, -8); |
1683 |
> |
case 7: INVERT_8(dest, -7); |
1684 |
> |
case 6: INVERT_8(dest, -6); |
1685 |
> |
case 5: INVERT_8(dest, -5); |
1686 |
> |
case 4: INVERT_8(dest, -4); |
1687 |
> |
case 3: INVERT_8(dest, -3); |
1688 |
> |
case 2: INVERT_8(dest, -2); |
1689 |
> |
case 1: INVERT_8(dest, -1); |
1690 |
> |
} while (--n > 0); |
1691 |
> |
} |
1692 |
> |
} |
1693 |
|
|
1694 |
< |
// And perform the fill |
1695 |
< |
fillrect32_hook(dest_X, dest_Y, dest_X_max, dest_Y_max, color); |
1694 |
> |
// 32-bit cell to invert? |
1695 |
> |
if (length & 4) { |
1696 |
> |
INVERT_4(dest, 0); |
1697 |
> |
if (bpp <= 16) |
1698 |
> |
dest += 4; |
1699 |
> |
} |
1700 |
> |
|
1701 |
> |
// 16-bit cell to invert? |
1702 |
> |
if (bpp <= 16 && (length & 2)) { |
1703 |
> |
INVERT_2(dest, 0); |
1704 |
> |
if (bpp <= 8) |
1705 |
> |
dest += 2; |
1706 |
> |
} |
1707 |
> |
|
1708 |
> |
// 8-bit cell to invert? |
1709 |
> |
if (bpp <= 8 && (length & 1)) |
1710 |
> |
INVERT_1(dest, 0); |
1711 |
> |
|
1712 |
> |
#undef INVERT_1 |
1713 |
> |
#undef INVERT_2 |
1714 |
> |
#undef INVERT_4 |
1715 |
> |
#undef INVERT_8 |
1716 |
|
} |
1717 |
|
|
1718 |
< |
static void accl_invrect(accl_params *p) |
1718 |
> |
void NQD_invrect(uint32 p) |
1719 |
|
{ |
1720 |
< |
D(bug("accl_invrect\n")); |
1720 |
> |
D(bug("accl_invrect %08x\n", p)); |
1721 |
|
|
1722 |
|
// Get inversion parameters |
1723 |
< |
int16 dest_X = p->dest_rect[1] - p->dest_bounds[1]; |
1724 |
< |
int16 dest_Y = p->dest_rect[0] - p->dest_bounds[0]; |
1725 |
< |
int16 dest_X_max = p->dest_rect[3] - p->dest_bounds[1] - 1; |
1726 |
< |
int16 dest_Y_max = p->dest_rect[2] - p->dest_bounds[0] - 1; |
1723 |
> |
int16 dest_X = (int16)ReadMacInt16(p + acclDestRect + 2) - (int16)ReadMacInt16(p + acclDestBoundsRect + 2); |
1724 |
> |
int16 dest_Y = (int16)ReadMacInt16(p + acclDestRect + 0) - (int16)ReadMacInt16(p + acclDestBoundsRect + 0); |
1725 |
> |
int16 width = (int16)ReadMacInt16(p + acclDestRect + 6) - (int16)ReadMacInt16(p + acclDestRect + 2); |
1726 |
> |
int16 height = (int16)ReadMacInt16(p + acclDestRect + 4) - (int16)ReadMacInt16(p + acclDestRect + 0); |
1727 |
|
D(bug(" dest X %d, dest Y %d\n", dest_X, dest_Y)); |
1728 |
< |
D(bug(" dest X max %d, dest Y max %d\n", dest_X_max, dest_Y_max)); |
1728 |
> |
D(bug(" width %d, height %d, bytes_per_row %d\n", width, height, (int32)ReadMacInt32(p + acclDestRowBytes))); |
1729 |
|
|
1730 |
|
//!!?? pen_mode == 14 |
1731 |
|
|
1732 |
|
// And perform the inversion |
1733 |
< |
invrect_hook(dest_X, dest_Y, dest_X_max, dest_Y_max); |
1733 |
> |
const int bpp = bytes_per_pixel(ReadMacInt32(p + acclDestPixelSize)); |
1734 |
> |
const int dest_row_bytes = (int32)ReadMacInt32(p + acclDestRowBytes); |
1735 |
> |
uint8 *dest = Mac2HostAddr(ReadMacInt32(p + acclDestBaseAddr) + (dest_Y * dest_row_bytes) + (dest_X * bpp)); |
1736 |
> |
width *= bpp; |
1737 |
> |
switch (bpp) { |
1738 |
> |
case 1: |
1739 |
> |
for (int i = 0; i < height; i++) { |
1740 |
> |
do_invrect<8>(dest, width); |
1741 |
> |
dest += dest_row_bytes; |
1742 |
> |
} |
1743 |
> |
break; |
1744 |
> |
case 2: |
1745 |
> |
for (int i = 0; i < height; i++) { |
1746 |
> |
do_invrect<16>(dest, width); |
1747 |
> |
dest += dest_row_bytes; |
1748 |
> |
} |
1749 |
> |
break; |
1750 |
> |
case 4: |
1751 |
> |
for (int i = 0; i < height; i++) { |
1752 |
> |
do_invrect<32>(dest, width); |
1753 |
> |
dest += dest_row_bytes; |
1754 |
> |
} |
1755 |
> |
break; |
1756 |
> |
} |
1757 |
|
} |
1758 |
|
|
1759 |
< |
static bool accl_fillrect_hook(accl_params *p) |
1759 |
> |
// Rectangle filling |
1760 |
> |
template< int bpp > |
1761 |
> |
static inline void do_fillrect(uint8 *dest, uint32 color, uint32 length) |
1762 |
|
{ |
1763 |
< |
D(bug("accl_fillrect_hook %p\n", p)); |
1763 |
> |
#define FILL_1(PTR, OFS, VAL) ((uint8 *)(PTR))[OFS] = (VAL) |
1764 |
> |
#define FILL_2(PTR, OFS, VAL) ((uint16 *)(PTR))[OFS] = (VAL) |
1765 |
> |
#define FILL_4(PTR, OFS, VAL) ((uint32 *)(PTR))[OFS] = (VAL) |
1766 |
> |
#define FILL_8(PTR, OFS, VAL) ((uint64 *)(PTR))[OFS] = (VAL) |
1767 |
> |
|
1768 |
> |
#ifndef UNALIGNED_PROFITABLE |
1769 |
> |
// Align on 16-bit boundaries |
1770 |
> |
if (bpp < 16 && (((uintptr)dest) & 1)) { |
1771 |
> |
FILL_1(dest, 0, color); |
1772 |
> |
dest += 1; length -= 1; |
1773 |
> |
} |
1774 |
> |
|
1775 |
> |
// Align on 32-bit boundaries |
1776 |
> |
if (bpp < 32 && (((uintptr)dest) & 2)) { |
1777 |
> |
FILL_2(dest, 0, color); |
1778 |
> |
dest += 2; length -= 2; |
1779 |
> |
} |
1780 |
> |
#endif |
1781 |
> |
|
1782 |
> |
// Fill 8-byte words |
1783 |
> |
if (length >= 8) { |
1784 |
> |
const uint64 c = (((uint64)color) << 32) | color; |
1785 |
> |
const int r = (length / 8) % 8; |
1786 |
> |
dest += r * 8; |
1787 |
> |
|
1788 |
> |
int n = ((length / 8) + 7) / 8; |
1789 |
> |
switch (r) { |
1790 |
> |
case 0: do { |
1791 |
> |
dest += 64; |
1792 |
> |
FILL_8(dest, -8, c); |
1793 |
> |
case 7: FILL_8(dest, -7, c); |
1794 |
> |
case 6: FILL_8(dest, -6, c); |
1795 |
> |
case 5: FILL_8(dest, -5, c); |
1796 |
> |
case 4: FILL_8(dest, -4, c); |
1797 |
> |
case 3: FILL_8(dest, -3, c); |
1798 |
> |
case 2: FILL_8(dest, -2, c); |
1799 |
> |
case 1: FILL_8(dest, -1, c); |
1800 |
> |
} while (--n > 0); |
1801 |
> |
} |
1802 |
> |
} |
1803 |
> |
|
1804 |
> |
// 32-bit cell to fill? |
1805 |
> |
if (length & 4) { |
1806 |
> |
FILL_4(dest, 0, color); |
1807 |
> |
if (bpp <= 16) |
1808 |
> |
dest += 4; |
1809 |
> |
} |
1810 |
> |
|
1811 |
> |
// 16-bit cell to fill? |
1812 |
> |
if (bpp <= 16 && (length & 2)) { |
1813 |
> |
FILL_2(dest, 0, color); |
1814 |
> |
if (bpp <= 8) |
1815 |
> |
dest += 2; |
1816 |
> |
} |
1817 |
> |
|
1818 |
> |
// 8-bit cell to fill? |
1819 |
> |
if (bpp <= 8 && (length & 1)) |
1820 |
> |
FILL_1(dest, 0, color); |
1821 |
> |
|
1822 |
> |
#undef FILL_1 |
1823 |
> |
#undef FILL_2 |
1824 |
> |
#undef FILL_4 |
1825 |
> |
#undef FILL_8 |
1826 |
> |
} |
1827 |
> |
|
1828 |
> |
void NQD_fillrect(uint32 p) |
1829 |
> |
{ |
1830 |
> |
D(bug("accl_fillrect %08x\n", p)); |
1831 |
> |
|
1832 |
> |
// Get filling parameters |
1833 |
> |
int16 dest_X = (int16)ReadMacInt16(p + acclDestRect + 2) - (int16)ReadMacInt16(p + acclDestBoundsRect + 2); |
1834 |
> |
int16 dest_Y = (int16)ReadMacInt16(p + acclDestRect + 0) - (int16)ReadMacInt16(p + acclDestBoundsRect + 0); |
1835 |
> |
int16 width = (int16)ReadMacInt16(p + acclDestRect + 6) - (int16)ReadMacInt16(p + acclDestRect + 2); |
1836 |
> |
int16 height = (int16)ReadMacInt16(p + acclDestRect + 4) - (int16)ReadMacInt16(p + acclDestRect + 0); |
1837 |
> |
uint32 color = htonl(ReadMacInt32(p + acclPenMode) == 8 ? ReadMacInt32(p + acclForePen) : ReadMacInt32(p + acclBackPen)); |
1838 |
> |
D(bug(" dest X %d, dest Y %d\n", dest_X, dest_Y)); |
1839 |
> |
D(bug(" width %d, height %d\n", width, height)); |
1840 |
> |
D(bug(" bytes_per_row %d color %08x\n", (int32)ReadMacInt32(p + acclDestRowBytes), color)); |
1841 |
> |
|
1842 |
> |
// And perform the fill |
1843 |
> |
const int bpp = bytes_per_pixel(ReadMacInt32(p + acclDestPixelSize)); |
1844 |
> |
const int dest_row_bytes = (int32)ReadMacInt32(p + acclDestRowBytes); |
1845 |
> |
uint8 *dest = Mac2HostAddr(ReadMacInt32(p + acclDestBaseAddr) + (dest_Y * dest_row_bytes) + (dest_X * bpp)); |
1846 |
> |
width *= bpp; |
1847 |
> |
switch (bpp) { |
1848 |
> |
case 1: |
1849 |
> |
for (int i = 0; i < height; i++) { |
1850 |
> |
memset(dest, color, width); |
1851 |
> |
dest += dest_row_bytes; |
1852 |
> |
} |
1853 |
> |
break; |
1854 |
> |
case 2: |
1855 |
> |
for (int i = 0; i < height; i++) { |
1856 |
> |
do_fillrect<16>(dest, color, width); |
1857 |
> |
dest += dest_row_bytes; |
1858 |
> |
} |
1859 |
> |
break; |
1860 |
> |
case 4: |
1861 |
> |
for (int i = 0; i < height; i++) { |
1862 |
> |
do_fillrect<32>(dest, color, width); |
1863 |
> |
dest += dest_row_bytes; |
1864 |
> |
} |
1865 |
> |
break; |
1866 |
> |
} |
1867 |
> |
} |
1868 |
> |
|
1869 |
> |
bool NQD_fillrect_hook(uint32 p) |
1870 |
> |
{ |
1871 |
> |
D(bug("accl_fillrect_hook %08x\n", p)); |
1872 |
|
|
1873 |
|
// Check if we can accelerate this fillrect |
1874 |
< |
if (p->dest_base_addr == screen_base && ((uint32 *)p)[0x284 >> 2] != 0 && display_type == DIS_SCREEN) { |
1875 |
< |
if (p->transfer_mode == 8) { |
1874 |
> |
if (ReadMacInt32(p + 0x284) != 0 && ReadMacInt32(p + acclDestPixelSize) >= 8) { |
1875 |
> |
const int transfer_mode = ReadMacInt32(p + acclTransferMode); |
1876 |
> |
if (transfer_mode == 8) { |
1877 |
|
// Fill |
1878 |
< |
if (p->dest_pixel_size == 8 && fillrect8_hook != NULL) { |
1879 |
< |
p->draw_proc = accl_fillrect8; |
1880 |
< |
return true; |
1881 |
< |
} 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) { |
1878 |
> |
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_FILLRECT)); |
1879 |
> |
return true; |
1880 |
> |
} |
1881 |
> |
else if (transfer_mode == 10) { |
1882 |
|
// Invert |
1883 |
< |
p->draw_proc = accl_invrect; |
1883 |
> |
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_INVRECT)); |
1884 |
|
return true; |
1885 |
|
} |
1886 |
|
} |
1887 |
|
return false; |
1888 |
|
} |
1889 |
|
|
1692 |
– |
static struct accl_hook_info fillrect_hook_info = {accl_fillrect_hook, accl_sync_hook, ACCL_FILLRECT}; |
1693 |
– |
#endif |
1694 |
– |
|
1890 |
|
// Rectangle blitting |
1891 |
|
// TODO: optimize for VOSF and target pixmap == screen |
1892 |
< |
void NQD_bitblt(uint32 arg) |
1892 |
> |
void NQD_bitblt(uint32 p) |
1893 |
|
{ |
1894 |
< |
D(bug("accl_bitblt %08x\n", arg)); |
1700 |
< |
accl_params *p = (accl_params *)arg; |
1894 |
> |
D(bug("accl_bitblt %08x\n", p)); |
1895 |
|
|
1896 |
|
// Get blitting parameters |
1897 |
< |
int16 src_X = p->src_rect[1] - p->src_bounds[1]; |
1898 |
< |
int16 src_Y = p->src_rect[0] - p->src_bounds[0]; |
1899 |
< |
int16 dest_X = p->dest_rect[1] - p->dest_bounds[1]; |
1900 |
< |
int16 dest_Y = p->dest_rect[0] - p->dest_bounds[0]; |
1901 |
< |
int16 width = p->dest_rect[3] - p->dest_rect[1]; |
1902 |
< |
int16 height = p->dest_rect[2] - p->dest_rect[0]; |
1903 |
< |
D(bug(" src addr %08x, dest addr %08x\n", p->src_base_addr, p->dest_base_addr)); |
1897 |
> |
int16 src_X = (int16)ReadMacInt16(p + acclSrcRect + 2) - (int16)ReadMacInt16(p + acclSrcBoundsRect + 2); |
1898 |
> |
int16 src_Y = (int16)ReadMacInt16(p + acclSrcRect + 0) - (int16)ReadMacInt16(p + acclSrcBoundsRect + 0); |
1899 |
> |
int16 dest_X = (int16)ReadMacInt16(p + acclDestRect + 2) - (int16)ReadMacInt16(p + acclDestBoundsRect + 2); |
1900 |
> |
int16 dest_Y = (int16)ReadMacInt16(p + acclDestRect + 0) - (int16)ReadMacInt16(p + acclDestBoundsRect + 0); |
1901 |
> |
int16 width = (int16)ReadMacInt16(p + acclDestRect + 6) - (int16)ReadMacInt16(p + acclDestRect + 2); |
1902 |
> |
int16 height = (int16)ReadMacInt16(p + acclDestRect + 4) - (int16)ReadMacInt16(p + acclDestRect + 0); |
1903 |
> |
D(bug(" src addr %08x, dest addr %08x\n", ReadMacInt32(p + acclSrcBaseAddr), ReadMacInt32(p + acclDestBaseAddr))); |
1904 |
|
D(bug(" src X %d, src Y %d, dest X %d, dest Y %d\n", src_X, src_Y, dest_X, dest_Y)); |
1905 |
|
D(bug(" width %d, height %d\n", width, height)); |
1906 |
|
|
1907 |
|
// And perform the blit |
1908 |
< |
const int bpp = bytes_per_pixel(p->src_pixel_size); |
1908 |
> |
const int bpp = bytes_per_pixel(ReadMacInt32(p + acclSrcPixelSize)); |
1909 |
|
width *= bpp; |
1910 |
< |
if (p->src_row_bytes > 0) { |
1911 |
< |
const int src_row_bytes = p->src_row_bytes; |
1912 |
< |
const int dst_row_bytes = p->dest_row_bytes; |
1913 |
< |
uint8 *src = (uint8 *)p->src_base_addr + (src_Y * src_row_bytes) + (src_X * bpp); |
1914 |
< |
uint8 *dst = (uint8 *)p->dest_base_addr + (dest_Y * dst_row_bytes) + (dest_X * bpp); |
1910 |
> |
if ((int32)ReadMacInt32(p + acclSrcRowBytes) > 0) { |
1911 |
> |
const int src_row_bytes = (int32)ReadMacInt32(p + acclSrcRowBytes); |
1912 |
> |
const int dst_row_bytes = (int32)ReadMacInt32(p + acclDestRowBytes); |
1913 |
> |
uint8 *src = Mac2HostAddr(ReadMacInt32(p + acclSrcBaseAddr) + (src_Y * src_row_bytes) + (src_X * bpp)); |
1914 |
> |
uint8 *dst = Mac2HostAddr(ReadMacInt32(p + acclDestBaseAddr) + (dest_Y * dst_row_bytes) + (dest_X * bpp)); |
1915 |
|
for (int i = 0; i < height; i++) { |
1916 |
< |
memcpy(dst, src, width); |
1916 |
> |
memmove(dst, src, width); |
1917 |
|
src += src_row_bytes; |
1918 |
|
dst += dst_row_bytes; |
1919 |
|
} |
1920 |
|
} |
1921 |
|
else { |
1922 |
< |
const int src_row_bytes = -p->src_row_bytes; |
1923 |
< |
const int dst_row_bytes = -p->dest_row_bytes; |
1924 |
< |
uint8 *src = (uint8 *)p->src_base_addr + ((src_Y + height - 1) * src_row_bytes) + (src_X * bpp); |
1925 |
< |
uint8 *dst = (uint8 *)p->dest_base_addr + ((dest_Y + height - 1) * dst_row_bytes) + (dest_X * bpp); |
1922 |
> |
const int src_row_bytes = -(int32)ReadMacInt32(p + acclSrcRowBytes); |
1923 |
> |
const int dst_row_bytes = -(int32)ReadMacInt32(p + acclDestRowBytes); |
1924 |
> |
uint8 *src = Mac2HostAddr(ReadMacInt32(p + acclSrcBaseAddr) + ((src_Y + height - 1) * src_row_bytes) + (src_X * bpp)); |
1925 |
> |
uint8 *dst = Mac2HostAddr(ReadMacInt32(p + acclDestBaseAddr) + ((dest_Y + height - 1) * dst_row_bytes) + (dest_X * bpp)); |
1926 |
|
for (int i = height - 1; i >= 0; i--) { |
1927 |
< |
memcpy(dst, src, width); |
1927 |
> |
memmove(dst, src, width); |
1928 |
|
src -= src_row_bytes; |
1929 |
|
dst -= dst_row_bytes; |
1930 |
|
} |
1931 |
|
} |
1932 |
|
} |
1933 |
|
|
1934 |
< |
bool NQD_bitblt_hook(uint32 arg) |
1934 |
> |
/* |
1935 |
> |
BitBlt transfer modes: |
1936 |
> |
0 : srcCopy |
1937 |
> |
1 : srcOr |
1938 |
> |
2 : srcXor |
1939 |
> |
3 : srcBic |
1940 |
> |
4 : notSrcCopy |
1941 |
> |
5 : notSrcOr |
1942 |
> |
6 : notSrcXor |
1943 |
> |
7 : notSrcBic |
1944 |
> |
32 : blend |
1945 |
> |
33 : addPin |
1946 |
> |
34 : addOver |
1947 |
> |
35 : subPin |
1948 |
> |
36 : transparent |
1949 |
> |
37 : adMax |
1950 |
> |
38 : subOver |
1951 |
> |
39 : adMin |
1952 |
> |
50 : hilite |
1953 |
> |
*/ |
1954 |
> |
|
1955 |
> |
bool NQD_bitblt_hook(uint32 p) |
1956 |
|
{ |
1957 |
< |
D(bug("accl_draw_hook %08x\n", arg)); |
1743 |
< |
accl_params *p = (accl_params *)arg; |
1957 |
> |
D(bug("accl_draw_hook %08x\n", p)); |
1958 |
|
|
1959 |
|
// Check if we can accelerate this bitblt |
1960 |
< |
if (((uint32 *)p)[0x18 >> 2] + ((uint32 *)p)[0x128 >> 2] == 0 && |
1961 |
< |
((uint32 *)p)[0x130 >> 2] == 0 && |
1962 |
< |
p->src_pixel_size >= 8 && p->src_pixel_size == p->dest_pixel_size && |
1963 |
< |
((p->src_row_bytes ^ p->dest_row_bytes) >> 31) == 0 && |
1964 |
< |
p->transfer_mode == 0 && |
1965 |
< |
((uint32 *)p)[0x15c >> 2] > 0) { |
1960 |
> |
if (ReadMacInt32(p + 0x018) + ReadMacInt32(p + 0x128) == 0 && |
1961 |
> |
ReadMacInt32(p + 0x130) == 0 && |
1962 |
> |
ReadMacInt32(p + acclSrcPixelSize) >= 8 && |
1963 |
> |
ReadMacInt32(p + acclSrcPixelSize) == ReadMacInt32(p + acclDestPixelSize) && |
1964 |
> |
(ReadMacInt32(p + acclSrcRowBytes) ^ ReadMacInt32(p + acclDestRowBytes)) >= 0 && // same sign? |
1965 |
> |
ReadMacInt32(p + acclTransferMode) == 0 && // srcCopy? |
1966 |
> |
ReadMacInt32(p + 0x15c) > 0) { |
1967 |
|
|
1968 |
|
// Yes, set function pointer |
1969 |
< |
p->draw_proc = NativeTVECT(NATIVE_BITBLT); |
1969 |
> |
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_BITBLT)); |
1970 |
|
return true; |
1971 |
|
} |
1972 |
|
return false; |
1991 |
|
WriteMacInt32(base + 0, NativeTVECT(NATIVE_BITBLT_HOOK)); |
1992 |
|
WriteMacInt32(base + 4, NativeTVECT(NATIVE_SYNC_HOOK)); |
1993 |
|
WriteMacInt32(base + 8, ACCL_BITBLT); |
1779 |
– |
#if defined(__powerpc__) // Temporary hack until it's fixed for e.g. little-endian & 64-bit platforms |
1994 |
|
NQDMisc(6, bitblt_hook_info.ptr()); |
1781 |
– |
#endif |
1995 |
|
|
1996 |
< |
// NQDMisc(6, &fillrect_hook_info); |
1996 |
> |
SheepVar fillrect_hook_info(sizeof(accl_hook_info)); |
1997 |
> |
base = fillrect_hook_info.addr(); |
1998 |
> |
WriteMacInt32(base + 0, NativeTVECT(NATIVE_FILLRECT_HOOK)); |
1999 |
> |
WriteMacInt32(base + 4, NativeTVECT(NATIVE_SYNC_HOOK)); |
2000 |
> |
WriteMacInt32(base + 8, ACCL_FILLRECT); |
2001 |
> |
NQDMisc(6, fillrect_hook_info.ptr()); |
2002 |
|
} |
2003 |
|
} |
2004 |
|
|
2106 |
|
|
2107 |
|
|
2108 |
|
/* |
2109 |
+ |
* Can we set the MacOS cursor image into the window? |
2110 |
+ |
*/ |
2111 |
+ |
|
2112 |
+ |
bool video_can_change_cursor(void) |
2113 |
+ |
{ |
2114 |
+ |
return hw_mac_cursor_accl && (display_type != DIS_SCREEN); |
2115 |
+ |
} |
2116 |
+ |
|
2117 |
+ |
|
2118 |
+ |
/* |
2119 |
|
* Set cursor image for window |
2120 |
|
*/ |
2121 |
|
|
2360 |
|
update_display(); |
2361 |
|
|
2362 |
|
// Set new cursor image if it was changed |
2363 |
< |
if (cursor_changed) { |
2363 |
> |
if (hw_mac_cursor_accl && cursor_changed) { |
2364 |
|
cursor_changed = false; |
2365 |
|
memcpy(cursor_image->data, MacCursor + 4, 32); |
2366 |
|
memcpy(cursor_mask_image->data, MacCursor + 36, 32); |