37 |
|
* Besides, there can't seem to be a way to call SetVideoMode() from a child thread. |
38 |
|
* - Refresh performance is still slow. Use SDL_CreateRGBSurface()? |
39 |
|
* - Backport hw cursor acceleration to Basilisk II? |
40 |
– |
* - Move generic Native QuickDraw acceleration routines to gfxaccel.cpp |
40 |
|
*/ |
41 |
|
|
42 |
|
#include "sysdeps.h" |
324 |
|
} |
325 |
|
|
326 |
|
// Map video_mode depth ID to numerical depth value |
327 |
< |
static int sdl_depth_of_video_depth(int video_depth) |
327 |
> |
static int mac_depth_of_video_depth(int video_depth) |
328 |
|
{ |
329 |
|
int depth = -1; |
330 |
|
switch (video_depth) { |
352 |
|
return depth; |
353 |
|
} |
354 |
|
|
355 |
+ |
// Map video_mode depth ID to SDL screen depth |
356 |
+ |
static int sdl_depth_of_video_depth(int video_depth) |
357 |
+ |
{ |
358 |
+ |
return (video_depth <= VIDEO_DEPTH_8BIT) ? 8 : mac_depth_of_video_depth(video_depth); |
359 |
+ |
} |
360 |
+ |
|
361 |
|
// Check wether specified mode is available |
362 |
|
static bool has_mode(int type, int width, int height) |
363 |
|
{ |
418 |
|
VIDEO_MODE_Y = height; |
419 |
|
VIDEO_MODE_RESOLUTION = resolution_id; |
420 |
|
VIDEO_MODE_ROW_BYTES = bytes_per_row; |
421 |
< |
VIDEO_MODE_DEPTH = depth; |
421 |
> |
VIDEO_MODE_DEPTH = (video_depth)depth; |
422 |
|
VideoModes.push_back(mode); |
423 |
|
} |
424 |
|
|
592 |
|
{ |
593 |
|
const VIDEO_MODE &mode = monitor.get_current_mode(); |
594 |
|
|
595 |
< |
if (VIDEO_MODE_DEPTH <= VIDEO_DEPTH_8BIT) |
595 |
> |
if ((int)VIDEO_MODE_DEPTH <= VIDEO_DEPTH_8BIT) |
596 |
|
SDL_SetPalette(s, SDL_PHYSPAL, sdl_palette, 0, 256); |
597 |
|
} |
598 |
|
|
623 |
|
ADBSetRelMouseMode(mouse_grabbed); |
624 |
|
|
625 |
|
// Create surface |
626 |
< |
int depth = (VIDEO_MODE_DEPTH <= VIDEO_DEPTH_8BIT ? 8 : screen_depth); |
626 |
> |
int depth = sdl_depth_of_video_depth(VIDEO_MODE_DEPTH); |
627 |
|
if ((s = SDL_SetVideoMode(width, height, depth, SDL_HWSURFACE)) == NULL) |
628 |
|
return; |
629 |
|
|
681 |
|
visualFormat.Rmask = f->Rmask; |
682 |
|
visualFormat.Gmask = f->Gmask; |
683 |
|
visualFormat.Bmask = f->Bmask; |
684 |
< |
Screen_blitter_init(visualFormat, true, sdl_depth_of_video_depth(VIDEO_MODE_DEPTH)); |
684 |
> |
Screen_blitter_init(visualFormat, true, mac_depth_of_video_depth(VIDEO_MODE_DEPTH)); |
685 |
|
|
686 |
|
// Load gray ramp to 8->16/32 expand map |
687 |
|
if (!IsDirectMode(mode)) |
792 |
|
|
793 |
|
if (video_driver_found) { |
794 |
|
// Skip aliases |
795 |
< |
static const char alias_str[] = "alias"; |
796 |
< |
if (strncmp(line, alias_str, sizeof(alias_str) - 1) == 0) |
795 |
> |
static const char sdl_str[] = "sdl"; |
796 |
> |
if (strncmp(line, sdl_str, sizeof(sdl_str) - 1) == 0) |
797 |
|
continue; |
798 |
|
|
799 |
|
// Read keycode |
804 |
|
break; |
805 |
|
} else { |
806 |
|
// Search for SDL video driver string |
807 |
< |
static const char alias_sdl_str[] = "alias SDL"; |
808 |
< |
if (strncmp(line, alias_sdl_str, sizeof(alias_sdl_str) - 1) == 0) { |
809 |
< |
char *p = line + sizeof(alias_sdl_str); |
807 |
> |
static const char sdl_str[] = "sdl"; |
808 |
> |
if (strncmp(line, sdl_str, sizeof(sdl_str) - 1) == 0) { |
809 |
> |
char *p = line + sizeof(sdl_str); |
810 |
|
if (strstr(video_driver, p) == video_driver) |
811 |
|
video_driver_found = true; |
812 |
|
} |
960 |
|
add_mode(display_type, 512, 342, 0x80, 64, VIDEO_DEPTH_1BIT); |
961 |
|
else { |
962 |
|
for (int d = VIDEO_DEPTH_1BIT; d <= default_depth; d++) { |
963 |
< |
int bpp = (d <= VIDEO_DEPTH_8BIT ? 8 : sdl_depth_of_video_depth(d)); |
963 |
> |
int bpp = sdl_depth_of_video_depth(d); |
964 |
|
if (SDL_VideoModeOK(max_width, max_height, bpp, SDL_HWSURFACE)) |
965 |
|
add_window_modes(video_depth(d)); |
966 |
|
} |
1152 |
|
const VIDEO_MODE &mode = get_current_mode(); |
1153 |
|
|
1154 |
|
// FIXME: how can we handle the gamma ramp? |
1155 |
< |
if (VIDEO_MODE_DEPTH > VIDEO_DEPTH_8BIT) |
1155 |
> |
if ((int)VIDEO_MODE_DEPTH > VIDEO_DEPTH_8BIT) |
1156 |
|
return; |
1157 |
|
|
1158 |
|
LOCK_PALETTE; |
1272 |
|
|
1273 |
|
|
1274 |
|
/* |
1275 |
< |
* Install graphics acceleration |
1275 |
> |
* Keyboard-related utilify functions |
1276 |
|
*/ |
1277 |
|
|
1278 |
< |
#ifdef SHEEPSHAVER |
1274 |
< |
// Rectangle inversion |
1275 |
< |
template< int bpp > |
1276 |
< |
static inline void do_invrect(uint8 *dest, uint32 length) |
1277 |
< |
{ |
1278 |
< |
#define INVERT_1(PTR, OFS) ((uint8 *)(PTR))[OFS] = ~((uint8 *)(PTR))[OFS] |
1279 |
< |
#define INVERT_2(PTR, OFS) ((uint16 *)(PTR))[OFS] = ~((uint16 *)(PTR))[OFS] |
1280 |
< |
#define INVERT_4(PTR, OFS) ((uint32 *)(PTR))[OFS] = ~((uint32 *)(PTR))[OFS] |
1281 |
< |
#define INVERT_8(PTR, OFS) ((uint64 *)(PTR))[OFS] = ~((uint64 *)(PTR))[OFS] |
1282 |
< |
|
1283 |
< |
#ifndef UNALIGNED_PROFITABLE |
1284 |
< |
// Align on 16-bit boundaries |
1285 |
< |
if (bpp < 16 && (((uintptr)dest) & 1)) { |
1286 |
< |
INVERT_1(dest, 0); |
1287 |
< |
dest += 1; length -= 1; |
1288 |
< |
} |
1289 |
< |
|
1290 |
< |
// Align on 32-bit boundaries |
1291 |
< |
if (bpp < 32 && (((uintptr)dest) & 2)) { |
1292 |
< |
INVERT_2(dest, 0); |
1293 |
< |
dest += 2; length -= 2; |
1294 |
< |
} |
1295 |
< |
#endif |
1296 |
< |
|
1297 |
< |
// Invert 8-byte words |
1298 |
< |
if (length >= 8) { |
1299 |
< |
const int r = (length / 8) % 8; |
1300 |
< |
dest += r * 8; |
1301 |
< |
|
1302 |
< |
int n = ((length / 8) + 7) / 8; |
1303 |
< |
switch (r) { |
1304 |
< |
case 0: do { |
1305 |
< |
dest += 64; |
1306 |
< |
INVERT_8(dest, -8); |
1307 |
< |
case 7: INVERT_8(dest, -7); |
1308 |
< |
case 6: INVERT_8(dest, -6); |
1309 |
< |
case 5: INVERT_8(dest, -5); |
1310 |
< |
case 4: INVERT_8(dest, -4); |
1311 |
< |
case 3: INVERT_8(dest, -3); |
1312 |
< |
case 2: INVERT_8(dest, -2); |
1313 |
< |
case 1: INVERT_8(dest, -1); |
1314 |
< |
} while (--n > 0); |
1315 |
< |
} |
1316 |
< |
} |
1317 |
< |
|
1318 |
< |
// 32-bit cell to invert? |
1319 |
< |
if (length & 4) { |
1320 |
< |
INVERT_4(dest, 0); |
1321 |
< |
if (bpp <= 16) |
1322 |
< |
dest += 4; |
1323 |
< |
} |
1324 |
< |
|
1325 |
< |
// 16-bit cell to invert? |
1326 |
< |
if (bpp <= 16 && (length & 2)) { |
1327 |
< |
INVERT_2(dest, 0); |
1328 |
< |
if (bpp <= 8) |
1329 |
< |
dest += 2; |
1330 |
< |
} |
1331 |
< |
|
1332 |
< |
// 8-bit cell to invert? |
1333 |
< |
if (bpp <= 8 && (length & 1)) |
1334 |
< |
INVERT_1(dest, 0); |
1335 |
< |
|
1336 |
< |
#undef INVERT_1 |
1337 |
< |
#undef INVERT_2 |
1338 |
< |
#undef INVERT_4 |
1339 |
< |
#undef INVERT_8 |
1340 |
< |
} |
1341 |
< |
|
1342 |
< |
void NQD_invrect(uint32 p) |
1343 |
< |
{ |
1344 |
< |
D(bug("accl_invrect %08x\n", p)); |
1345 |
< |
|
1346 |
< |
// Get inversion parameters |
1347 |
< |
int16 dest_X = (int16)ReadMacInt16(p + acclDestRect + 2) - (int16)ReadMacInt16(p + acclDestBoundsRect + 2); |
1348 |
< |
int16 dest_Y = (int16)ReadMacInt16(p + acclDestRect + 0) - (int16)ReadMacInt16(p + acclDestBoundsRect + 0); |
1349 |
< |
int16 width = (int16)ReadMacInt16(p + acclDestRect + 6) - (int16)ReadMacInt16(p + acclDestRect + 2); |
1350 |
< |
int16 height = (int16)ReadMacInt16(p + acclDestRect + 4) - (int16)ReadMacInt16(p + acclDestRect + 0); |
1351 |
< |
D(bug(" dest X %d, dest Y %d\n", dest_X, dest_Y)); |
1352 |
< |
D(bug(" width %d, height %d, bytes_per_row %d\n", width, height, (int32)ReadMacInt32(p + acclDestRowBytes))); |
1353 |
< |
|
1354 |
< |
//!!?? pen_mode == 14 |
1355 |
< |
|
1356 |
< |
// And perform the inversion |
1357 |
< |
const int bpp = bytes_per_pixel(ReadMacInt32(p + acclDestPixelSize)); |
1358 |
< |
const int dest_row_bytes = (int32)ReadMacInt32(p + acclDestRowBytes); |
1359 |
< |
uint8 *dest = Mac2HostAddr(ReadMacInt32(p + acclDestBaseAddr) + (dest_Y * dest_row_bytes) + (dest_X * bpp)); |
1360 |
< |
width *= bpp; |
1361 |
< |
switch (bpp) { |
1362 |
< |
case 1: |
1363 |
< |
for (int i = 0; i < height; i++) { |
1364 |
< |
do_invrect<8>(dest, width); |
1365 |
< |
dest += dest_row_bytes; |
1366 |
< |
} |
1367 |
< |
break; |
1368 |
< |
case 2: |
1369 |
< |
for (int i = 0; i < height; i++) { |
1370 |
< |
do_invrect<16>(dest, width); |
1371 |
< |
dest += dest_row_bytes; |
1372 |
< |
} |
1373 |
< |
break; |
1374 |
< |
case 4: |
1375 |
< |
for (int i = 0; i < height; i++) { |
1376 |
< |
do_invrect<32>(dest, width); |
1377 |
< |
dest += dest_row_bytes; |
1378 |
< |
} |
1379 |
< |
break; |
1380 |
< |
} |
1381 |
< |
} |
1382 |
< |
|
1383 |
< |
// Rectangle filling |
1384 |
< |
template< int bpp > |
1385 |
< |
static inline void do_fillrect(uint8 *dest, uint32 color, uint32 length) |
1386 |
< |
{ |
1387 |
< |
#define FILL_1(PTR, OFS, VAL) ((uint8 *)(PTR))[OFS] = (VAL) |
1388 |
< |
#define FILL_2(PTR, OFS, VAL) ((uint16 *)(PTR))[OFS] = (VAL) |
1389 |
< |
#define FILL_4(PTR, OFS, VAL) ((uint32 *)(PTR))[OFS] = (VAL) |
1390 |
< |
#define FILL_8(PTR, OFS, VAL) ((uint64 *)(PTR))[OFS] = (VAL) |
1391 |
< |
|
1392 |
< |
#ifndef UNALIGNED_PROFITABLE |
1393 |
< |
// Align on 16-bit boundaries |
1394 |
< |
if (bpp < 16 && (((uintptr)dest) & 1)) { |
1395 |
< |
FILL_1(dest, 0, color); |
1396 |
< |
dest += 1; length -= 1; |
1397 |
< |
} |
1398 |
< |
|
1399 |
< |
// Align on 32-bit boundaries |
1400 |
< |
if (bpp < 32 && (((uintptr)dest) & 2)) { |
1401 |
< |
FILL_2(dest, 0, color); |
1402 |
< |
dest += 2; length -= 2; |
1403 |
< |
} |
1404 |
< |
#endif |
1405 |
< |
|
1406 |
< |
// Fill 8-byte words |
1407 |
< |
if (length >= 8) { |
1408 |
< |
const uint64 c = (((uint64)color) << 32) | color; |
1409 |
< |
const int r = (length / 8) % 8; |
1410 |
< |
dest += r * 8; |
1411 |
< |
|
1412 |
< |
int n = ((length / 8) + 7) / 8; |
1413 |
< |
switch (r) { |
1414 |
< |
case 0: do { |
1415 |
< |
dest += 64; |
1416 |
< |
FILL_8(dest, -8, c); |
1417 |
< |
case 7: FILL_8(dest, -7, c); |
1418 |
< |
case 6: FILL_8(dest, -6, c); |
1419 |
< |
case 5: FILL_8(dest, -5, c); |
1420 |
< |
case 4: FILL_8(dest, -4, c); |
1421 |
< |
case 3: FILL_8(dest, -3, c); |
1422 |
< |
case 2: FILL_8(dest, -2, c); |
1423 |
< |
case 1: FILL_8(dest, -1, c); |
1424 |
< |
} while (--n > 0); |
1425 |
< |
} |
1426 |
< |
} |
1427 |
< |
|
1428 |
< |
// 32-bit cell to fill? |
1429 |
< |
if (length & 4) { |
1430 |
< |
FILL_4(dest, 0, color); |
1431 |
< |
if (bpp <= 16) |
1432 |
< |
dest += 4; |
1433 |
< |
} |
1434 |
< |
|
1435 |
< |
// 16-bit cell to fill? |
1436 |
< |
if (bpp <= 16 && (length & 2)) { |
1437 |
< |
FILL_2(dest, 0, color); |
1438 |
< |
if (bpp <= 8) |
1439 |
< |
dest += 2; |
1440 |
< |
} |
1441 |
< |
|
1442 |
< |
// 8-bit cell to fill? |
1443 |
< |
if (bpp <= 8 && (length & 1)) |
1444 |
< |
FILL_1(dest, 0, color); |
1445 |
< |
|
1446 |
< |
#undef FILL_1 |
1447 |
< |
#undef FILL_2 |
1448 |
< |
#undef FILL_4 |
1449 |
< |
#undef FILL_8 |
1450 |
< |
} |
1451 |
< |
|
1452 |
< |
void NQD_fillrect(uint32 p) |
1453 |
< |
{ |
1454 |
< |
D(bug("accl_fillrect %08x\n", p)); |
1455 |
< |
|
1456 |
< |
// Get filling parameters |
1457 |
< |
int16 dest_X = (int16)ReadMacInt16(p + acclDestRect + 2) - (int16)ReadMacInt16(p + acclDestBoundsRect + 2); |
1458 |
< |
int16 dest_Y = (int16)ReadMacInt16(p + acclDestRect + 0) - (int16)ReadMacInt16(p + acclDestBoundsRect + 0); |
1459 |
< |
int16 width = (int16)ReadMacInt16(p + acclDestRect + 6) - (int16)ReadMacInt16(p + acclDestRect + 2); |
1460 |
< |
int16 height = (int16)ReadMacInt16(p + acclDestRect + 4) - (int16)ReadMacInt16(p + acclDestRect + 0); |
1461 |
< |
uint32 color = htonl(ReadMacInt32(p + acclPenMode) == 8 ? ReadMacInt32(p + acclForePen) : ReadMacInt32(p + acclBackPen)); |
1462 |
< |
D(bug(" dest X %d, dest Y %d\n", dest_X, dest_Y)); |
1463 |
< |
D(bug(" width %d, height %d\n", width, height)); |
1464 |
< |
D(bug(" bytes_per_row %d color %08x\n", (int32)ReadMacInt32(p + acclDestRowBytes), color)); |
1465 |
< |
|
1466 |
< |
// And perform the fill |
1467 |
< |
const int bpp = bytes_per_pixel(ReadMacInt32(p + acclDestPixelSize)); |
1468 |
< |
const int dest_row_bytes = (int32)ReadMacInt32(p + acclDestRowBytes); |
1469 |
< |
uint8 *dest = Mac2HostAddr(ReadMacInt32(p + acclDestBaseAddr) + (dest_Y * dest_row_bytes) + (dest_X * bpp)); |
1470 |
< |
width *= bpp; |
1471 |
< |
switch (bpp) { |
1472 |
< |
case 1: |
1473 |
< |
for (int i = 0; i < height; i++) { |
1474 |
< |
memset(dest, color, width); |
1475 |
< |
dest += dest_row_bytes; |
1476 |
< |
} |
1477 |
< |
break; |
1478 |
< |
case 2: |
1479 |
< |
for (int i = 0; i < height; i++) { |
1480 |
< |
do_fillrect<16>(dest, color, width); |
1481 |
< |
dest += dest_row_bytes; |
1482 |
< |
} |
1483 |
< |
break; |
1484 |
< |
case 4: |
1485 |
< |
for (int i = 0; i < height; i++) { |
1486 |
< |
do_fillrect<32>(dest, color, width); |
1487 |
< |
dest += dest_row_bytes; |
1488 |
< |
} |
1489 |
< |
break; |
1490 |
< |
} |
1491 |
< |
} |
1492 |
< |
|
1493 |
< |
bool NQD_fillrect_hook(uint32 p) |
1278 |
> |
static bool is_modifier_key(SDL_KeyboardEvent const & e) |
1279 |
|
{ |
1280 |
< |
D(bug("accl_fillrect_hook %08x\n", p)); |
1281 |
< |
|
1282 |
< |
// Check if we can accelerate this fillrect |
1283 |
< |
if (ReadMacInt32(p + 0x284) != 0 && ReadMacInt32(p + acclDestPixelSize) >= 8) { |
1284 |
< |
const int transfer_mode = ReadMacInt32(p + acclTransferMode); |
1285 |
< |
if (transfer_mode == 8) { |
1286 |
< |
// Fill |
1287 |
< |
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_FILLRECT)); |
1288 |
< |
return true; |
1289 |
< |
} |
1290 |
< |
else if (transfer_mode == 10) { |
1291 |
< |
// Invert |
1292 |
< |
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_INVRECT)); |
1293 |
< |
return true; |
1294 |
< |
} |
1295 |
< |
} |
1511 |
< |
return false; |
1512 |
< |
} |
1513 |
< |
|
1514 |
< |
// Rectangle blitting |
1515 |
< |
// TODO: optimize for VOSF and target pixmap == screen |
1516 |
< |
void NQD_bitblt(uint32 p) |
1517 |
< |
{ |
1518 |
< |
D(bug("accl_bitblt %08x\n", p)); |
1519 |
< |
|
1520 |
< |
// Get blitting parameters |
1521 |
< |
int16 src_X = (int16)ReadMacInt16(p + acclSrcRect + 2) - (int16)ReadMacInt16(p + acclSrcBoundsRect + 2); |
1522 |
< |
int16 src_Y = (int16)ReadMacInt16(p + acclSrcRect + 0) - (int16)ReadMacInt16(p + acclSrcBoundsRect + 0); |
1523 |
< |
int16 dest_X = (int16)ReadMacInt16(p + acclDestRect + 2) - (int16)ReadMacInt16(p + acclDestBoundsRect + 2); |
1524 |
< |
int16 dest_Y = (int16)ReadMacInt16(p + acclDestRect + 0) - (int16)ReadMacInt16(p + acclDestBoundsRect + 0); |
1525 |
< |
int16 width = (int16)ReadMacInt16(p + acclDestRect + 6) - (int16)ReadMacInt16(p + acclDestRect + 2); |
1526 |
< |
int16 height = (int16)ReadMacInt16(p + acclDestRect + 4) - (int16)ReadMacInt16(p + acclDestRect + 0); |
1527 |
< |
D(bug(" src addr %08x, dest addr %08x\n", ReadMacInt32(p + acclSrcBaseAddr), ReadMacInt32(p + acclDestBaseAddr))); |
1528 |
< |
D(bug(" src X %d, src Y %d, dest X %d, dest Y %d\n", src_X, src_Y, dest_X, dest_Y)); |
1529 |
< |
D(bug(" width %d, height %d\n", width, height)); |
1530 |
< |
|
1531 |
< |
// And perform the blit |
1532 |
< |
const int bpp = bytes_per_pixel(ReadMacInt32(p + acclSrcPixelSize)); |
1533 |
< |
width *= bpp; |
1534 |
< |
if ((int32)ReadMacInt32(p + acclSrcRowBytes) > 0) { |
1535 |
< |
const int src_row_bytes = (int32)ReadMacInt32(p + acclSrcRowBytes); |
1536 |
< |
const int dst_row_bytes = (int32)ReadMacInt32(p + acclDestRowBytes); |
1537 |
< |
uint8 *src = Mac2HostAddr(ReadMacInt32(p + acclSrcBaseAddr) + (src_Y * src_row_bytes) + (src_X * bpp)); |
1538 |
< |
uint8 *dst = Mac2HostAddr(ReadMacInt32(p + acclDestBaseAddr) + (dest_Y * dst_row_bytes) + (dest_X * bpp)); |
1539 |
< |
for (int i = 0; i < height; i++) { |
1540 |
< |
memmove(dst, src, width); |
1541 |
< |
src += src_row_bytes; |
1542 |
< |
dst += dst_row_bytes; |
1543 |
< |
} |
1544 |
< |
} |
1545 |
< |
else { |
1546 |
< |
const int src_row_bytes = -(int32)ReadMacInt32(p + acclSrcRowBytes); |
1547 |
< |
const int dst_row_bytes = -(int32)ReadMacInt32(p + acclDestRowBytes); |
1548 |
< |
uint8 *src = Mac2HostAddr(ReadMacInt32(p + acclSrcBaseAddr) + ((src_Y + height - 1) * src_row_bytes) + (src_X * bpp)); |
1549 |
< |
uint8 *dst = Mac2HostAddr(ReadMacInt32(p + acclDestBaseAddr) + ((dest_Y + height - 1) * dst_row_bytes) + (dest_X * bpp)); |
1550 |
< |
for (int i = height - 1; i >= 0; i--) { |
1551 |
< |
memmove(dst, src, width); |
1552 |
< |
src -= src_row_bytes; |
1553 |
< |
dst -= dst_row_bytes; |
1554 |
< |
} |
1555 |
< |
} |
1556 |
< |
} |
1557 |
< |
|
1558 |
< |
/* |
1559 |
< |
BitBlt transfer modes: |
1560 |
< |
0 : srcCopy |
1561 |
< |
1 : srcOr |
1562 |
< |
2 : srcXor |
1563 |
< |
3 : srcBic |
1564 |
< |
4 : notSrcCopy |
1565 |
< |
5 : notSrcOr |
1566 |
< |
6 : notSrcXor |
1567 |
< |
7 : notSrcBic |
1568 |
< |
32 : blend |
1569 |
< |
33 : addPin |
1570 |
< |
34 : addOver |
1571 |
< |
35 : subPin |
1572 |
< |
36 : transparent |
1573 |
< |
37 : adMax |
1574 |
< |
38 : subOver |
1575 |
< |
39 : adMin |
1576 |
< |
50 : hilite |
1577 |
< |
*/ |
1578 |
< |
|
1579 |
< |
bool NQD_bitblt_hook(uint32 p) |
1580 |
< |
{ |
1581 |
< |
D(bug("accl_draw_hook %08x\n", p)); |
1582 |
< |
|
1583 |
< |
// Check if we can accelerate this bitblt |
1584 |
< |
if (ReadMacInt32(p + 0x018) + ReadMacInt32(p + 0x128) == 0 && |
1585 |
< |
ReadMacInt32(p + 0x130) == 0 && |
1586 |
< |
ReadMacInt32(p + acclSrcPixelSize) >= 8 && |
1587 |
< |
ReadMacInt32(p + acclSrcPixelSize) == ReadMacInt32(p + acclDestPixelSize) && |
1588 |
< |
(ReadMacInt32(p + acclSrcRowBytes) ^ ReadMacInt32(p + acclDestRowBytes)) >= 0 && // same sign? |
1589 |
< |
ReadMacInt32(p + acclTransferMode) == 0 && // srcCopy? |
1590 |
< |
ReadMacInt32(p + 0x15c) > 0) { |
1591 |
< |
|
1592 |
< |
// Yes, set function pointer |
1593 |
< |
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_BITBLT)); |
1280 |
> |
switch (e.keysym.sym) { |
1281 |
> |
case SDLK_NUMLOCK: |
1282 |
> |
case SDLK_CAPSLOCK: |
1283 |
> |
case SDLK_SCROLLOCK: |
1284 |
> |
case SDLK_RSHIFT: |
1285 |
> |
case SDLK_LSHIFT: |
1286 |
> |
case SDLK_RCTRL: |
1287 |
> |
case SDLK_LCTRL: |
1288 |
> |
case SDLK_RALT: |
1289 |
> |
case SDLK_LALT: |
1290 |
> |
case SDLK_RMETA: |
1291 |
> |
case SDLK_LMETA: |
1292 |
> |
case SDLK_LSUPER: |
1293 |
> |
case SDLK_RSUPER: |
1294 |
> |
case SDLK_MODE: |
1295 |
> |
case SDLK_COMPOSE: |
1296 |
|
return true; |
1297 |
|
} |
1298 |
|
return false; |
1299 |
|
} |
1300 |
|
|
1301 |
< |
// Wait for graphics operation to finish |
1600 |
< |
bool NQD_sync_hook(uint32 arg) |
1601 |
< |
{ |
1602 |
< |
D(bug("accl_sync_hook %08x\n", arg)); |
1603 |
< |
return true; |
1604 |
< |
} |
1605 |
< |
|
1606 |
< |
void VideoInstallAccel(void) |
1301 |
> |
static bool is_ctrl_down(SDL_keysym const & ks) |
1302 |
|
{ |
1303 |
< |
// Install acceleration hooks |
1609 |
< |
if (PrefsFindBool("gfxaccel")) { |
1610 |
< |
D(bug("Video: Installing acceleration hooks\n")); |
1611 |
< |
uint32 base; |
1612 |
< |
|
1613 |
< |
SheepVar bitblt_hook_info(sizeof(accl_hook_info)); |
1614 |
< |
base = bitblt_hook_info.addr(); |
1615 |
< |
WriteMacInt32(base + 0, NativeTVECT(NATIVE_BITBLT_HOOK)); |
1616 |
< |
WriteMacInt32(base + 4, NativeTVECT(NATIVE_SYNC_HOOK)); |
1617 |
< |
WriteMacInt32(base + 8, ACCL_BITBLT); |
1618 |
< |
NQDMisc(6, bitblt_hook_info.ptr()); |
1619 |
< |
|
1620 |
< |
SheepVar fillrect_hook_info(sizeof(accl_hook_info)); |
1621 |
< |
base = fillrect_hook_info.addr(); |
1622 |
< |
WriteMacInt32(base + 0, NativeTVECT(NATIVE_FILLRECT_HOOK)); |
1623 |
< |
WriteMacInt32(base + 4, NativeTVECT(NATIVE_SYNC_HOOK)); |
1624 |
< |
WriteMacInt32(base + 8, ACCL_FILLRECT); |
1625 |
< |
NQDMisc(6, fillrect_hook_info.ptr()); |
1626 |
< |
} |
1303 |
> |
return ctrl_down || (ks.mod & KMOD_CTRL); |
1304 |
|
} |
1628 |
– |
#endif |
1305 |
|
|
1306 |
|
|
1307 |
|
/* |
1309 |
|
* and -2 if the key was recognized as a hotkey |
1310 |
|
*/ |
1311 |
|
|
1636 |
– |
static bool is_ctrl_down(SDL_keysym const & ks) |
1637 |
– |
{ |
1638 |
– |
return ctrl_down || (ks.mod & KMOD_CTRL); |
1639 |
– |
} |
1640 |
– |
|
1312 |
|
static int kc_decode(SDL_keysym const & ks, bool key_down) |
1313 |
|
{ |
1314 |
|
switch (ks.sym) { |
1378 |
|
case SDLK_RCTRL: return 0x36; |
1379 |
|
case SDLK_LSHIFT: return 0x38; |
1380 |
|
case SDLK_RSHIFT: return 0x38; |
1381 |
+ |
#if (defined(__APPLE__) && defined(__MACH__)) |
1382 |
+ |
case SDLK_LALT: return 0x3a; |
1383 |
+ |
case SDLK_RALT: return 0x3a; |
1384 |
+ |
case SDLK_LMETA: return 0x37; |
1385 |
+ |
case SDLK_RMETA: return 0x37; |
1386 |
+ |
#else |
1387 |
|
case SDLK_LALT: return 0x37; |
1388 |
|
case SDLK_RALT: return 0x37; |
1389 |
|
case SDLK_LMETA: return 0x3a; |
1390 |
|
case SDLK_RMETA: return 0x3a; |
1391 |
+ |
#endif |
1392 |
|
case SDLK_MENU: return 0x32; |
1393 |
|
case SDLK_CAPSLOCK: return 0x39; |
1394 |
|
case SDLK_NUMLOCK: return 0x47; |
1495 |
|
// Keyboard |
1496 |
|
case SDL_KEYDOWN: { |
1497 |
|
int code = -1; |
1498 |
< |
if (use_keycodes) { |
1498 |
> |
if (use_keycodes && !is_modifier_key(event.key)) { |
1499 |
|
if (event2keycode(event.key, true) != -2) // This is called to process the hotkeys |
1500 |
|
code = keycode_table[event.key.keysym.scancode & 0xff]; |
1501 |
|
} else |
1523 |
|
} |
1524 |
|
case SDL_KEYUP: { |
1525 |
|
int code = -1; |
1526 |
< |
if (use_keycodes) { |
1526 |
> |
if (use_keycodes && !is_modifier_key(event.key)) { |
1527 |
|
if (event2keycode(event.key, false) != -2) // This is called to process the hotkeys |
1528 |
|
code = keycode_table[event.key.keysym.scancode & 0xff]; |
1529 |
|
} else |
1530 |
|
code = event2keycode(event.key, false); |
1531 |
< |
if (code >= 0 && code != 0x39) { // Don't propagate Caps Lock releases |
1532 |
< |
ADBKeyUp(code); |
1531 |
> |
if (code >= 0) { |
1532 |
> |
if (code == 0x39) { // Caps Lock released |
1533 |
> |
if (caps_on) { |
1534 |
> |
ADBKeyUp(code); |
1535 |
> |
caps_on = false; |
1536 |
> |
} else { |
1537 |
> |
ADBKeyDown(code); |
1538 |
> |
caps_on = true; |
1539 |
> |
} |
1540 |
> |
} else |
1541 |
> |
ADBKeyUp(code); |
1542 |
|
if (code == 0x36) |
1543 |
|
ctrl_down = false; |
1544 |
|
} |
1605 |
|
|
1606 |
|
// Check for first column from left and first column from right that have changed |
1607 |
|
if (high) { |
1608 |
< |
if (VIDEO_MODE_DEPTH < VIDEO_DEPTH_8BIT) { |
1608 |
> |
if ((int)VIDEO_MODE_DEPTH < VIDEO_DEPTH_8BIT) { |
1609 |
|
const int src_bytes_per_row = bytes_per_row; |
1610 |
|
const int dst_bytes_per_row = drv->s->pitch; |
1611 |
|
const int pixels_per_byte = VIDEO_MODE_X / src_bytes_per_row; |